#!/bin/bash<div>LOGFILE="/tmp/logfile"</div><div>WORD="word_to_find"</div><div>GREP=/bin/grep</div><div>found=`$GREP -i $WORD $LOGFILE`</div><div>if [ -z $found ]  ## $found is zero bytes</div><div>then</div>
<div>  ok=1</div><div>  RETSTRING=0 ## To be used for the exit code</div><div>  LINE="No instances found"</div><div>else<br>  ok=0</div><div>  RETSTRING=1</div><div>  LINE=$found</div><div>fi</div><div><br></div>
<div>echo $LINE</div><div>exit $RETSTRING</div><div><br></div><div>## End of snippet</div><div><br></div><div><br></div><div><div class="gmail_quote">On Fri, Apr 17, 2009 at 7:35 AM, kaouther mechri <span dir="ltr"><<a href="mailto:kmechri@gmail.com">kmechri@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hello All,<br><br>I am seraching a way to parse some  application log files on remote hosts and grep for specific words, I need to add this as a nagios check. <br>
<br>Can anyone help me <br>kind regards<br><font color="#888888">kaouther <br>
</font><br>------------------------------------------------------------------------------<br>
Stay on top of everything new and different, both inside and<br>
around Java (TM) technology - register by April 22, and save<br>
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.<br>
300 plus technical and hands-on sessions. Register today.<br>
Use priority code J9JMT32. <a href="http://p.sf.net/sfu/p" target="_blank">http://p.sf.net/sfu/p</a><br>_______________________________________________<br>
Nagios-users mailing list<br>
<a href="mailto:Nagios-users@lists.sourceforge.net">Nagios-users@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/nagios-users" target="_blank">https://lists.sourceforge.net/lists/listinfo/nagios-users</a><br>
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.<br>
::: Messages without supporting info will risk being sent to /dev/null<br></blockquote></div><br><br clear="all"><br>-- <br>Gary Every<br>"Pay it Forward!"<br><br>
</div>