1
0
mirror of https://github.com/c-kr/check_json.git synced 2024-11-23 10:53:47 +01:00

Added a boolean test option. For json variables with true/false. In this case -wen -c true/false as well as 0/1 can be used.

This commit is contained in:
Joop Boonen 2015-04-23 13:47:42 +02:00
parent 8290ad203b
commit 539635607c

View File

@ -140,6 +140,7 @@ my %attributes = map { $attributes[$_] => { warning => $warning[$_] , critical =
my %check_value; my %check_value;
my $check_value; my $check_value;
my $result = -1; my $result = -1;
my $resultTmp;
foreach my $attribute (sort keys %attributes){ foreach my $attribute (sort keys %attributes){
my $check_value; my $check_value;
@ -156,11 +157,40 @@ foreach my $attribute (sort keys %attributes){
$check_value = $check_value/$attributes{$attribute}{'divisor'}; $check_value = $check_value/$attributes{$attribute}{'divisor'};
} }
my $resultTmp = $np->check_threshold( if ( $check_value eq "true" or $check_value eq "false" ) {
check => $check_value, if ( $check_value eq "true") {
warning => $attributes{$attribute}{'warning'}, $resultTmp = 0;
critical => $attributes{$attribute}{'critical'} if ($attributes{$attribute}{'critical'} eq 1 or $attributes{$attribute}{'critical'} eq "true") {
); $resultTmp = 2;
}
else
{
if ($attributes{$attribute}{'warning'} eq 1 or $attributes{$attribute}{'warning'} eq "true") {
$resultTmp = 1;
}
}
}
if ( $check_value eq "false") {
$resultTmp = 0;
if ($attributes{$attribute}{'critical'} eq 0 or $attributes{$attribute}{'critical'} eq "false") {
$resultTmp = 2;
}
else
{
if ($attributes{$attribute}{'warning'} eq 0 or $attributes{$attribute}{'warning'} eq "false") {
$resultTmp = 1;
}
}
}
}
else
{
$resultTmp = $np->check_threshold(
check => $check_value,
warning => $attributes{$attribute}{'warning'},
critical => $attributes{$attribute}{'critical'}
);
}
$result = $resultTmp if $result < $resultTmp; $result = $resultTmp if $result < $resultTmp;
$attributes{$attribute}{'check_value'}=$check_value; $attributes{$attribute}{'check_value'}=$check_value;