[Nagiosplug-help] Questions using negate?

Voon, Ton Ton.Voon at egg.com
Tue Mar 18 05:53:16 CET 2003


Managed to have a play at cfpopen and here are the results:

A) RIGHT
$ ./negate /usr/bin/grep Network /etc/services
# Network services, Internet style
nntp            119/tcp         usenet          # Network News Transfer
ntp             123/tcp                         # Network Time Protocol
ntp             123/udp                         # Network Time Protocol

B) WRONG (the " are lost)
$ ./negate /usr/bin/grep "Network Time" /etc/services
grep: can't open Time
/etc/services:# Network services, Internet style
/etc/services:nntp            119/tcp         usenet            # Network
News Transfer
/etc/services:ntp               123/tcp                         # Network
Time Protocol
/etc/services:ntp               123/udp                         # Network
Time Protocol

C) WRONG (same as above)
$ ./negate /usr/bin/grep 'Network Time' /etc/services
grep: can't open Time
/etc/services:# Network services, Internet style
/etc/services:nntp            119/tcp         usenet            # Network
News Transfer
/etc/services:ntp               123/tcp                         # Network
Time Protocol
/etc/services:ntp               123/udp                         # Network
Time Protocol

D) RIGHT
$ ./negate '/usr/bin/grep "Network Time" /etc/services'
ntp             123/tcp                         # Network Time Protocol
ntp             123/udp                         # Network Time Protocol

E) RIGHT
$ ./negate "/usr/bin/grep 'Network Time' /etc/services"
ntp             123/tcp                         # Network Time Protocol
ntp             123/udp                         # Network Time Protocol

The only benefit is case D. Is it worth a switch over? Maybe the only change
is to provide better instructions on using case E and a better error message
if double quotes exist. 

Any comments?

Ton

