<!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.1400" name=GENERATOR></HEAD>
<BODY>
<DIV>
<DIV><SPAN class=081355613-12072004><FONT face=Arial color=#0000ff size=2>Happy 
to explain...</FONT></SPAN></DIV>
<DIV><SPAN class=081355613-12072004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=081355613-12072004><FONT face=Arial color=#0000ff size=2>What I 
mean is I would like to have log information stored in a MS SQL 2000 
server.  I've tried eventhandlers, but the script I wrote for some reason 
will not run wget.  Here's why I'm running wget...</FONT></SPAN></DIV>
<DIV><SPAN class=081355613-12072004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=081355613-12072004><FONT face=Arial color=#0000ff size=2>Since 
I didn't know a better way to get data from Nagios to MS SQL, I created a web 
page on my SQL server.  It's just like a form processing page on a website, 
except there's no form.  The data submitted to that page goes into a 
database that I created to keep nagios info.</FONT></SPAN></DIV>
<DIV><SPAN class=081355613-12072004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=081355613-12072004><FONT face=Arial color=#0000ff size=2>My 
event handler, sql_AddRecord, gets the Nagios Macros passed to it.  I'm 
using it as a global event handler for services and hosts.  It looks like 
this:</FONT></SPAN></DIV>
<DIV><SPAN class=081355613-12072004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=081355613-12072004><FONT face=Arial color=#0000ff 
size=2>-----</FONT></SPAN></DIV>
<DIV><SPAN class=081355613-12072004></SPAN><SPAN class=081355613-12072004><FONT 
face=Arial color=#0000ff size=2><FONT size=2>
<P>#!/bin/sh</P>
<P>#</P>
<P># Write Record to SQL server.</P>
<P>#</P>
<P>recordtype=$(/usr/lib/nagios/plugins/eventhandlers/encode.pl "$1") 
timet=$(/usr/lib/nagios/plugins/eventhandlers/encode.pl "$2") 
hostname=$(/usr/lib/nagios/plugins/eventhandlers/encode.pl "$3") 
hostalias=$(/usr/lib/nagios/plugins/eventhandlers/encode.pl "$4") 
hostaddress=$(/usr/lib/nagios/plugins/eventhandlers/encode.pl "$5") 
hoststate=$(/usr/lib/nagios/plugins/eventhandlers/encode.pl "$6") 
statetype=$(/usr/lib/nagios/plugins/eventhandlers/encode.pl "$7") 
attempt=$(/usr/lib/nagios/plugins/eventhandlers/encode.pl "$8") 
plugout=$(/usr/lib/nagios/plugins/eventhandlers/encode.pl "$9") 
executiontime=$(/usr/lib/nagios/plugins/eventhandlers/encode.pl "${10}") 
latency=$(/usr/lib/nagios/plugins/eventhandlers/encode.pl "${11}") 
lastcheck=$(/usr/lib/nagios/plugins/eventhandlers/encode.pl "${12}") 
laststatechange=$(/usr/lib/nagios/plugins/eventhandlers/encode.pl "${13}")</P>
<P># Remove file created last time</P>
<P>rm -rfv /usr/lib/nagios/plugins/eventhandlers/addrecord.asp</P>
<P># What type of record are we creating?</P>
<P>case "$1" in</P>
<P>HOST)</P>
<P>#echo timet $timet hostname $hostname hostalias $hostalias hostaddress 
$hostaddress hoststate $hoststate statetype $statetype attempt $attempt plugout 
$plugout executiontime $executiontime latency $latency lastcheck $lastcheck 
laststatechange $laststatechange | mail jdoyle@lewisgaleclinic.com</P>
<P>wget --background --no-clobber --append-output=/tmp/wget.log 
--post-data="timet=$timet&recordtype=$recordtype&hostname=$hostname&hostalias=$hostalias&hostaddress=$hostaddress&hoststate=$hoststate&statetype=$statetype&attempt=$attempt&plugout=$plugout&executiontime=$executiontime&latency=$latency&lastcheck=$lastcheck&laststatechange=$laststatechange" 
</FONT><A href="http://sql/nagios/addrecord.asp"><U><FONT color=#0000ff 
size=2>http://sql/nagios/addrecord.asp</U></FONT></A></P><FONT size=2>
<P>;;</P>
<P>SERVICE)</P>
<P>servicedesc=$(/usr/lib/nagios/plugins/eventhandlers/encode.pl "${14}") 
servicestate=$(/usr/lib/nagios/plugins/eventhandlers/encode.pl "${15}")</P>
<P>#echo timet $timet hostname $hostname hostalias $hostalias hostaddress 
$hostaddress hoststate $hoststate statetype $statetype attempt $attempt plugout 
$plugout executiontime $executiontime latency $latency lastcheck $lastcheck 
laststatechange $laststatechange servicedesc $servicedesc servicestate 
$servicestate | mail jdoyle@lewisgaleclinic.com</P>
<P>wget --background --no-clobber --append-output=/tmp/wget.log 
--post-data="timet=$timet&recordtype=$recordtype&hostname=$hostname&hostalias=$hostalias&hostaddress=$hostaddress&hoststate=$hoststate&statetype=$statetype&attempt=$attempt&plugout=$plugout&executiontime=$executiontime&latency=$latency&lastcheck=$lastcheck&laststatechange=$laststatechange&servicedesc=$servicedesc&servicestate=$servicestate" 
</FONT><A href="http://sql/nagios/addrecord.asp"><U><FONT color=#0000ff 
size=2>http://sql/nagios/addrecord.asp</U></FONT></A></P><FONT size=2>
<P>;;</P>
<P>esac</P>
<P>exit 0</P></FONT></FONT></SPAN></DIV>
<DIV><SPAN class=081355613-12072004><FONT face=Arial color=#0000ff 
size=2>-----</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=081355613-12072004><FONT face=Arial color=#0000ff 
size=2>encode.pl is a file that will take the string and return a url-encoded 
version of the string.  That way it will post properly to my 
page.</FONT></SPAN></DIV>
<DIV><SPAN class=081355613-12072004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=081355613-12072004><FONT face=Arial color=#0000ff size=2>Here 
are my command definitions for my global event handlers:</FONT></SPAN></DIV>
<DIV><SPAN class=081355613-12072004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=081355613-12072004><FONT face=Arial color=#0000ff 
size=2>-----</FONT></SPAN></DIV>
<DIV><SPAN class=081355613-12072004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=081355613-12072004><FONT face=Arial color=#0000ff size=2>define 
command{<BR>        
command_name    
log_host_change<BR>        
command_line    
/usr/lib/nagios/plugins/eventhandlers/sql_AddRecord "HOST" "$TIMET$" 
"$HOSTNAME$" "$HOSTALIAS$" "$HOSTADDRESS$" "$HOSTSTATE$" "$STATETYPE$" 
"$HOSTATTEMPT$" "$OUTPUT$" "$EXECUTIONTIME$" "$LATENCY$" "$LASTCHECK$" 
"$LASTSTATECHANGE$"<BR>        
}</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=081355613-12072004><FONT face=Arial color=#0000ff size=2>define 
command{<BR>        
command_name    
log_service_change<BR>        
command_line    
/usr/lib/nagios/plugins/eventhandlers/sql_AddRecord "SERVICE" "$TIMET$" 
"$HOSTNAME$" "$HOSTALIAS$" "$HOSTADDRESS$" "$HOSTSTATE$" "$STATETYPE$" 
"$SERVICEATTEMPT$" "$OUTPUT$" "$EXECUTIONTIME$" "$LATENCY$" "$LASTCHECK$" 
"$LASTSTATECHANGE$" "$SERVICEDESC$" "$SERVICESTATE$"<BR></FONT></SPAN></DIV>
<DIV><SPAN class=081355613-12072004><FONT face=Arial color=#0000ff 
size=2>-----</FONT></SPAN></DIV>
<DIV><SPAN class=081355613-12072004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=081355613-12072004><FONT face=Arial color=#0000ff size=2>In the 
main script, you can see where I have commented a line that I used for 
testing.  It tested fine, it echoed all of the url-encoded macros and piped 
them to my email.</FONT></SPAN></DIV>
<DIV><SPAN class=081355613-12072004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=081355613-12072004><FONT face=Arial color=#0000ff size=2>If, 
after the wget line, I add "| mail jdoyle@lewisgaleclinic.com" I get a blank 
email when the event handler runs.  wget just doesn't seem to 
work.</FONT></SPAN></DIV>
<DIV><SPAN class=081355613-12072004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=081355613-12072004><FONT face=Arial color=#0000ff size=2>If I 
run the main script from the command line with some made up data to fill the 
variables, it works fine, and adds the data to the sql 
server.</FONT></SPAN></DIV>
<DIV><SPAN class=081355613-12072004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=081355613-12072004><FONT face=Arial color=#0000ff size=2>I'm so 
close, but can't figure out why wget does nothing when run from the 
eventhandler.</FONT></SPAN></DIV></DIV>
<DIV> </DIV>
<DIV align=left>
<TABLE 
style="BORDER-RIGHT: lightsteelblue 2px solid; BORDER-TOP: lightsteelblue 2px solid; BORDER-LEFT: lightsteelblue 2px solid; WIDTH: 337px; BORDER-BOTTOM: lightsteelblue 2px solid; HEIGHT: 73px" 
cellSpacing=0 cellPadding=0 width=337 align=left>
  <TBODY>
  <TR>
    <TD align=middle bgColor=lightsteelblue><A title="hi mom!"><FONT 
      face=arial><B>Jack Doyle, LGC Information Systems</B></FONT></A> </TD></TR>
  <TR>
    <TD align=middle bgColor=#e0e0e0>Systems Operations Specialist </TD></TR>
  <TR>
    <TD align=middle bgColor=#e0e0e0><FONT color=blue>540.776.2025</FONT> 
  </TD></TR></TBODY></TABLE></DIV>
<DIV align=left><FONT face=Arial size=2></FONT> </DIV>
<DIV align=left><FONT face=Arial size=2></FONT> </DIV>
<DIV align=left><FONT face=Arial size=2></FONT> </DIV>
<DIV align=left><FONT face=Arial size=2></FONT> </DIV>
<DIV align=left><FONT face=Arial size=2></FONT> </DIV>
<DIV align=left><FONT face=Arial size=2></FONT> </DIV>
<DIV align=left> </DIV>
<DIV> </DIV></BODY></HTML>