Skip to content
Snippets Groups Projects
Commit 3d91a27e authored by cheko's avatar cheko
Browse files

Added a check to make sure there is no division by zerro. In case the

gapfile is empty or corrupted, the resulting values will be 0, this
could cause an unwanted alarm.
parent ded959d9
No related branches found
No related tags found
No related merge requests found
......@@ -38,8 +38,6 @@ use warnings;
#-------------------------------------------------------------------------------
# Used Modules
#-------------------------------------------------------------------------------
# use lib "/usr/local/nrpe/perl/lib";
# use Nagios::Plugin;
use Monitoring::Plugin;
use Data::Dumper;
......@@ -137,6 +135,12 @@ sub calculateData
for ( my $i = 0; $i < scalar @$names; $i++ )
{
# in case the gapfile is empty
if ( $sum == 0 )
{
$cpu->[ $i ] = 0;
next;
}
$cpu->[ $i ] = $results[ $i ] * 100 / $sum;
}
return $cpu;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment