Page 1 of 1

possible bug in API - not printable character

Posted: Thu Apr 24, 2014 12:32 pm
by jssingh
Hi,

A couple of our systems got decommissioned and it led to check_ping to fail (obviously). So the output according to the GUI is:

Code: Select all

check_ping: Invalid hostname/address - ldan10
Usage:
check_ping -H <host_address> -w <wrta>,<wpl>% -c <crta>,<cpl>%
[-p packets] [-t timeout] [-4


However, the json breaks my Perl script (very ungracefully). It turns out that when the API creates the JSON, one of the characters turns into a nonprintable character (I'm guessing). Here is what I get if I just do a json query:

Code: Select all

"long_plugin_output": "Usage:check_ping -H <host_address> -w <wrta>,<wpl>? <crta>,<cpl>% [-p packets] [-t timeout] [-4",
oddly only the first % gets changed.

and this is the output if I use decode_json().

Code: Select all

-bash-4.1$ ./broken_json.pl 
malformed UTF-8 character in JSON string, at character offset 521 (before "\x{b0} <crta>,<cpl>%...") at ./broken_json.pl line 10
-bash-4.1$
Is there something that can be done about that? Because it is hard to work around it when the script just dies.

thanks!

Re: possible bug in API - not printable character

Posted: Thu Apr 24, 2014 12:53 pm
by abrist
I think this bug has already been reported and I myself have run into it with my json work. I will open up an internal bug report and try to expedite it. What version of core are you running?

Re: possible bug in API - not printable character

Posted: Thu Apr 24, 2014 12:56 pm
by jssingh
Thank you. nagios 4.0.4

Re: possible bug in API - not printable character

Posted: Thu Apr 24, 2014 3:04 pm
by abrist
I think it is due to the pipe "|". From the plugin source for check_ping:

Code: Select all

void
print_usage (void)
{
  printf ("%s\n", _("Usage:"));
        printf ("%s -H <host_address> -w <wrta>,<wpl>%% -c <crta>,<cpl>%%\n", progname);
  printf (" [-p packets] [-t timeout] [-4|-6]\n");
}
I will get someone on it . . .
EDIT: Actually, there may be two issues here. Anyways, we will get to the bottom of it.

Re: possible bug in API - not printable character

Posted: Thu Apr 24, 2014 8:51 pm
by jssingh
Thank you!

Re: possible bug in API - not printable character

Posted: Fri Apr 25, 2014 11:12 am
by lmiltchev
Thanks for bringing this to our attention!