<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Message</TITLE>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2800.1544" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=286264114-25092007><FONT face=Arial color=#0000ff size=2>I'm no
expert in python or passive results, however you appear to be opening the file
for write access. Have you tried opening for append (w+
perhaps?)</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN lang=en-gb><B><FONT face=Arial size=2>--</FONT></B></SPAN><SPAN
lang=en-gb></SPAN></DIV>
<P dir=ltr><SPAN lang=en-gb><I><FONT face="Times New Roman">"Even if you're on
the right track, you'll get run over if you just sit
there."</FONT></I></SPAN><SPAN lang=en-gb><I><BR></I><B></B></SPAN><SPAN
lang=en-gb><B><BR><FONT face=Arial size=2>Paul
Weaver </FONT></B></SPAN><SPAN
lang=en-gb><B><BR></B></SPAN><SPAN lang=en-gb><FONT face=Arial size=2>Systems
Development Engineer</FONT></SPAN><SPAN lang=en-gb><BR></SPAN><SPAN
lang=en-gb><FONT face=Arial size=2>News Production
Facilities,</FONT></SPAN><SPAN lang=en-gb><B><FONT
face=Arial></FONT></B></SPAN><SPAN lang=en-gb><B></B></SPAN><SPAN lang=en-gb><B>
<FONT face=Arial size=2>BBC News</FONT></B></SPAN><SPAN
lang=en-gb><BR><B></B></SPAN><SPAN lang=en-gb><B><FONT face=Arial
size=2>Work: </FONT></B></SPAN><SPAN lang=en-gb></SPAN><SPAN
lang=en-gb> <FONT face=Arial size=2>020 822</FONT></SPAN><SPAN
lang=en-gb><B></B></SPAN><SPAN lang=en-gb><B><FONT face=Arial size=2>5
8109<BR><B></B></SPAN><SPAN lang=en-gb><B><FONT face=Arial
size=2>Mobile: </FONT></B></SPAN><SPAN lang=en-gb></SPAN><SPAN
lang=en-gb> <FONT face=Arial size=2>07738 481006</FONT></SPAN><SPAN
lang=en-gb><B></B></SPAN><SPAN lang=en-gb><B><FONT face=Arial size=2><BR>Room
1244, BBC Television Centre,</FONT></B></SPAN><SPAN
lang=en-gb><BR></SPAN><SPAN lang=en-gb><FONT face=Arial size=2>Wood Lane,
London, W12 7RJ</FONT></SPAN><SPAN lang=en-gb></SPAN></P>
<P dir=ltr><SPAN lang=en-gb><I></I></SPAN></P></FONT></B>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV></DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT
face=Tahoma size=2>-----Original Message-----<BR><B>From:</B>
nagios-users-bounces@lists.sourceforge.net
[mailto:nagios-users-bounces@lists.sourceforge.net] <B>On Behalf Of
</B>pankaj.dhali@wipro.com<BR><B>Sent:</B> 25 September 2007
15:39<BR><B>To:</B> nagios-users@lists.sourceforge.net<BR><B>Subject:</B>
[Nagios-users] FW: Nagios: Error while writing to pipe<BR><BR></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff
size=2></FONT> </DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT face=Arial
color=#800000 size=2><SPAN class=043052012-25092007>Hi<SPAN
class=902433314-25092007><FONT color=#0000ff>
All,</FONT></SPAN></SPAN></FONT></DIV>
<DIV><FONT color=#800000><SPAN class=043052012-25092007><FONT face=Arial><FONT
size=2> <SPAN
class=902433314-25092007><FONT color=#0000ff> I am new to Nagios, I am
trying to receive SNMP Trap from Windows client machine. I am using
Python script to see how Nagios can create an
event/alert</FONT></SPAN></FONT></FONT></SPAN></FONT></DIV>
<DIV><FONT color=#800000><SPAN class=043052012-25092007><FONT face=Arial><FONT
size=2><SPAN class=902433314-25092007><FONT color=#0000ff>by checking Passive
Service Check Result submitted by this
script.</FONT> </SPAN> <SPAN
class=902433314-25092007><FONT
color=#0000ff> </FONT></SPAN></FONT></FONT></SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#800000 size=2><SPAN
class=043052012-25092007><SPAN class=902433314-25092007><FONT
color=#0000ff>
</FONT> </SPAN>I have attached the Python script which is used write
"Passive Service check Result" to Nagios external command
file</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#800000 size=2><SPAN class=043052012-25092007>for
creating an alert/event. But when I run this script </SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=043052012-25092007></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=043052012-25092007>--------------------------------------------------</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=043052012-25092007><FONT size=2>
<P>[root@Symbol eventhandlers]# pwd</P>
<P>/usr/local/nagios/libexec/eventhandlers</P>
<P> <FONT color=#0000ff>[root@Symbol eventhandlers]# python
snmptraphandling.py 10.207.40.203 CRITICAL 12</FONT></P>
<P>2</P>
<P>[root@Symbol eventhandlers]#</P></FONT></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=043052012-25092007>---------------------------------------------</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=043052012-25092007></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=043052012-25092007></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#800000 size=2><SPAN class=043052012-25092007>I
get following error:</SPAN></FONT></DIV>
<DIV><SPAN class=043052012-25092007><SPAN class=043052012-25092007><FONT
face=Arial><FONT size=2><SPAN class=902433314-25092007><FONT
color=#0000ff></FONT></SPAN></FONT></FONT></SPAN></SPAN> </DIV>
<DIV><FONT size=+0><SPAN class=043052012-25092007><FONT face=Arial
size=2>[root@Symbol rw]# tail -f nagios.cmd</FONT></DIV>
<DIV>
<P><FONT face=Arial size=2>[1190731734]
PROCESS_SERVICE_CHECK_RESULT;10.207.40.203;snmp_trap_handling_critical;2;"
12"</FONT></P>
<P><FONT face=Arial color=#0000ff size=2><STRONG>tail: nagios.cmd: file
truncated</STRONG></FONT></P>
<P><FONT color=#0000ff><FONT face=Arial><FONT size=2><STRONG>tail: nagios.cmd:
cannot seek to offset 0: Illegal seek</STRONG> </FONT></FONT></FONT></P>
<P><FONT face=Arial size=2>[root@Symbol rw]#</FONT></P>
<P><SPAN class=043052012-25092007><FONT face=Arial
size=2>--------------------------------------------------</FONT></SPAN></P>
<P><SPAN class=043052012-25092007><FONT face=Arial size=2>nagios.cmd is a
pipe: </FONT></SPAN></P>
<P><SPAN class=043052012-25092007><SPAN class=043052012-25092007><FONT
face=Arial size=2>[root@Symbol rw]# ls -l</FONT></P>
<DIV>
<P><FONT face=Arial size=2>total 0</FONT></P>
<P><FONT face=Arial><FONT size=2><STRONG><FONT
color=#0000ff>prw-rw</FONT></STRONG>---- 1 nagios nagcmd 0 Sep 25 20:18 <FONT
color=#0000ff><STRONG>nagios.cmd</STRONG> </FONT></FONT></FONT></P>
<P><FONT face=Arial size=2>[root@Symbol rw]#</FONT></P>
<P><FONT face=Arial size=2>[root@Symbol rw]# pwd</FONT></P>
<P><FONT face=Arial size=2>/usr/local/nagios/var/rw</FONT></P>
<P><FONT face=Arial size=2></FONT> </P>
<P><SPAN class=043052012-25092007><FONT face=Arial><FONT size=2> <FONT
color=#800000>why I am getting <STRONG>Illegal seek</STRONG> error. I have
tried to use this script to a normal read write file and it works fine, but
while writing to a pipe it is </FONT></FONT></FONT></SPAN></P>
<P><SPAN class=043052012-25092007><FONT face=Arial color=#800000
size=2>showing error. If the problem is due to the script then
it could be here</FONT></SPAN></P>
<P><SPAN class=043052012-25092007><FONT face=Arial size=2>output =
open('/usr/local/nagios/var/rw/nagios.cmd',
'w')<BR> print
return_code<BR> results = "[" +
mytime + "] " + "PROCESS_SERVICE_CHECK_RESULT;"
\<BR> + host + ";" +
"snmp_trap_handling_" + service_suffix + ";"
\<BR> + return_code + ";" +
mondata_res + "\n"<BR>
output.write(results)</FONT></SPAN></P>
<P><SPAN class=043052012-25092007><FONT face=Arial color=#800000 size=2>It
could be file(pipe) permission problem, I have no idea.</FONT></SPAN></P>
<P>
<P><SPAN class=043052012-25092007><FONT
face="Courier New"><TT></TT></FONT></SPAN></P><SPAN
class=043052012-25092007><FONT face="Courier New"><TT>I have followed below
link to give permission to nagios.cmd</TT></FONT></SPAN>
<P></P>
<P><SPAN class=043052012-25092007><FONT face="Courier New"><TT><FONT
face=Arial size=2><A
href="http://nagios.sourceforge.net/docs/2_0/commandfile.html">http://nagios.sourceforge.net/docs/2_0/commandfile.html</A></FONT> </TT></FONT></P><PRE style="MARGIN: 0em"></PRE></SPAN>
<P><SPAN class=043052012-25092007><FONT face=Arial size=2>Thanks &
Regards,</FONT></SPAN></P>
<P><SPAN class=043052012-25092007><FONT face=Arial
size=2>Pankaj</FONT></SPAN></P>
<P><SPAN class=043052012-25092007><FONT face=Arial
size=2></FONT></SPAN> </P>
<P><SPAN class=043052012-25092007><FONT face=Arial
size=2></FONT></SPAN> </P></SPAN></DIV></SPAN>
<P><FONT face=Arial
size=2></FONT> </P></SPAN></FONT></DIV></BLOCKQUOTE><br/><font face="Times New Roman" size="3"><a href="http://www.bbc.co.uk">http://www.bbc.co.uk</a><br/>This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated.<br/>If you have received it in error, please delete it from your system.<br/>Do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately.<br/>Please note that the BBC monitors e-mails sent or received.<br/>Further communication will signify your consent to this.</font></BODY></HTML>