package MonitisMonitorManager::Parsing::JSON;
use MonitisMonitorManager::M3PluginCommon;
use strict;
use JSON;
sub new {
my ($class, $name) = @_;
return undef;
}
# this function identifies the tok
sing
sub name {
return "json";
}
# matches all XML strings in the given output
sub parse {
my ($self, $metric_name, $metric_xml_path, $output, $results) = @_;
# handle JSON pattern matching
# eva
tch() block
eval {
my $json_presentation = from_json( $output, { utf8 => 1 } );
$self->match_strings_in_object($metric_name, $metric_xml_path, $json_presentation, "json", $results);
};
}
# mat
nnection;
use MonitisMonitorManager::M3Logger;
use Carp;
use Date::Manip;
use File::Basename;
use JSON;
use Data::Dumper;
#################
### CONSTANTS ###
#################
require Exporter;
our
formatted_results = format_results(\%results);
my $formatted_additional_results = format_results_json(\%additional_results);
return $self->update_data_for_monitor(
agent_name => $agent_name,
mo
s;
}
# formats the hash of results into a string
sub format_results_json(%) {
my (%results) = %{$_[0]};
return "[" . encode_json(\%results) . "]";
}
# simply replaces the %SOMETHING% with the rele