Special characters in services.cfg file - Solved
Chris Dos
chris at chrisdos.com
Thu Apr 24 00:54:36 CEST 2008
Chris Dos wrote:
> Patrick Morris wrote:
>> On Wed, 23 Apr 2008, Chris Dos wrote:
>>
>>> I'm having problem getting a command to run in services.cfg file when it works fine from the command line.
>>>
>>> >From the command line:
>>> /usr/lib/nagios/plugins/check_http -H 10.20.40.41 -w 2 -c 5 -t 10 -u
>>> http://cleopatra/userservice/signup/getstates.flx -T 'text/xml' -P '<request foruser="1" forgroup="1"
>>> fordomain="1" basedomain="1" cultureinfo="en-US" coreproductid="1" products="" systemtypeid="1"
>>> timezoneinfo="1|Mountain Standard Time (US & Canada & Mexico)|MST|Mountain Daylight
>>> Time|-7|0|1|0|3|0|1|2|0|11|0|0|2|0"> <getStates countryid="1" /> </request>' -s 'Colorado'
>>>
>>> results in:
>>> HTTP OK HTTP/1.1 200 OK - 0.004 second response time
>>>
>>> Putting in services.cfg:
>>> define service{
>>> use generic-service ; Name of service template to use
>>> host_name Cleopatra
>>> service_description HTTP_Post_States
>>> is_volatile 0
>>> check_period 24x7
>>> max_check_attempts 3
>>> normal_check_interval 1
>>> retry_check_interval 1
>>> contact_groups Admins_E-mails,Admins_Pagers
>>> notification_interval 30
>>> notification_period 24x7
>>> notification_options w,u,c,r
>>> check_command check_http!-w 2 -c 5 -t 10 -u
>>> http://cleopatra/userservice/signup/getstates.flx -T 'text/xml' -P '<request foruser="1" forgroup="1"
>>> fordomain="1" basedomain="1" cultureinfo="en-US" coreproductid="1" products="" systemtypeid="1"
>>> timezoneinfo="1|Mountain Standard Time (US & Canada & Mexico)|MST|Mountain Daylight
>>> Time|-7|0|1|0|3|0|1|2|0|11|0|0|2|0"> <getStates countryid="1" /> </request>'
>>> }
>> Wow. That may be the ugliest check command I've ever seen. :)
>>
>> What's your definition for the check_http check command look like?
>>
>> I'd normally suggest you set up a specialized check command for this
>> rather than to try to pass all those parameters in the service
>> definition, but that's up to you.
>
> Yea, it's the most awful check I've been ask to set up.
>
> I've been taking out characters to try and find the culprit. It seems that it does not like a semicolon. Is
> there any way to escape this character?
I've figured out a solution to my problem. XML needs a ampersand and since it's a special character it needs
to encode it as &. Since Nagios interprets everything after the semicolon as a comment, and this is a
http post, I was able to URL encode it. So this "&" translates into "%26amp%3B". Though it would be nice
if Nagios includes some way of escape a semicolon for other problems.
Chris
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
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