Machine A = nagios master, Machine B = edge machine.
In machine A's host.cfg I have:
define command {
command_name check_tok
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_tok 123
}
define service
use bg-service
hostgroup_name test_oob1
service_description Recall12
check_command check_tok
servicegroups nrpe
}
In Machine B's commands.cfg in /etc/nrpe.d I have:
command[check_tok]=/usr/lib64/nagios/plugins/check_test.sh
In machine's B's /usr/lib64/nagios/plugins, I have check_test.py and check_test.sh.
check.test.sh looks like the following:
#!/bin/sh
/usr/bin/sudo /usr/lib64/nagios/plugins/check_test.py
exit $?
and check_test.py looks like the following:
#!/usr/bin/env python
import sys
if __name__ == "__main__":
if sys.argv == '123'
print("this ok")
sys.exit(0)
else:
print('this is not 123')
sys.exit(2)
In machine's B /etc/sudoers.d/nrpe
nrpe ALL = (ALL) NOPASSWD: /usr/lib64/nagios/plugins/check_test.py
As you can see, the argument i am pasting to check_test.py is '123' and it should result in a sys.exit(0). however, in my nagios mon it said " NRPE: Unable to read output "
command[check_tok]=/usr/lib64/nagios/plugins/check_test
tocommand[check_tok]=/usr/lib64/nagios/plugins/check_test.sh
.