mirror of
https://github.com/c-kr/check_json.git
synced 2024-11-23 10:53:47 +01:00
Merge pull request #13 from worldcitizen/master
Added a boolean test option. For json variables with true/false. In this case -w en -c true/false as well as 0/1 can be used.
This commit is contained in:
commit
125e30842f
@ -140,6 +140,7 @@ my %attributes = map { $attributes[$_] => { warning => $warning[$_] , critical =
|
||||
my %check_value;
|
||||
my $check_value;
|
||||
my $result = -1;
|
||||
my $resultTmp;
|
||||
|
||||
foreach my $attribute (sort keys %attributes){
|
||||
my $check_value;
|
||||
@ -156,11 +157,40 @@ foreach my $attribute (sort keys %attributes){
|
||||
$check_value = $check_value/$attributes{$attribute}{'divisor'};
|
||||
}
|
||||
|
||||
my $resultTmp = $np->check_threshold(
|
||||
if ( $check_value eq "true" or $check_value eq "false" ) {
|
||||
if ( $check_value eq "true") {
|
||||
$resultTmp = 0;
|
||||
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;
|
||||
|
||||
$attributes{$attribute}{'check_value'}=$check_value;
|
||||
|
Loading…
Reference in New Issue
Block a user