Check file string and show the output

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
amitw
Posts: 28
Joined: Tue Jun 28, 2016 8:07 am

Check file string and show the output

Post by amitw »

Hi,
I have a bash script that runs every minute and creating a TXT file with the output.
I trying to figure how i can display the output of the TXT file on Nagios GUI and alert according to the output.
for an example, if the TXT file says "OK" - show the output on Nagios GUI and the status will be OK.
If the TXT file says "Problem" - show the output on Nagios GUI and the status will be critical

Appreciate your help.

Thanks
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Check file string and show the output

Post by lmiltchev »

Does your text file get "completely overwritten" every minute or you append to the existing text? Other words, do you expect to have only one "OK" or "Problem" pattern in the file or multiple ones (some old and some new)? You can look for a suitable plugin on the Nagios Exchange.

If you needed something simple (when you don't have multiple "OK" or "Problem" entries in the file), you could probably modify this script a bit to achieve your goal:
https://gist.githubusercontent.com/dvar ... in_file.sh

If you needed a plugin with a greater functionality, you could try this one:
https://labs.consol.de/nagios/check_logfiles/index.html
or search Nagios Exchange for other plugins.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked