Below is the simple Python plugin I have written to achieve this. This python script gets all jobs stats using the Jenkins API and then parses for the stability of the Job.
But there was a catch !!! the file that I wanted to monitor is actually owned by root user.
So my custom written plugin was working very well when I am running manually (using root user ) but failing when nagios was trying to run it via NRPE it was not working.
Solution : Use Sudo to run the custom plugin , so that when NRPE tries to execute the script it is actually running as a root user.
For that , add a very restrictive entry in sudoers file , giving access to the Nagios user only for that single command as below,
nagios ALL=(ALL) NOPASSWD: /usr/local/nagios/libexec/check_my_file
and in the nrpe.cfg use sudo to run the command , as shown below
and its done 🙂
Note : On Centos and Redhat Machines you also need to turn off the requiretty option in your suoders file
Comment out the line,
This how to will show how to install the open source software NAGIOS to monitor network devices such as switches, routers, servers, firewall…etc.
The detail instruction for installing WMI is found here
A good detail of installing wmi client and wmi plugin is available at interwebplus.com
Note : if your few of the perl modules were outdated, The check_wmi plugin will not work.
in that case you can use –IgnoreMyOutDatedPerlModuleVersions case.