Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # note: it's easier if you enter the parameters directly in the script and save it.
- # Only the sensor ID should be passed like this in the sensors parameter settings: -sensorid 1234
- param(
- $prtgusername = "<the-username-you-want-to-use>",
- $prtgpasshash = "<your-prtg-user-passhash>",
- $sensoroid = <the id of the sensor that retrieves the timestamp>,
- $prtg = "<the-url-of-your-prtg-server, e.g. http://your-prtg-server>"
- )
- $prtgurl = ([string]::Format("http://{3}/api/getsensordetails.json?id={0}&username={1}&passhash={2}",$sensoroid,$prtguser,$prtgpass,$prtg))
- $result = ((Invoke-WebRequest -UseBasicParsing $prtgurl) | ConvertFrom-Json).sensordata.lastmessage
- [datetime]$timestamp = [datetime]::ParseExact($result,"yyyy-mm-dd HH:MM:ss",$null)
- [datetime]$currentTimeStamp = (Get-Date);
- $timediff = (New-TimeSpan -Start $timestamp -End $currentTimeStamp).Seconds
- if($timediff -lt 0){ $timediff = $timediff * -1 }
- Write-Host ("{0}:Current time offset between PRTG and host: {0} seconds" -f $timediff);
Advertisement
Add Comment
Please, Sign In to add comment