On Thu, Jun 18, 2015 at 9:00 AM, <[email protected]> wrote:
> Send monit-general mailing list submissions to > [email protected] > > To subscribe or unsubscribe via the World Wide Web, visit > https://lists.nongnu.org/mailman/listinfo/monit-general > or, via email, send a message with subject or body 'help' to > [email protected] > > You can reach the person managing the list at > [email protected] > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of monit-general digest..." > > > Today's Topics: > > 1. Re: Conditionally check file content (Paul Theodoropoulos) > 2. Fwd: Monit: 'Matching' functionality isn't working > (Marie Mcallister) > 3. Re: Monit: 'Matching' functionality isn't working (Martin Pala) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Wed, 17 Jun 2015 15:13:26 -0700 > From: Paul Theodoropoulos <[email protected]> > To: This is the general mailing list for monit > <[email protected]> > Subject: Re: Conditionally check file content > Message-ID: <[email protected]> > Content-Type: text/plain; charset="utf-8"; Format="flowed" > > I'd recommend putting your tests/conditionals into a shell script, then > check for the exit code from the script, for example: > > cat /usr/local/bin/my_test_script > #!/bin/sh > MYERRLOG=/var/www/myapp/log/myapp-err.log > if [ ! -e $MYERRLOG ];then # If the error log doesn't exist, > all is good, so exit 'happy' > exit 1 > fi > 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 > STAT=$? > if [ "$STAT" -eq "0" ];then > exit 0 # if the return status shows that the error was found, > exit with 'unhappy' status > else > exit 1 #otherwise, all is good > fi > > 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: > > Hi there, > > > > 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 /var/www/myapp/log/myapp-err.log > > if match > > "^.*FATAL.*$" then alert > > > > > > > > Thanks Ben > > > > > > > > > > -- > > To unsubscribe: > > https://lists.nongnu.org/mailman/listinfo/monit-general > > -- > Paul Theodoropoulos > www.anastrophe.com > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://lists.nongnu.org/archive/html/monit-general/attachments/20150617/ac0a4117/attachment.html > > > > ------------------------------ > > Message: 2 > Date: Wed, 17 Jun 2015 19:38:00 -0700 > From: Marie Mcallister <[email protected]> > To: [email protected] > Subject: Fwd: Monit: 'Matching' functionality isn't working > Message-ID: > <CAA3TBssrckESs7mv3Df8yrpM4bBLv2= > [email protected]> > Content-Type: text/plain; charset="utf-8" > > Hello, > > I have a process that's kicked off from a custom script. The process does > not end with '.pid' so I am trying to use 'matching'. However it seems to > be breaking on the whitespace (just stops after 'bin/bash'), no matter how > I format the command. The commands themselves do work fine, outside of > monit. > > Here is what I am trying to use: > > check process example_process matching "example_process" > start program = "/bin/bash -c 'nohup /mnt1/path/to/custom/bin/run.sh &'" > stop program = "/usr/bin/killall example_process" > if cpu > 80% for 2 cycles then alert > if cpu > 95% for 5 cycles then restart > if totalmem > 500.0 MB for 5 cycles then restart > if children > 3 then restart > > Errors logged: > > [UTC Jun 18 02:01:46] info : 'system_ip-10-0-11-189' Monit started > [UTC Jun 18 02:01:46] error : 'example_process' process is not running > [UTC Jun 18 02:01:46] info : 'example_process' trying to restart > [UTC Jun 18 02:01:46] info : 'example_process' start: /bin/bash > [UTC Jun 18 02:02:16] error : 'example_process' failed to start > rinse, repeat... > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://lists.nongnu.org/archive/html/monit-general/attachments/20150617/45d2e622/attachment.html > > > > ------------------------------ > > Message: 3 > Date: Thu, 18 Jun 2015 11:56:53 +0200 > From: Martin Pala <[email protected]> > To: This is the general mailing list for monit > <[email protected]> > Subject: Re: Monit: 'Matching' functionality isn't working > Message-ID: <[email protected]> > Content-Type: text/plain; charset=utf-8 > > Hello Marie, > > you can test the pattern using CLI: > > monit procmatch ?<pattern>? > > If you won?t find the pattern, please post output of the real process: ?ps > -ef | grep <example_process>?, so we can test the match. > > > Regards, > Martin > > Hi Martin, Thank you for the response. The proc match is successful: monit procmatch classification List of processes matching pattern "classification": ------------------------------------------ /mnt1/build/seeing/build/bin/classification_node -c /mnt1/config/classificationconfig.json ------------------------------------------ Total matches: 1 Is it the way I am formatting the check? It does not seem to be taking the whole 'start' line into consideration. -Marie > > On 18 Jun 2015, at 04:38, Marie Mcallister <[email protected]> > wrote: > > > > Hello, > > > > I have a process that's kicked off from a custom script. The process > does not end with '.pid' so I am trying to use 'matching'. However it seems > to be breaking on the whitespace (just stops after 'bin/bash'), no matter > how I format the command. The commands themselves do work fine, outside of > monit. > > > > Here is what I am trying to use: > > > > check process example_process matching "example_process" > > start program = "/bin/bash -c 'nohup /mnt1/path/to/custom/bin/run.sh &'" > > stop program = "/usr/bin/killall example_process" > > if cpu > 80% for 2 cycles then alert > > if cpu > 95% for 5 cycles then restart > > if totalmem > 500.0 MB for 5 cycles then restart > > if children > 3 then restart > > > > Errors logged: > > > > [UTC Jun 18 02:01:46] info : 'system_ip-10-0-11-189' Monit started > > [UTC Jun 18 02:01:46] error : 'example_process' process is not running > > [UTC Jun 18 02:01:46] info : 'example_process' trying to restart > > [UTC Jun 18 02:01:46] info : 'example_process' start: /bin/bash > > [UTC Jun 18 02:02:16] error : 'example_process' failed to start > > rinse, repeat... > > > > -- > > To unsubscribe: > > https://lists.nongnu.org/mailman/listinfo/monit-general > > > > > ------------------------------ > > _______________________________________________ > monit-general mailing list > [email protected] > https://lists.nongnu.org/mailman/listinfo/monit-general > > > End of monit-general Digest, Vol 149, Issue 13 > ********************************************** >
-- To unsubscribe: https://lists.nongnu.org/mailman/listinfo/monit-general
