[monitoring-plugins] Refactoring

Bernd Arnold git at monitoring-plugins.org
Thu Jul 26 07:40:15 CEST 2018


 Module: monitoring-plugins
 Branch: master
 Commit: cf157ef84502ed86b006fbb6289b7ec94e8f0eb3
 Author: Bernd Arnold <wopfel at gmail.com>
   Date: Wed Jun 13 17:28:53 2018 +0200
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=cf157ef

Refactoring

Better alignment.
Avoid duplications ("Exceeds ... threshold").

---

 plugins-scripts/check_uptime.pl | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/plugins-scripts/check_uptime.pl b/plugins-scripts/check_uptime.pl
index f2b47be..1f844ff 100755
--- a/plugins-scripts/check_uptime.pl
+++ b/plugins-scripts/check_uptime.pl
@@ -107,9 +107,9 @@ if ( $days > 14 ) {
 
 my $pretty_uptime = "";
 $pretty_uptime .= sprintf( "%d week%s, ",   $weeks, $weeks == 1 ? "" : "s" )  if  $weeks;
-$pretty_uptime .= sprintf( "%d day%s, ",    $days, $days == 1 ? "" : "s" )    if  $days;
+$pretty_uptime .= sprintf( "%d day%s, ",    $days,  $days  == 1 ? "" : "s" )  if  $days;
 $pretty_uptime .= sprintf( "%d hour%s, ",   $hours, $hours == 1 ? "" : "s" )  if  $hours;
-$pretty_uptime .= sprintf( "%d minute%s, ", $mins, $mins == 1 ? "" : "s" )    if  $mins;
+$pretty_uptime .= sprintf( "%d minute%s, ", $mins,  $mins  == 1 ? "" : "s" )  if  $mins;
 # Replace last occurence of comma with "and"
 $pretty_uptime =~ s/, $/ and /;
 # Always print the seconds (though it may be 0 seconds)
@@ -123,16 +123,16 @@ my $state_str = "UNKNOWN";
 my $out_of_bounds_text = "";
 if ( $uptime_seconds > $upper_crit_threshold ) {
 	$state_str = "CRITICAL";
-	$out_of_bounds_text = "Exceeds upper crit threshold";
+	$out_of_bounds_text = "upper crit";
 } elsif ( $uptime_seconds < $lower_crit_threshold ) {
 	$state_str = "CRITICAL";
-	$out_of_bounds_text = "Exceeds lower crit threshold";
+	$out_of_bounds_text = "lower crit";
 } elsif ( $uptime_seconds > $upper_warn_threshold ) {
 	$state_str = "WARNING";
-	$out_of_bounds_text = "Exceeds upper warn threshold";
+	$out_of_bounds_text = "upper warn";
 } elsif ( $uptime_seconds < $lower_warn_threshold ) {
 	$state_str = "WARNING";
-	$out_of_bounds_text = "Exceeds lower warn threshold";
+	$out_of_bounds_text = "lower warn";
 } else {
 	$state_str = "OK";
 }
@@ -140,7 +140,7 @@ if ( $uptime_seconds > $upper_crit_threshold ) {
 $msg = "$state_str: ";
 
 $msg .= "uptime is $uptime_seconds seconds. ";
-$msg .= "$out_of_bounds_text. "  if  $out_of_bounds_text;
+$msg .= "Exceeds $out_of_bounds_text threshold. "  if  $out_of_bounds_text;
 $msg .= "Running for $pretty_uptime. "  if  $opt_f;
 if ( $opt_s ) {
 	chomp( my $up_since = `uptime -s` );



More information about the Commits mailing list