JSON error for specific host/host-tempate history

Post here if you found bugs.
User avatar
Tontonitch
NConf addict
NConf addict
Posts: 254
Joined: Fri May 07, 2010 10:14
Location: Thionville, France
Contact:

JSON error for specific host/host-tempate history

Post by Tontonitch » Tue Dec 20, 2011 10:02

Hi,

I've discovered a problem with the history.
Hereunder how to reproduce it:
  • Hosts->Show
  • Click on a host to see its details
  • Expand the history box on the right
  • Click on 'show all changes'
JSON_issue.png
JSON_issue.png (27.46 KiB) Viewed 7756 times
Then, you should see the JSON error popup:
JSON_issue2.png
JSON_issue2.png (13.49 KiB) Viewed 7756 times
This problem only occurs for objects of class host and host-template.

BR,
Yannick

User avatar
fgander
NConf developer
NConf developer
Posts: 308
Joined: Mon Mar 16, 2009 14:23
Location: Bern, Switzerland
Contact:

Re: JSON error for specific host/host-tempate history

Post by fgander » Thu Dec 22, 2011 00:53

For such problem, the browser is most important.. Because its working on FF8. So which one did you use ?
I guess you have something special as a hostname, or service name or something similar.
Do you have the problem all the time, no matter of which host you try ?

Normal History - is there the problem too ?
F.G. - NConf developer
http://www.nconf.org
Image
Follow NConf on Twitter!

User avatar
Tontonitch
NConf addict
NConf addict
Posts: 254
Joined: Fri May 07, 2010 10:14
Location: Thionville, France
Contact:

Re: JSON error for specific host/host-tempate history

Post by Tontonitch » Thu Dec 22, 2011 15:57

Hi Fabian,

Screenshots added to previous post.
Tested on Firefox 8.0, 9.0.1, Chrome 16: same JSON format error message.
Tested with a test host "Test" without any services: still the issue.
The error is reported for every host / host-template.

Normal History is working coorectly. I also tried to show all history entries: working correctly.

BR,
Yannick

User avatar
Tontonitch
NConf addict
NConf addict
Posts: 254
Joined: Fri May 07, 2010 10:14
Location: Thionville, France
Contact:

Re: JSON error for specific host/host-tempate history

Post by Tontonitch » Thu Jan 05, 2012 14:39

Hi guys,

Spent my lunchtime on that and finally fixed that issue.

Taking the JSON info from one host: nconf/call_file.php?ajax_file=json/history.php&debug=no&id=<id_item>

Code: Select all

{"sEcho": 0, "iTotalRecords": 38, "iTotalDisplayRecords": 38, "aaData": [ ["2011-06-07 16:25:24","Bulk import","added","host_name","TEST","21150"],["2011-06-07 16:25:24","Bulk import","assigned","host-preset","windows-preset","21151"],["2011-06-07 16:25:24","Bulk import","assigned","os","Windows","21152"],["2011-06-07 16:25:24","Bulk import","assigned","use","windows-host","21153"],["2011-06-07 16:25:24","Bulk import","assigned","check_period","24x7","21154"],["2011-06-07 16:25:24","Bulk import","added","address","xxx.xxx.xxx.xxx","21155"],["2011-06-07 16:25:24","Bulk import","added","alias","TEST","21156"],["2011-06-07 16:25:24","Bulk import","assigned","notification_period","24x7","21157"],["2011-06-07 16:25:24","Bulk import","added","host_is_collector","no","21158"],["2011-06-07 16:25:24","Bulk import","assigned","parents","TITI","21159"],["2011-06-07 16:25:24","Bulk import","created","host","TEST","21160"],["2011-06-07 16:26:10","Bulk import","assigned","members","windows-prod-servers","22160"],["2011-06-07 16:26:44","Bulk import","added","service","Cpu usage","22172"],["2011-06-07 16:26:44","Bulk import","added","service","Eventlog - application","22180"],["2011-06-07 16:26:44","Bulk import","added","service","Eventlog - security","22188"],["2011-06-07 16:26:44","Bulk import","added","service","Eventlog - system","22196"],["2011-06-07 16:26:44","Bulk import","added","service","Fixed disk usage","22204"],["2011-06-07 16:26:44","Bulk import","added","service","Memory usage","22212"],["2011-06-07 16:26:44","Bulk import","added","service","Service - auto-started services","22220"],["2011-06-07 16:26:44","Bulk import","added","service","Uptime","22228"],["2011-06-07 16:27:45","admin","assigned","monitored by","Default Icinga","33453"],["2011-06-07 16:27:45","admin","unassigned","monitored by","","33454"],["2011-06-08 18:24:33","admin","assigned","monitored by","","33927"],["2011-06-08 18:24:33","admin","unassigned","monitored by","Default Icinga","33928"],["2011-07-14 09:41:44","Monitoring administrator","assigned","check period","","36074"],["2011-07-14 09:41:44","Monitoring administrator","unassigned","check period","24x7","36075"],["2011-07-14 09:43:58","Monitoring administrator","assigned","notification period","","36262"],["2011-07-14 09:43:58","Monitoring administrator","unassigned","notification period","24x7","36263"],["2011-08-18 11:42:22","Monitoring administrator","modified","action URL","/pnp4nagios/graph?host=$HOSTNAME$&srv=_HOST_\' class=\'tips\' rel=\'/pnp4nagios/popup?host=$HOSTNAME$&srv=_HOST_","36725"],["2011-08-22 13:49:36","Monitoring administrator","assigned","monitored by","Default Icinga","37443"],["2011-08-22 13:49:36","Monitoring administrator","unassigned","monitored by","","37444"],["2011-08-23 13:51:13","Monitoring administrator","removed","service","Eventlog - application","37454"],["2011-08-23 13:51:13","Monitoring administrator","removed","service","Eventlog - security","37455"],["2011-08-23 13:51:13","Monitoring administrator","removed","service","Eventlog - system","37456"],["2011-10-12 11:15:51","admin","assigned","parent hosts","TUTU","40021"],["2011-10-12 11:15:51","admin","unassigned","parent hosts","TATA","40022"],["2011-10-17 10:39:59","Monitoring administrator","added","service","Interface status","40127"],["2011-10-17 11:20:24","Monitoring administrator","removed","service","Interface status","40151"]] }
Parsing that via http://jsonlint.com/ reported a problem with the action_url value

