possible bug in API - not printable character

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
User avatar
jssingh
Posts: 110
Joined: Mon Apr 29, 2013 4:55 pm

possible bug in API - not printable character

Post 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!
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: possible bug in API - not printable character

Post 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?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
User avatar
jssingh
Posts: 110
Joined: Mon Apr 29, 2013 4:55 pm

Re: possible bug in API - not printable character

Post by jssingh »

Thank you. nagios 4.0.4
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: possible bug in API - not printable character

Post 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.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
User avatar
jssingh
Posts: 110
Joined: Mon Apr 29, 2013 4:55 pm

Re: possible bug in API - not printable character

Post by jssingh »

Thank you!
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: possible bug in API - not printable character

Post by lmiltchev »

Thanks for bringing this to our attention!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked