Page 1 of 1

Find error word in log file

Posted: Tue Feb 15, 2022 4:29 am
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

Re: Find error word in log file

Posted: Tue Feb 15, 2022 2:22 pm
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