Code: Select all

...n URL",            "/pnp4nagios/graph?host=$HOSTNAME$&srv=_HOST_\' class=\'tips\'
----------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['
The problem was with the backslash. And this is quite common to have such a character in the action_URL string.

Hereunder a fix for include/ajax/json/history.php, which simply double the backslashes:
nconf-1.3.0-0_bugfix_JSON_format.patch.zip
(349 Bytes) Downloaded 364 times
Cheers,
Yannick

User avatar
Tontonitch
NConf addict
NConf addict
Posts: 254
Joined: Fri May 07, 2010 10:14
Location: Thionville, France
Contact:

Re: JSON error for specific host/host-tempate history

Post by Tontonitch » Thu Jan 05, 2012 15:45

Discovered that some backslashes don't have to be doubled. So the patch above breaks some other strings.
ex:
"<a href=\"detail.php?id=7054\">Cisco_environment</a>",
Corrected the patch (more accurate to \' pattern):
nconf-1.3.0-0_bugfix_JSON_format.patch.zip
(350 Bytes) Downloaded 340 times
BR,
Yannick

User avatar
fgander
NConf developer
NConf developer
Posts: 308
Joined: Mon Mar 16, 2009 14:23
Location: Bern, Switzerland
Contact:

Re: JSON error for specific host/host-tempate history

Post by fgander » Mon Jan 09, 2012 21:55

Yannick, thanks for that, sorry I am currently very busy with other projects, but i will check that in a week or so.
cheers fabian
F.G. - NConf developer
http://www.nconf.org
Image
Follow NConf on Twitter!

User avatar
fgander
NConf developer
NConf developer
Posts: 308
Joined: Mon Mar 16, 2009 14:23
Location: Bern, Switzerland
Contact:

Re: JSON error for specific host/host-tempate history

Post by fgander » Fri Mar 23, 2012 00:27

Okey, I have updated the history JSON encoding, please test the new implementation and give feedback, thanks!

https://github.com/nconf/development/co ... fc22a7a69f
F.G. - NConf developer
http://www.nconf.org
Image
Follow NConf on Twitter!

User avatar
Tontonitch
NConf addict
NConf addict
Posts: 254
Joined: Fri May 07, 2010 10:14
Location: Thionville, France
Contact:

Re: JSON error for specific host/host-tempate history

Post by Tontonitch » Fri Mar 23, 2012 15:58

Hi Fabian,

I've tested your new implementation.
Everything seems to work correctly with the new history.php file.
The info in the history seem to be not altered also, that seems ok.
No more JSON format problem.

Cheers,
Yannick

User avatar
fgander
NConf developer
NConf developer
Posts: 308
Joined: Mon Mar 16, 2009 14:23
Location: Bern, Switzerland
Contact:

Re: JSON error for specific host/host-tempate history

Post by fgander » Sat Mar 24, 2012 00:13

Cool, lets push it into master branch :ugeek:
Thanks Yannick!
F.G. - NConf developer
http://www.nconf.org
Image
Follow NConf on Twitter!

Locked