Hi All
I have used the below code to print the dumper of a json
#!/usr/bin/perl
use LWP::Simple;
use JSON qw( decode_json );
use Data::Dumper;
use strict;
use warnings;
my (%list);
my $trendsurl = "http://sensu:4567/events";
my $json = get( $trendsurl );
die "Could not get $trendsurl!" unless defined $json;
my $decoded_json = decode_json( $json );
print Dumper $decoded_json;
which gives me the following
$VAR1 = [
{
'client' => 'es1.',
'flapping' => bless( do{\(my $o = 0)}, 'JSON::XS::Boolean' ),
'check' => 'disk_usage',
'occurrences' => 2160,
'issued' => 1371466494,
'status' => 1,
'handlers' => [
'default'
],
'output' => 'com.dneg.es1.df.boot.df_complex.free OK
WARNING: com.dneg.es1.df.opt-elasticsearch.df_complex.free will run out of space in 10 days at current rate
com.dneg.es1.df.root.df_complex.free OK
'
},
{
'client' => 'graphite1.',
'flapping' => $VAR1->[0]{'flapping'},
'check' => 'disk_usage',
'occurrences' => 7028,
'issued' => 1371466494,
'status' => 1,
'handlers' => [
'default'
],
'output' => 'com.dneg.graphite1.df.boot.df_complex.free OK
com.dneg.graphite1.df.root.df_complex.free OK
WARNING: com.dneg.graphite1.df.user_data.df_complex.free will run out of space in 12 days at current rate
'
},
I am now stuck in how to use that data, i want to extract the client and the Warning
i.e
client' => 'graphite1.
WARNING: fee will run out of space in 12 days at current rate
any pointers would be great
Thanks
ADam