I want to create a script where i check the logfile every 5 or 10 minutes to know if the service is up and running, and also, to know if the logfile is receiving and sending these files that are being received (more like if a new file enters in the logfile, or not receiving anything.) In case of not receiving anything in 5 or 10 mins, depending on the configuration, warns me via Nagios Monitoring. I have no idea how to start scripting this one.
-
Nagios (resp. nrpe) comes with lots of check scripts (in `/usr/lib/nagios/plugins`), furthermore masses of scripts for each and any service can be found in the internet. These scripts are being scheduled and executed from a remote host with nagios or icinga2. – digijay Aug 24 '21 at 20:43
2 Answers
Well this depends on the contents of your logfiles, but here are some suggestions, which might help you:
If you just want to see if a process is running, you can use the nagios plugin "check_procs".
To check if a logfile is beeing written to, you can use the nagios plugin "check_file_age".
If you want to check for certain expressions, this is a great plugin: https://labs.consol.de/nagios/check_logfiles

- 648
- 4
- 14
-
Hi, thanks for the reply. In my case, this logfile is "feeded" every minute, the situation was: the service was up and running, but even with the service up, was in zombie state, service was running, but not receiving and transmitting files. The alert was needed to fix this problem. So i was thinking about to monitor the logfile every 5 minutes to check if the logfile was feeded, if it's feeded, ok. If it's not, i want Nagios to warn me. – Jhony Aug 25 '21 at 03:05
You are better off checking the process table via ps
to see if your process is running correctly.
Some nagios plugins you may consider:
https://exchange.nagios.org/directory/Plugins/Operating-Systems/Linux/check_ps-2Esh/details
https://exchange.nagios.org/directory/Plugins/Operating-Systems/Linux/check_logfiles/details
See check_procs @Virsacer says as well.

- 25,540
- 2
- 42
- 72
-
Thanks for the reply. The service was up and running, but not working as expected. Like i said to Virsacer, the service was running in a zombie state, was up and running, but without any action... A restart in the service was needed to solve the problem. And to avoid situations like this in the future, i want to create this script to alert me. – Jhony Aug 25 '21 at 03:12