newlines in JSON

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.
User avatar
jssingh
Posts: 110
Joined: Mon Apr 29, 2013 4:55 pm

Re: newlines in JSON

Post by jssingh »

Sorry, I was out on Friday and forgot to bump. =(
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: newlines in JSON

Post by abrist »

That's fine. So was Eric :P
I will attempt to get more information through email instead.
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.
droland
Posts: 2
Joined: Fri Jul 18, 2014 6:07 pm

Re: newlines in JSON

Post by droland »

Hi, I'm jjsingh's coworker and will be tracking this issue while she is out of the office.

I would appreciate it if you can add me to any email traffic.

David
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: newlines in JSON

Post by abrist »

You may need to subscribe to this thread to receive emails. Eric[0] just committed and pushed code late last week. All standard JSON escaping should now be implemented in the json cgis.
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: newlines in JSON

Post by jssingh »

Hi,

first a note on personnel. I will be intermittently out of the office quite a bit until labor day, so (as mentioned earlier) David will be following up on things while I'm gone, but I will be popping in here now and then as well.

Thanks for the update and I installed the latest commit ... but now the JSON breaks for the services with newlines:
from the browser I get an Internal Service Error.

from a script on the command line I get this error:

Code: Select all

-bash-4.1$ ./qstat_test.pl 
, or } expected while parsing object/hash, at character offset 574 (before "\n") at ./qstat_test.pl line 13
-bash-4.1$
I looked at the output from the original plugin and the character at 574 seems to be where a newline should be. Let me know if you need any more information before I revert back.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: newlines in JSON

Post by abrist »

Could you post (obfuscate where necessary) the status string that is failing? (particularly he few chars before and after the offset?)
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: newlines in JSON

Post by jssingh »

from the plugin output:

Code: Select all

 Server reports 3 jobs total (T:0 Q:0 H:0 W:0 R:3 E:0 B:0)\\n\\n  Host       CPUs Tasks Jobs Info\\n  ---------- ---- ----- ---- ------------------\\n   243 hosts 1944     0   -- har\\n  r710i1n15     0     0    0 har down\\n   370 hosts 2960  2960   -- har in-use\\n    25 hosts   40     0   -- har offline\\n  r719i0n6      8     0    0 har {offline down}\\n\\n                                          Req'd     Elap\\nJobID      Queue  Jobname        CPUs Nds wallt Ss wallt Eff Group Model\\n---------- ------ -------------- ---- --- ----- -- ----- --- ----- -------\\n13170.p233 long   RS25VoF         800 100 16:00 R  00:12 28% e1120 100:har\\n   Job run at Mon Jul 21 at 09:59 on (r704i0n10:ncpus=8)+(r704i0n11:ncpus=...\\n13171.p233 long   MLHoleVoF       800 100 16:00 R  00:08 11% e1120 100:har\\n   Job run at Mon Jul 21 at 10:03 on (r707i1n2:ncpus=8)+(r707i1n3:ncpus=8)...\\n13167.p233 normal tnksmthlwr4o6H 1360 170 08:00 R  02:45 86% e1201 170:har\\n   Job run at Mon Jul 21 at 07:24 on (r701i0n1:ncpus=8)+(r701i0n3:ncpus=8)...
character 574 is the newline here:

Code: Select all

-------\\n13170.p233
hope this helps.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: newlines in JSON

Post by tmcdonald »

What is your perl version?

Code: Select all

perl -V | head -1
I found a somewhat recent bug with older versions of perl parsing JSON resulting in that same error:

https://github.com/makamaka/JSON-PP/issues/8

It might still be a lingering issue worth looking into.

In addition, can you pipe the plugin output to a file and attach that file? I want to look at it from a hex level.
Former Nagios employee
droland
Posts: 2
Joined: Fri Jul 18, 2014 6:07 pm

Re: newlines in JSON

Post by droland »

Here is the perl version:
droland@lnxsrv78:~> perl -V | head -1
Summary of my perl5 (revision 5 version 10 subversion 1) configuration:

Janice is expected back later this week. She will have to prepare and send the file.

David
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: newlines in JSON

Post by sreinhardt »

Sounds great, either pm it to tmcdonald or paste it here and he will take a look!
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Locked