Hey there!
I have created a custom xml sensor which should have different "LimitMaxError" values depending on a condition. The sample below should illustrate what I am trying.
$hour = (get-date).Hour
if($hour -lt 9){
$limit = 5
} else{
$limit = 15
}
$xml += "<?xml version=""1.0"" encoding=""Windows-1252"" ?>"
$xml += "<prtg>"
$xml += "<result>"
$xml += "<Channel>Hour</Channel>"
$xml += "<Value>$hour</Value>"
$xml += "<Unit>Custom</Unit>"
$xml += "<CustomUnit>#</CustomUnit>"
$xml += "<LimitMaxError>$limit</LimitMaxError>"
$xml += "<LimitMode>1</LimitMode>"
$xml += "</result>"
$xml += "</prtg>"
$xml
If $hour < 9, $limit = 5 and if $hour > 9, $limit = 15. When I run this script in PowerShell ISE the value of $limit is correctly changing dependig on the condition but when the sensor is created the value of <LimitMaxError> does not change. The Value $hour is updated correctly.
Is there any way to realize this or can't limits of a channel be updated during script runtime?
Thanks in advance Kind Regards
Article Comments
Attention: This article is a record of a conversation with the Paessler support team. The information in this conversation is not updated to preserve the historical record. As a result, some of the information or recommendations in this conversation might be out of date.
Hello,
thank you for the fast reply. I must have skipped this.
Thanks for the example.
Kind Regards
Oct, 2015 - Permalink
Hello,
we appreciate your inquiry.
As per the documentation available within PRTG (Setup > PRTG API > Custom Sensors):
This also applies to the following elements:
Within Custom Sensors, you can "workaround" this by using the following tags to set the sensor to error or warning based on specific conditions within the script:
As example:
Best Regards,
Oct, 2015 - Permalink