Page 1 of 1
Make nagios execute script
Posted: Sat Jan 09, 2021 7:38 am
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?
Re: Make nagios execute script
Posted: Tue Jan 12, 2021 4:07 pm
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.
Re: Make nagios execute script
Posted: Wed Jan 13, 2021 5:05 am
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!!.
Re: Make nagios execute script
Posted: Mon Jan 18, 2021 9:35 pm
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.