Yes i could do that but as far as i know monit remembers the last
file position and does only scan new entries each cycle.|
I would then basically have to replicate this logic - suboptimal...
On 18.06.2015 00:13, Paul
I'd recommend putting your tests/conditionals
into a shell script, then check for the exit code from the
script, for example:
if [ ! -e $MYERRLOG ];then # If the
error log doesn't exist, all is good, so exit 'happy'
grep "^.*FATAL.*$" $MYERRLOG >/dev/null 2>&1 #
the file exists, this will be reached. grep the file for the
error line, and check the return status
if [ "$STAT" -eq "0" ];then
exit 0 # if the return status shows that the error
was found, exit with 'unhappy' status
exit 1 # otherwise, all is good
and your monit script:
check program my_test_script with path /usr/local/bin/my_test_script
if status != 1 then alert
if status != 1 for 3 cycles then alert
There's obviously other, probably 'cleaner' ways to do this, but
that's the sort of construct I use.
On 6/17/15 12:57 AM, Ben Soot wrote:
I want to be alerted if file content (in an error log file)
matches a pattern. The difficulty is that the file itself might
not exist at all, which is ok.
How would you do that?
My current clause gives me a read flag in mmonit when the file
does not exist:
check file myapp-err.log with path
"^.*FATAL.*$" then alert