Some scenarios require the use of a reverse or negated service check. An example of this would be when monitoring network bandwidth to ensure it is meeting certain specifications, such as returning OK when the bandwidth is at 500 Mbps and returning a WARNING when the bandwidth dips below 400 Mbps.
The Negate plugin
The Negate plugin will be useful in instances like this as it is able to reverse or negate the result code being returned by a regular check.
Considerations
The plugin has some considerations that need to be taken into account when being used.
1. The negate plugin can only run plugins located in the /opt/plugins directory. This is for security concerns, to prevent users from using it to run system commands (such as though that are run through sudo). An error will be shown if the plugin being run is not in the /opt/plugins directory.
[root@op5-system ~]# asmonitor /opt/plugins/negate "$(which cat) /etc/passwd"
negate: Can only be used with plugins from /opt/plugins/
2. The plugin, by default, only changes the result code of the plugin it is negating.
On a normal run of check_ping, the result code is '2', corresponding to CRITITCAL.
[root@op5-system ~]# asmonitor /opt/plugins/check_ping -H 172.16.20.69
CRITICAL - 172.16.20.69: rta nan, lost 100%|rta=0.000ms;200.000;500.000;0; pl=100%;40;80;;
[root@op5-system ~]# echo $?
2
When run through the negate plugin, the result code is changed but the output text is not.
[root@op5-system ~]# asmonitor /opt/plugins/negate /opt/plugins/check_ping -H 172.16.20.69
CRITICAL - 172.16.20.69: rta nan, lost 100%|rta=0.000ms;200.000;500.000;0; pl=100%;40;80;;
[root@op5-system ~]# echo $?
0
3. Changing the plugin's output text can be done by specifying the -s flag.
The examples in #2 show that the text output is CRITICAL regardless of running the negate plugin. When specifying -s, the text output is changed to match the negated result code.
[root@op5-system ~]# asmonitor /opt/plugins/negate -s /opt/plugins/check_ping -H 172.16.20.69
OK - 172.16.20.69: rta nan, lost 100%|rta=0.000ms;200.000;500.000;0; pl=100%;40;80;;
[root@op5-system ~]# echo $?
0
Note that this will only work for text output in UPPERCASE.
If you have any further questions:
- Please contact with our Client Services team via the chat service box available in any of our websites or via email to support@itrsgroup.com
- Make sure you provide to us:
- ANY LOG FILE OR DIAGNOSTIC
- ANY SCREENSHOT
Comments
0 comments
Please sign in to leave a comment.