Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Yes I am trying to figure out how to write a plugin that contains conditional logic in regards to sending an alert if more than one superuser exists on the server. The only thing I have so far is the following command:
awk -F: '{if ($3 < 1) print $0}' < /etc/passwd
which prints --> root0:0:root:/root:/bin/bash
This is close to what I need however I need this to report if the total count is more than one and I have no clue how to convert this into commands
So another words if I ran the same command and it printed the following then send an alert
awk -F: '{if ($3 < 1) print $0}' < /etc/passwd
root0:0:root:/root:/bin/bash
super0:0:super:/super:/bin/bash
-> send alert to Nagios
Something as simple as piping your current command into "wc -l" to check for total line count should work. If it's greater than 1, return critical, if 1 return OK. When returning, simply use exit(0) or exit(2) for OK and Critical respectively. You probably should take a look at the plugin guidelines for a more detailed description.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.