I have following sensor to report number of failed orders in our system database. I could not fix the script to reported expected error message. Please provide any suggestion or guidance to fix the issue.
#!/bin/bash prtg_scripts_result=`cat <<EOF <?xml version="1.0" encoding='UTF-8'?> <prtg> EOF ` PSQL_QUERY="SELECT COUNT(\"OrderID\") FROM \"Sales\" WHERE \"OrderID\" IN ('SO', 'RN') AND \"StatusID\" = 'F'" PSQL_EXEC=$(echo "$PSQL_QUERY" | psql -Uxxx -h10.12.13.14 -t --no-align --field-separator=$'\011') if [ "$PSQL_EXEC" -eq 0 ]; then PSQL_EXEC=0 else PSQL_EXEC=$PSQL_EXEC fi prtg_scripts_result=$prtg_scripts_result`cat <<EOF <result> <channel>Failed Order</channel> <value>$PSQL_EXEC</value> <Unit>Custom</Unit> <LimitMaxError>0.5</LimitMaxError> <LimitErrorMsg>$PSQL_EXEC Failed Order</LimitErrorMsg> <LimitMode>1</LimitMode> </result> </prtg> EOF ` echo "$prtg_scripts_result"
Current error message displayed in MAP and Sensor:
11 # (Failed Order) is above the error limit of 0.50 # in Failed Order. 11 Failed Order |
Expectation:
11 Failed Order |
Note:
Following SSH-Script is not useful in my case due to sensor should be turned RED if there is more than 1 failed order. There is no valid error code available in PRTG to display without any error code PExxxx.
#!/bin/bash get_row_count(){ rowCount=$(echo "$1" | psql -Uxxx -h10.12.13.14 -t --no-align --field-separator=$'\011') if [ $rowCount -eq 12 ] then echo "0:$rowCount:$rowCount Zero Order Status is in Provisioning Failed" else echo "1:$rowCount:$rowCount Failed Order" fi } main(){ get_row_count "SELECT COUNT(\"OrderID\") FROM \"Sales\" WHERE \"OrderID\" IN ('SO', 'RN') AND \"StatusID\" = 'F'" } main "$1"
Warning message:
11 Failed Order |
Article Comments
Hello Luciano Lingnau,
Thank you for the reply.
Strange that following message repeated for each scanned interval
11 # (Failed Order) is above the error limit of 0.50 # in Failed Order. 11 Failed Order |
Sample result:
<?xml version="1.0" encoding='UTF-8'?>\\ <prtg>\\<result>\\ <channel>Failed Order</channel>\\ <value>11</value>\\ <Unit>Custom</Unit>\\ <LimitMaxError>0.5</LimitMaxError>\\ <LimitErrorMsg>11 Failed Order</LimitErrorMsg>\\ <LimitMode>1</LimitMode>\\ </result>\\ <text>11 Failed Order </text>\\ </prtg>
I cannot use <error>1</error> like following due to channel and unit value will be ignored.
Last/Current value is required in report generation to find number of failed orders reported per month.
<prtg>\\ <error>1</error>\\ <text>Value ($value) is above limit</text>\\ </prtg>
It would be better to have a feature request to display exact message passed in <LimitErrorMsg> instead of:
%value %unit (%channel) is above the %limittype limit of %definedlimit %unit in %channel.
or SSH Script without displaying error code PExx in message.
Value | Description |
---|---|
0 | OK |
1 | WARNING |
2 | Error |
3 | System Error (e.g. a network/socket error) |
4 | Protocol Error (e.g. web server returns a 404) |
5 | Content Error (e.g. a web page does not contain a required word) |
Dec, 2017 - Permalink
Hi,
Is it now possible to customise the returned message now - without having to use <error></error> & <text></text>??
If you have a sensor with many channels and you want the other channels to continue to log data than this is really not an ideal solution!
We need to be able to remove the excessive message prefix;
%value %unit (%channel) is above the %limittype limit of %definedlimit %unit in %channel.
It's really excessive~
--
As a work around for this, I use 2 sensors - one which I return <error></error> & <text></text> in the schema and then another sensor which continues to log values but never goes down.
Jan, 2019 - Permalink
Hi Jaime,
This is still not possible and also not planned for the future at the moment.
If tyou think this could be important for other customers, you can also open a feature request here. Please follow this manual. If the post gets upvotes we will take a closer look.
Kind regards,
Birk Guttmann, Tech Support Team
Jan, 2019 - Permalink
Please allow us to focus solely on the script's output:
When using this:
You're creating a limit for this channel, in this case whenever the limit is crossed PRTG will display the following standard text:
These are also only passed on the first scan/result and are not updated later. Please have a look here for details:
If you want o have complete control over the error/warning text you need to compare the current value against a limit within the script and then produce an output similar to this:
The same goes for warning:
Best Regards,
Luciano Lingnau [Paessler Support]
Dec, 2017 - Permalink