<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=US-ASCII">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 10">
<meta name=Originator content="Microsoft Word 10">
<link rel=File-List href="cid:filelist.xml@01C326C3.14E1B3C0">
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
name="PersonName"/>
<!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:DoNotRelyOnCSS/>
</o:OfficeDocumentSettings>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:SpellingState>Clean</w:SpellingState>
<w:DocumentKind>DocumentEmail</w:DocumentKind>
<w:EnvelopeVis/>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]--><!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;
mso-font-charset:0;
mso-generic-font-family:swiss;
mso-font-pitch:variable;
mso-font-signature:553679495 -2147483648 8 0 66047 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;
text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;
text-underline:single;}
span.emailstyle17
{mso-style-name:emailstyle17;
font-family:Arial;
mso-ascii-font-family:Arial;
mso-hansi-font-family:Arial;
mso-bidi-font-family:Arial;
color:windowtext;}
span.emailstyle18
{mso-style-name:emailstyle18;
font-family:Arial;
mso-ascii-font-family:Arial;
mso-hansi-font-family:Arial;
mso-bidi-font-family:Arial;
color:navy;}
span.EmailStyle19
{mso-style-type:personal-reply;
mso-style-noshow:yes;
mso-ansi-font-size:10.0pt;
mso-bidi-font-size:10.0pt;
font-family:Arial;
mso-ascii-font-family:Arial;
mso-hansi-font-family:Arial;
mso-bidi-font-family:Arial;
color:navy;}
span.SpellE
{mso-style-name:"";
mso-spl-e:yes;}
@page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:35.4pt;
mso-footer-margin:35.4pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";}
</style>
<![endif]-->
</head>
<body lang=EN-US link=blue vlink=purple style='tab-interval:36.0pt'>
<div class=Section1>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Try adding this to the top of the script.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>#! /<span class=SpellE>usr/bin/perl</span><o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>use <span class=SpellE>Getopt::Long</span>;<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>use <span class=SpellE>vars</span> <span
class=SpellE>qw</span>($<span class=SpellE>opt_V</span> $<span class=SpellE>opt_h</span>
$<span class=SpellE>opt_H</span> $<span class=SpellE>opt_w</span> $<span
class=SpellE>opt_c</span> $PROGNAME);<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>use lib "/<span class=SpellE>usr/local/nagios/libexec</span>"<span
style='mso-spacerun:yes'> </span>;<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>use <span class=SpellE>utils</span> <span
class=SpellE>qw</span>(%ERRORS &<span class=SpellE>print_revision</span>
&support &usage);<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>$PROGNAME = "<span class=SpellE>check_queue</span>";<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>sub <span class=SpellE>print_help</span>
();<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>sub <span class=SpellE>print_usage</span>
();<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>$ENV{'PATH'}='';<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>$ENV{'BASH_ENV'}='';<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>$ENV{'ENV'}='';<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>and use something like this for your exit
code<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>if ($ok){<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><span style='mso-spacerun:yes'>
</span>print "Ok. $line\n";<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><span style='mso-spacerun:yes'>
</span>exit $ERRORS{'OK'};<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>}<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>if ($<span class=SpellE>not_ok</span>) {<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><span style='mso-spacerun:yes'>
</span>print "WARNING.<span style='mso-spacerun:yes'> </span>Cannot
read the bloody line\n";<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><span style='mso-spacerun:yes'>
</span>exit $ERRORS{"WARNING"};<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>}<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>I'm no <span class=SpellE>perl</span>
expert but I hacked around until mine worked and this is what I did.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Later,<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Dean<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma'>-----Original Message-----<br>
<b><span style='font-weight:bold'>From:</span></b> Jan van den Berg
[mailto:jan@e-commercepark.com] <br>
<b><span style='font-weight:bold'>Sent:</span></b> May 30, 2003 2:06 PM<br>
<b><span style='font-weight:bold'>To:</span></b> '</span></font><st1:PersonName><font
size=2 face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>Nagios-Users</span></font></st1:PersonName><font
size=2 face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'> (E-mail)'<br>
<b><span style='font-weight:bold'>Subject:</span></b> [Nagios-users] Perl
subroutine plug-in<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'> <o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>Hi there,</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'> </span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>I don't if this is the right
place here, but I have a question about a plug-in I'm developing.</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'> </span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>See the following Perl sub-routine</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'> </span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>sub get_alert<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
{<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
local @ARGV = '/var/log/alert';<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
my @last8;<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'> <o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
while (<>) {<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
push @last8, $_;<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
shift @last8 while @last8 > 8;<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
}<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
my
$line = $last8[-6];<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
my $line =~
y/[,'"()<>]:;0123456789*//d;
<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
print $line; <o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
#print "test";<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
}<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'> <o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>So what this does is, get the 8
before last line from a log file, strips this line from meta-characters and
print out a clean line of text. When I run this command-line: no problem.
However Nagios says there is no output! But when I uncomment the print
"test"; it prints this out nicely in Nagios..... so the
subroutine is okay, and the print statement is okay.</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'> (I also tried using quotes
around "$line" but that didn't work).</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'> </span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>So what am I doing wrong here?</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'> </span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>Please help.</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'> </span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>Jan van den Berg</span></font><o:p></o:p></p>
</div>
</body>
</html>