...
 
Commits (2)
......@@ -74,11 +74,13 @@ wrap_exit($code, $message);
sub check_status
{
my $label;
my $uom;
my $type;
my $i;
my @values;
foreach my $value (@{$mp->opts->value}) {
($label, $value) = split /=/, $value, 2;
($label, $uom) = split /;/, $label, 2;
my ($oid_value, $threshold) = split /;/, $value;
my ($oid_type, $oid) = split /:/, $oid_value;
......@@ -98,11 +100,12 @@ sub check_status
}
my %foo = (
'label' => $label,
'oid' => $oid,
'threshold_warning' => $threshold_warning,
'label' => $label,
'uom' => $uom,
'oid' => $oid,
'threshold_warning' => $threshold_warning,
'threshold_critical' => $threshold_critical,
'type' => $oid_type,
'type' => $oid_type,
);
push @values, \%foo;
......@@ -128,6 +131,8 @@ sub check_status
my $value_type = $value_cfg{type};
if ($value_type eq 'bool') {
check_status_bool(\%value_cfg, $value);
} elsif ($value_type =~ m/^float/) {
check_status_float(\%value_cfg, $value);
}
}
# foreach my $value_cfg (@values) {
......@@ -159,6 +164,37 @@ sub check_status_bool
$mp->add_message($check_status, $value_cfg{label} . ': ' . $value);
}
sub check_status_float
{
my $check_status;
my $f = shift;
my %value_cfg = %{$f};
my $value = shift;
my ($type_name, $type_modifier, $type_mod_value) = split /,/, $value_cfg{type};
if (defined $type_modifier && defined $type_mod_value) {
if ($type_modifier eq '/') {
$value /= $type_mod_value;
} elsif ($type_modifier eq '*') {
$value *= $type_mod_value;
}
}
$mp->add_perfdata(
label => $value_cfg{label},
value => $value,
warning => $value_cfg{threshold_warning},
critical => $value_cfg{threshold_critical},
uom => $value_cfg{uom},
);
$check_status = $mp->check_threshold(
check => $value,
warning => $value_cfg{threshold_warning},
critical => $value_cfg{threshold_critical},
);
$mp->add_message($check_status, $value_cfg{label} . ': ' . $value . ($value_cfg{uom} // ""));
}
sub wrap_exit
{
if($pkg_monitoring_available == 1) {
......