> -----Original Message-----
> From:	Voon, Ton [SMTP:Ton.Voon at egg.com]
> Sent:	Tuesday, March 18, 2003 12:31 PM
> To:	'Subhendu Ghosh'; Nagiosplug-help at lists.sourceforge.net
> Subject:	RE: [Nagiosplug-help] Questions using negate?
> 
> I think there is a problem in spopen which affects negate and other
> plugins
> where external command calls with double quotes do not work correctly.
> 
> RIGHT (no spaces in command)
> $ negate /usr/bin/grep Network /etc/services
> # Network services, Internet style
> nntp            119/tcp         usenet          # Network News Transfer
> ntp             123/tcp                         # Network Time Protocol
> 
> WRONG (spaces lost when passed to spopen - I think it is running a grep
> against a file called Time, then /etc/services)
> $ negate /usr/bin/grep "Network Time" /etc/services
> /etc/services:# Network services, Internet style
> /etc/services:nntp            119/tcp         usenet            # Network
> News Transfer
> /etc/services:ntp               123/tcp                         # Network
> Time Protocol
> 
> WRONG (same as above)
> $ negate /usr/bin/grep 'Network Time' /etc/services
> /etc/services:# Network services, Internet style
> /etc/services:nntp            119/tcp         usenet            # Network
> News Transfer
> /etc/services:ntp               123/tcp                         # Network
> Time Protocol
> 
> WRONG (spopen returns NULL if " found in the command line)
> $ negate '/usr/bin/grep "Network Time" /etc/services'
> Could not open pipe: /usr/bin/grep "Network Time" /etc/services
> 
> RIGHT (spopen doesn't mind ' and the shell has kept the spaces in between)
> $ negate "/usr/bin/grep 'Network Time' /etc/services"
> ntp             123/tcp                         # Network Time Protocol
> 
> I'll look into using cfpopen (http://www.cfengine.org) to see if that will
> help, but it will take me ages!
> 
> Ton
> 
> > -----Original Message-----
> > From:	Subhendu Ghosh [SMTP:sghosh at sghosh.org]
> > Sent:	Tuesday, March 18, 2003 3:11 AM
> > To:	Nagiosplug-help at lists.sourceforge.net
> > Subject:	RE: [Nagiosplug-help] Questions using negate?
> > 
> > I thinks you need backslash to escape not forward slash...
> > 
> > -s \"word1 word2\"
> > 
> > -sg
> > 
> > On Tue, 18 Mar 2003, Rick . wrote:
> > 
> > > Thanks Subhendu,
> > > 
> > > The plugin works a lot better. My only problem now is that i need to
> use
> > the 
> > > -s command to check for a string of text using check_http. The string
> > needs 
> > > to be two words.
> > > When i put the two words in the quotes "word1 word2" with check_http
> > only, 
> > > the command works fine. But as soon as i negate the check_http
> command,
> > it 
> > > doesn't work with more than one word in the string.
> > > I have tried -s /"word1 word2/" etc but unfortunately it isn't
> working.
> > > 
> > > Is there any way to do this?
> > > 
> > > Thanks alot!
> > > 
> > > Rick :)
> > > 
> > > 
> > > 
> > > 
> > > 
> > > >From: Subhendu Ghosh <sghosh at sghosh.org>
> > > >To: Nagiosplug-help at lists.sourceforge.net
> > > >Subject: RE: [Nagiosplug-help] Questions using negate?
> > > >Date: Fri, 14 Mar 2003 19:10:05 -0500 (EST)
> > > >
> > > >
> > > >There was a recent patch applied on negate - you might want to grab
> the
> > > >latest version of negate from CVS...
> > > >
> > > >-sg
> > > >
> > > >On Thu, 6 Mar 2003, Rick . wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > I downloaded and tested this plugin, and i am having the same
> > problem.
> > > > >
> > > > > The plugin is always giving an OK, whether the negated plugin is
> OK
> > or
> > > > > CRITICAL.
> > > > >
> > > > > Does anybody know how to fix this?
> > > > >
> > > > > Thanks,
> > > > >
> > > > > Rick.
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > >From: Rose David <DRose at snyderdrug.com>
> > > > > >To: Nagiosplug-help at lists.sourceforge.net
> > > > > >Subject: RE: [Nagiosplug-help] Questions using negate?
> > > > > >Date: Wed, 5 Mar 2003 11:38:13 -0600
> > > > > >
> > > > > >Thank you for your response and input.  I have now used your
> script
> > and 
> > > >it
> > > > > >has gotten me farther along than I have been able to this point.
> > Here 
> > > >is
> > > > > >the catch.  When I run this on the command line, it works just as
> > > > > >advertised, switching the return codes from 2 to 0 or from 0 to
> 2.
> > > > > >However,
> > > > > >when I run it in nagios as a command, either a Critical or an OK
> > state 
> > > >on
> > > > > >the check_ping shows up as OK.  Using the same command, I get the
> 
> > > >following
> > > > > >two results:
> > > > > >
> > > > > >Status		Status Information
> > > > > >OK			CRITICAL - Plugin timed out after 10 seconds
> > > > > >OK			PING OK - Packet loss = 20%, RTA = 245.95 ms
> > > > > >
> > > > > >Any further input as to what I might do to get this to work?
> > > > > >
> > > > > >
> > > > > >
> > > > > > > We re-wrote negate as a simple perl script.  I have tried your
> > > > > > > check_ping input with my version of negate and here is what I
> > get:
> > > > > > >
> > > > > > >
> > > > > > > root at lxxxx:[/home/nagios/etc]: /home/nagios/libexec/new-negate
> > > > > > > /home/nagios/libexec/check_ping -H auspap01 -w 1000.0,100% -c
> > > > > > > 1000.0,100% -p 5
> > > > > > > Command is: /home/nagios/libexec/check_ping -H host01 -w
> > > > > > > 1000.0,100% -c
> > > > > > > 1000.0,100% -p 5PING OK - Packet loss = 0%, RTA = 4.62 ms
> > > > > > > Return code is 0
> > > > > > > root at lapin:[/home/nagios/etc]: echo $?
> > > > > > > 2
> > > > > > >
> > > > > > > The first return code is the actual return from the check_ping
> 
> > > >plugin,
> > > > > > > the second $? output is the negated output.  Since check_ping 
> > > >produces
> > > > > > > multiple return codes depending on the result, it is
> > > > > > > difficult to use a
> > > > > > > generic negate plugin.  I have included our version of the
> > plugin
> > > > > > > "new-negate.  Hope this helps..
> > > > > > >
> > > > > > > Good luck
> > > > > > >
> > > > > > >
> > > > > > > John Cockerham
> > > > > > > Sr. Network Administrator
> > > > >
> > > > >
> > > > > _________________________________________________________________
> > > > > Hotmail now available on Australian mobile phones. Go to
> > > > > http://ninemsn.com.au/mobilecentral/hotmail_mobile.asp
> > > > >
> > > > >
> > > > >
> > > > > -------------------------------------------------------
> > > > > This SF.net email is sponsored by:Crypto Challenge is now open!
> > > > > Get cracking and register here for some mind boggling fun and
> > > > > the chance of winning an Apple iPod:
> > > > > http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en
> > > > > _______________________________________________
> > > > > Nagiosplug-help mailing list
> > > > > Nagiosplug-help at lists.sourceforge.net
> > > > > https://lists.sourceforge.net/lists/listinfo/nagiosplug-help
> > > > > ::: Please include plugins version (-v) and OS when reporting any
> > issue.
> > > > > ::: Messages without supporting info will risk being sent to
> > /dev/null
> > > > >
> > > >
> > > >--
> > > >
> > > >
> > > >
> > > >
> > > >-------------------------------------------------------
> > > >This SF.net email is sponsored by:Crypto Challenge is now open!
> > > >Get cracking and register here for some mind boggling fun and
> > > >the chance of winning an Apple iPod:
> > > >http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en
> > > >_______________________________________________
> > > >Nagiosplug-help mailing list
> > > >Nagiosplug-help at lists.sourceforge.net
> > > >https://lists.sourceforge.net/lists/listinfo/nagiosplug-help
> > > >::: Please include plugins version (-v) and OS when reporting any
> > issue.
> > > >::: Messages without supporting info will risk being sent to
> /dev/null
> > > 
> > > 
> > > _________________________________________________________________
> > > Hotmail now available on Australian mobile phones. Go to  
> > > http://ninemsn.com.au/mobilecentral/hotmail_mobile.asp
> > > 
> > 
> > -- 
> > 
> > 
> > 
> > 
> > 
> > -------------------------------------------------------
> > This SF.net email is sponsored by:Crypto Challenge is now open! 
> > Get cracking and register here for some mind boggling fun and 
> > the chance of winning an Apple iPod:
> > http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en
> > _______________________________________________
> > Nagiosplug-help mailing list
> > Nagiosplug-help at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/nagiosplug-help
> > ::: Please include plugins version (-v) and OS when reporting any issue.
> 
> > ::: Messages without supporting info will risk being sent to /dev/null
> 
> 
> This private and confidential e-mail has been sent to you by Egg.
> The Egg group of companies includes Egg Banking plc
> (registered no. 2999842), Egg Financial Products Ltd (registered
> no. 3319027) and Egg Investments Ltd (registered no. 3403963) which
> carries out investment business on behalf of Egg and is regulated
> by the Financial Services Authority.  
> Registered in England and Wales. Registered offices: 1 Waterhouse Square,
> 138-142 Holborn, London EC1N 2NA.
> If you are not the intended recipient of this e-mail and have
> received it in error, please notify the sender by replying with
> 'received in error' as the subject and then delete it from your
> mailbox.
> 
> 
> 
> -------------------------------------------------------
> This SF.net email is sponsored by: Does your code think in ink? 
> You could win a Tablet PC. Get a free Tablet PC hat just for playing. 
> What are you waiting for?
> http://ads.sourceforge.net/cgi-bin/redirect.pl?micr5043en
> _______________________________________________
> Nagiosplug-help mailing list
> Nagiosplug-help at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagiosplug-help
> ::: Please include plugins version (-v) and OS when reporting any issue. 
> ::: Messages without supporting info will risk being sent to /dev/null




More information about the Help mailing list