Skip to content

Instantly share code, notes, and snippets.

@amit-y
Last active June 5, 2018 17:57
Show Gist options
  • Save amit-y/f90a400e9d44eb514e7e04c284911e61 to your computer and use it in GitHub Desktop.
Save amit-y/f90a400e9d44eb514e7e04c284911e61 to your computer and use it in GitHub Desktop.
#!/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