Log to Database Event Handler

Marc Powell marc at ena.com
Wed Apr 7 22:49:37 CEST 2004


David Barnett <mailto:DavidB at etobin.com> wrote:
> Thanks for the help.  I had the line I posted as the actual command
> line, so no script got called.  When I put in (1,2,3,4,5,6) as the
> values for the fields, it inserts the numbers into the table.  But
> when I try putting in a string or one of the macros (with or without
> single quotes around it), it won't insert the data.  Any idea why? 
> Thanks for responding before.     

Well sure. You won't be able to use single quotes because you are
wrapping your entire INSERT statement in them. You'll need to use double
quotes or swap the two --

Your original

/usr/bin/mysql -D <db_name> --execute 'INSERT into <table_name>
(date,time,host,service,state,output) VALUES($DATE$,$TIME$,$HOSTNAME$,
$SERVICEDESC$,$SERVICESTATE$,$OUTPUT$)'

Becomes

/usr/bin/mysql -D <db_name> --execute 'INSERT into <table_name>
(date,time,host,service,state,output)
VALUES("$DATE$","$TIME$","$HOSTNAME$","$SERVICEDESC$","$SERVICESTATE$","
$OUTPUT$")'

Or

/usr/bin/mysql -D <db_name> --execute "INSERT into <table_name>
(date,time,host,service,state,output)
VALUES('$DATE$','$TIME$','$HOSTNAME$','$SERVICEDESC$','$SERVICESTATE$','
$OUTPUT$')"

SQL syntax may require you to use the latter, I'm not sure. In my
previous email I was conservative in my use of quoting (only for
$SERVICEDESC$ and $OUTPUT$). I'm more aggressive in these examples to be
safe.

--
Marc 


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list