Find error word in log file

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
RIDS_I2MP
Posts: 751
Joined: Thu Mar 13, 2014 9:25 am

Find error word in log file

Post by RIDS_I2MP »

Hi Team,

We want to monitor a log file in a specific location. The script/plugin should search for word 'error' in the log file.
We are using Aix systems on which we have installed NRPE agent.

Thanks and regards
Prashanth Chenna
Thanks & Regards,
I2MP Team.
User avatar
pbroste
Posts: 1288
Joined: Tue Jun 01, 2021 1:27 pm

Re: Find error word in log file

Post by pbroste »

Hello Prashanth Chenna,

Thanks for reaching out, appears that you have already installed NRPE agent on your AIX environment.

Here is an example script that you can work from:
#!/bin/bash

countWarnings=$(grep 'yourword" /var/log/somelog | wc -l)

case $countWarnings in [0]*)
echo "OK - $countWarnings% of found in log file."
exit 0 ;;

[1-100]*)
echo "WARNING - $countWarnings% of found in log file."
exit 1 ;;

esac
This would be placed in the plugin directory.

Thanks,
Perry
Locked