Make nagios execute script

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.
Locked
Hanza
Posts: 8
Joined: Fri Dec 25, 2020 5:24 pm

Make nagios execute script

Post by Hanza »

I have a php script can read status.dat file and return data at json format in data.json file.
So how can I make nagios core execute a php script in background like the plugins?
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: Make nagios execute script

Post by gormank »

You can define a command in the commands.cfg or in CCM if using nagios XI. Since nagios expects some text output and a return value between 0-3 your script needs to be set to do so. Then you can create a serive in nagios to execute the script periodically.
Hanza
Posts: 8
Joined: Fri Dec 25, 2020 5:24 pm

Re: Make nagios execute script

Post by Hanza »

- If I do the script like a plugin then I need to add it to one of the hosts, so nagios can execute the script. But I don't want the user to see the service, I just want it to be executed in the background!!.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Make nagios execute script

Post by mcapra »

Why not use something like cron?
https://opensource.com/article/17/11/how-use-cron-linux

Nagios Core is for monitoring. If you just want to periodically run a script or command, cron is a much more lightweight and ubiquitous option for that particular use case IMO.
Former Nagios employee
https://www.mcapra.com/
Locked