cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post
Level 11

Json Simple and perl

Jump to solution

I am trying to create an application monitor using perl and json.  We have the script built out and created a new APM template with a Windows Script monitor component. The problem is, when we run this against a node we get the following error:

Testing on node '10.6.242.73' failed with 'Unknown' status ('Unknown' might be different if script exits with a different exit code).

Here is the script.  Any help is appreciated.

#!c:\perl\bin\perl

#

use JSON;

use Data::Dumper;

$ip = '10.88.14.81';

$port = 80;

$inst = "AMQ2";

$ARG = $WScript->{Arguments};

if($ARG) {

  $ip = $ARG->item(0);

  $port = $ARG->item(1);

  $inst = $ARG->item(2);

}

$url = " ";

#print "$url\n";

$content = `wget $url --output-document=- --output-file=-`;

unless($content) {

  print "Message: Could not reach the MC status page\n";

  print "Statistic: 0\n";

  if ($ARG) {$WScript->Quit(1)};

  exit;

}

#print $content;

$x = decode_json($content);

#foreach $k1 (keys %$x) {

# $v1 = $$x{$k1};

# print "$k1 => $v1\n";

#}

$own = $$x{ownedItemCount};

$npolls = $$x{numberOfPolls};

$epolls = $$x{numberOfEmptyPolls};

print "Message.ownedItemCount: $own Owned Items\n";

print "Statistic.ownedItemCount: $own\n";

print "Message.numberOfPolls: $npolls Polls\n";

print "Statistic.numberOfPolls: $npolls\n";

print "Message.numberOfEmptyPolls: $epolls Empty Polls\n";

print "Statistic.numberOfEmptyPolls: $epolls\n";

if ($ARG) {$WScript->Quit(0)};

exit;

Tags (3)
0 Kudos
1 Solution
Level 11

OK, never mind.  We got it figured out!

View solution in original post

0 Kudos
3 Replies
Level 11

OK, never mind.  We got it figured out!

View solution in original post

0 Kudos

And could you please also tell what was the problem with your script? It could help other users who will find this topic.

Sure,so it was 2 things that caused this to not work.  We needed to download the Json addins in Perl on the poller.  The 2nd thing was someone else was trying to figure this out and modified the perl script.  They modified an arguement from ARG to ARRG.  Once both of these were corrected, our script ran with no issues.