JSON Parsing error

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
ksric
Posts: 11
Joined: Wed Feb 27, 2013 5:41 am

JSON Parsing error

Post by ksric »

Hi,

We have developed a perl script to monitor the Google Applications stats but my plugin sometimes give an 'malformed JSON string,' when running the script.

[root@clrfmd1 libexec]# ./check_googlestats.pl --service='Google Calendar'
malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "(end of string)") at ./check_googlestats.pl line 23

The plugin doesn't always throw this error and works pretty fine most of the time.
The URL that we are accessing is below

my $content = `curl http://www.google.com/appsstatus/json/en 2>/dev/null`;
$content =~ s/dashboard.jsonp\(//g;
$content =~ s/\)\;$//g;

The script is trying to process the response from JSON by decoding the URL.

Does anybody have any idea on this? There appears to somehow the parsing is wrong and I am unable to find the problem. Could somebody please let me know what changes are required to get this going.

Regards,
Sricharan
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: JSON Parsing error

Post by tmcdonald »

This is less of a Nagios problem and more of a Perl problem in general. You might have better luck asking on the perlmonks.org forum.
Former Nagios employee
Locked