I am writing a script which will return the last sync code and the last successful sync date so that I can monitor my SCCM's server ability to keep itself up to date with Microsoft's update catalog.

Import-Module (Join-Path $(Split-Path $env:SMS_ADMIN_UI_PATH) ConfigurationManager.psd1)

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

$syncResult = get-cmsoftwareupdatesyncstatus

$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: %value</LimitErrorMsg>
</result>
<result>
<channel>Last Successful Sync Time</channel>
<value>" + $syncResult.lastSuccessfulSyncTime + "</value>
<unit>float</unit>
</result>"

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

The idea is that if an error occurs, I can tell how long it has been a problem by having the last successful sync returned right next to it. How can I have PRTG display text in a channel? I keep getting Custom SNMP String questions with my current level of Google-fu.


Article Comments

Hi,

Unfortunately it is not possible to show a date format as a text in a channel. I would recommend ro rewrite your script to calculates the difference between today's date and last update date. After this you can use <unit> Time Seconds to display the difference and convert it to hours if necessary.
You'll find more information here

Kind regards.


Sep, 2019 - Permalink