diff --git a/check_d42_health.pl b/check_d42_health.pl index 7dd1c0a..c25cf08 100644 --- a/check_d42_health.pl +++ b/check_d42_health.pl @@ -16,7 +16,6 @@ use File::Basename; $PROGNAME = basename($0); - my $plugin = Monitoring::Plugin->new( usage => "Usage: %s [ -v|--verbose ] [-t|--timeout ] [ -H|--host= ] @@ -81,6 +80,7 @@ # Parse arguments and process standard ones (e.g. usage, help, version) $plugin->getopts; +my $uom = ''; # -- cache variables my $cache_enabled = $plugin->opts->cache ? 1 : 0; @@ -179,7 +179,15 @@ $data_val = 100 - getPercentage('swaptotal', $data_val); } - +if ($plugin->opts->item =~ /swapfree|memfree|disk_used_percent|cpu_used_percent/) { + $uom = '%' +} +elsif ($plugin->opts->item =~ /swaptotal|memtotal|dbsize/) { + $uom = 'MB' +} +else { + $uom = '' +} # -- process backup status item if ($plugin->opts->item eq 'backup_status') { @@ -230,6 +238,12 @@ $plugin->set_thresholds(warning => $plugin->opts->warning, critical => $plugin->opts->critical); } +$plugin->add_perfdata( + label => $plugin->opts->item, + value => $data_val, + uom => $uom, +) if ($uom ne ''); + # -- compare thresholds if ($plugin->opts->warning || $plugin->opts->critical) {