Last active
June 5, 2018 17:57
-
-
Save amit-y/f90a400e9d44eb514e7e04c284911e61 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use diagnostics; | |
use Scalar::Util qw(looks_like_number); | |
print "{\"name\":\"com.newrelic.mqswig\",\"protocol_version\":\"1\",\"integration_version\":\"1.0.0\",\"metrics\":["; | |
while (<>) { | |
my @items = split / /, $_; | |
print "{\"event_type\":\"IBMMQSample\""; | |
foreach my $item(@items) { | |
my @key_value = split /[\(\)]/, $item; | |
if (@key_value == 2) { | |
my ($key, $value) = @key_value; | |
print ",\"mq." . lc $key . "\":"; | |
if (looks_like_number($value)) { | |
print "$value"; | |
} else { | |
print "\"$value\""; | |
} | |
} | |
} | |
print "},"; | |
} | |
print "{}],\"inventory\":{},\"events\":[]}\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment