Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $prtghost="<your-prtg-host>"
- $username="<your-prtg-user>";
- $passhash="<your-prtg-users-passhash>" # can be obtained from the accoutn configuration
- $Sensors = ((Invoke-WebRequest -URI "http://$($prtghost)/api/table.json?content=sensors&output=json&columns=objid,device,sensor&username=$($username)&passhash=$($passhash)").Content | ConvertFrom-Json)
- $Devices = ((Invoke-WebRequest -URI "http://$($prtghost)/api/table.json?content=devices&output=json&columns=objid,device&username=$($username)&passhash=$($passhash)").Content | ConvertFrom-Json)
- Write-Output "sep=;"
- Write-Output "DeviceID;Device;Sensor;SensorID;Channel;ChannelID;LowerWarningLimit;LowerErrorLimit;UpperWarningLimit;UpperErrorLimit"
- Foreach($Device in $Devices.devices){
- $Sensors = ((Invoke-WebRequest -URI "http://$($prtghost)/api/table.json?content=sensors&output=json&id=$($Device.objid)&columns=objid,device,sensor&username=$($username)&passhash=$($passhash)").Content | ConvertFrom-Json)
- Foreach($Sensor in $Sensors.sensors){
- $Channels = ((Invoke-WebRequest -URI "http://$($prtghost)/api/table.json?content=channels&output=json&columns=name,lastvalue_,objid&id=$($sensor.objid)&username=$($username)&passhash=$($passhash)").Content | ConvertFrom-Json);
- Foreach($Channel in $Channels.channels){
- $ChannelSettings = (Invoke-WebRequest -Uri "http://$($prtghost)/controls/channeledit.htm?_hjax=true&id=$($Sensor.objid)&username=$($username)&passhash=$($passhash)&channel=$($Channel.objid)");
- if(($channel.objid -eq -4) -or $Channel.name -eq "Execution Time"){ continue;}
- $LowerWarningLimit = $ChannelSettings.InputFields.FindById("limitminwarning_$($Channel.objid)").value
- $LowerErrorLimit = $ChannelSettings.InputFields.FindById("limitminerror_$($Channel.objid)").value
- $UpperWarningLimit = $ChannelSettings.InputFields.FindById("limitmaxwarning_$($Channel.objid)").value
- $UpperErrorLimit = $ChannelSettings.InputFields.FindById("limitmaxerror_$($Channel.objid)").value
- Write-Output ("{0};{1};{2};{3};{4};{5};{6};{7};{8};{9}" -f $Device.device,$Device.objid,$Sensor.sensor,$Sensor.objid,$Channel.name,$Channel.objid,$LowerWarningLimit,$LowerErrorLimit,$UpperWarningLimit,$UpperErrorLimit)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement