New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

300.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


Custom Sensor not showing a value

Votes:

0

Your Vote:

Up

Down

Same sensor from before (https://kb.paessler.com/en/topic/86773-script-returning-a-string-value) but I'm having trouble getting my time elapsed sensor to actually display the value I'm passing to it.

$module = (Join-Path $(Split-Path $env:SMS_ADMIN_UI_PATH) ConfigurationManager.psd1)

Import-module $module

$SiteCode = Get-PSDrive -PSProvider CMSITE
Set-Location -Path "$($SiteCode.Name):\"

$syncResult = get-cmsoftwareupdatesyncstatus

$timestamp = get-date
$timeDiff = $timestamp - $syncResult.lastSuccessfulSyncTime

$xmlOutput = '<?xml version="1.0" encoding="UTF-8" ?><prtg>'

$xmlOutput = $xmlOutput + "<result>
<channel>Sync Code</channel>
<value>" + $syncResult.lastSyncErrorCode + "</value>
<unit>Absolute</unit>
<limitmode>1</limitmode>
<LimitMaxError>0</LimitMaxError>
<LimitErrorMsg>SCCM Error: Sync with Microsoft Update Catalog failed.  Code: " + $syncResult.lastSyncErrorCode + "</LimitErrorMsg>
</result>
<result>
<channel>Successful Sync Age</channel>
<value>" + $timeDiff.TotalHours + "</value>
<unit>TimeHours</unit>
<float>1</float>
<DecimalMode>All</DecimalMode>
<limitMode>1</limitMode>
<limitMaxError>170</limitMaxError>
<LimitErrorMsg>SCCM has not been able to sync with Microsoft update in 7 days.</LimitErrorMsg>
</result>
"

$xmlOutput = $xmlOutput + "</prtg>"
$xmlOutput

When I tweak the channel settings, they are reflected in PRTG (converting the channel to TimeHours, for example). However the value is always zero. If I run the script manually in Powershell the totalHours property seems to be correctly displayed within the 'value' tag.

channel-configuration channel-settings custom-sensor powershell sccm

Created on Oct 2, 2019 6:42:41 PM by  whobutdrew (50) 1 1

Last change on Oct 3, 2019 4:06:26 AM by  Sven Roggenhofer [Paessler Technical Support]



Best Answer

Accepted Answer

Votes:

0

Your Vote:

Up

Down

You can close this. I turned on the EXE results for another SCCM-related sensors I am developing and figured out the problem for both.

When I was testing under my user account, the values were being generated. But when the user that PRTG was configured to use to run the sensor tried to execute the SCCM-specific cmdlets, some of them failed because it couldn't respond with "always allow" when Powershell prompted the 'user' to confirm that the module was trusted. Once I did that, both scripts began to display their values appropriately.

If I submit these sensors to Script World, I'll be sure to note this arcane requirement!

Created on Oct 3, 2019 5:33:20 PM by  whobutdrew (50) 1 1



2 Replies

Votes:

1

Your Vote:

Up

Down

Hi there,

Please activate the "Write EXE result to disk" option in the sensor's settings and post the log files (Result of Sensor XXX.Data.txt and Result of Sensor XXX.txt) located on the corresponding probe under "C:\ProgramData\Paessler\PRTG Network Monitor\Logs (Sensors)".

Best regards.

Created on Oct 3, 2019 8:23:00 AM by  Dariusz Gorka [Paessler Support]



Accepted Answer

Votes:

0

Your Vote:

Up

Down

You can close this. I turned on the EXE results for another SCCM-related sensors I am developing and figured out the problem for both.

When I was testing under my user account, the values were being generated. But when the user that PRTG was configured to use to run the sensor tried to execute the SCCM-specific cmdlets, some of them failed because it couldn't respond with "always allow" when Powershell prompted the 'user' to confirm that the module was trusted. Once I did that, both scripts began to display their values appropriately.

If I submit these sensors to Script World, I'll be sure to note this arcane requirement!

Created on Oct 3, 2019 5:33:20 PM by  whobutdrew (50) 1 1



Please log in or register to enter your reply.


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.