Hello community,

here is the log from the commit of package nagios-plugins-maintenance for 
openSUSE:Factory checked in at 2014-07-26 09:41:51
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/nagios-plugins-maintenance (Old)
 and      /work/SRC/openSUSE:Factory/.nagios-plugins-maintenance.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "nagios-plugins-maintenance"

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/nagios-plugins-maintenance/nagios-plugins-maintenance.changes
    2013-01-24 15:40:41.000000000 +0100
+++ 
/work/SRC/openSUSE:Factory/.nagios-plugins-maintenance.new/nagios-plugins-maintenance.changes
       2014-07-26 09:41:57.000000000 +0200
@@ -1,0 +2,8 @@
+Thu Jul 17 13:12:33 UTC 2014 - [email protected]
+
+- update to 2.0:
+  + allow to define a budget_date : unless this date is reached, 
+    we will not announce a warning or critical exit code 
+  + allow more fields for serial and inventory
+
+-------------------------------------------------------------------

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ nagios-plugins-maintenance.spec ++++++
--- /var/tmp/diff_new_pack.sgDuHe/_old  2014-07-26 09:41:58.000000000 +0200
+++ /var/tmp/diff_new_pack.sgDuHe/_new  2014-07-26 09:41:58.000000000 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package nagios-plugins-maintenance
 #
-# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,12 +17,12 @@
 
 
 Name:           nagios-plugins-maintenance
-Version:        1.7
-Release:        1
-License:        BSD-3-Clause
+Version:        2.0
+Release:        0
 Summary:        Check, if a host is in service
-Url:            http://en.opensuse.org/Nagios-plugins-maintenance
+License:        BSD-3-Clause
 Group:          System/Monitoring
+Url:            http://en.opensuse.org/Nagios-plugins-maintenance
 Source0:        check_maintenance.pl
 BuildRequires:  nagios-rpm-macros
 Requires:       perl(Date::Calc)

++++++ check_maintenance.pl ++++++
--- /var/tmp/diff_new_pack.sgDuHe/_old  2014-07-26 09:41:58.000000000 +0200
+++ /var/tmp/diff_new_pack.sgDuHe/_new  2014-07-26 09:41:58.000000000 +0200
@@ -4,6 +4,7 @@
 # check_maintenance - nagios plugin
 #
 # Copyright (C) 2010, Novell, Inc.
+# Copyright (C) 2014, SUSE Linux Products GmbH, Nuremberg
 # Author: Lars Vogdt
 #
 # All rights reserved.
@@ -50,13 +51,14 @@
 $ENV{'ENV'}      = '';
 
 our $conf = {
-    VERSION    => '1.7',
-    PROGNAME   => 'check_maintenance',
-    maint_file => '/etc/nagios/maintenance_data.txt',
-    timeout    => 120,
-    critical   => 4,
-    warning    => 8,
-    debug      => 0
+    VERSION     => '2.0',
+    PROGNAME    => 'check_maintenance',
+    maint_file  => '/etc/nagios/maintenance_data.txt',
+    budget_date => '01.01.1970',
+    timeout     => 120,
+    critical    => 4,
+    warning     => 8,
+    debug       => 0
 };
 
 our $print_version = 0;
@@ -118,7 +120,17 @@
                     DEBUG("No valid date for $host");
                 }
             }
-            if ( $comment =~ /.*\|.*/ ) {
+            if ( $comment =~ /.*\|.*\|.*\|.*/ ){
+                my ( $vendor, $serial, $inventory, $comment ) = split( '\|', 
$comment, 4 );
+                DEBUG(
+                    "More information in comment detected. Vendor: $vendor ; 
Serial: $serial ; Inventory: $inventory ; comment: $comment"
+                );
+                $data{$host}{'serial'}  = $serial;
+                $data{$host}{'inventory'}  = $inventory;
+                $data{$host}{'comment'} = $comment;
+                $data{$host}{'vendor'}  = $vendor;
+            }
+            elsif ( $comment =~ /.*\|.*/ ) {
                 my ( $vendor, $comment ) = split( '\|', $comment, 2 );
                 DEBUG(
                     "More information in comment detected. Vendor: $vendor ; 
comment: $comment"
@@ -165,6 +177,8 @@
     "releasefile=s" => \$conf->{'maint_file'},
     "t=i"           => \$conf->{'timeout'},
     "timeout=i"     => \$conf->{'timeout'},
+    "b=s"           => \$conf->{'budget_date'},
+    "budget_date=s"  => \$conf->{'budget_date'},
 ) or pod2usage(2);
 
 pod2usage(
@@ -208,6 +222,40 @@
     alarm(0);
     exit $ERRORS{"UNKNOWN"};
 }
+if ( "$conf->{'budget_date'}" =~ /\d{1,2}\.\d{1,2}\.\d{4}/ ){
+       my ($day, $month, $year ) = split( '\.', $conf->{'budget_date'}, 3 );
+       if ( check_date( $year, $month, $day ) ) {
+               $conf->{'budget_day'}=$day;
+               $conf->{'budget_month'}=$month;
+               $conf->{'budget_year'}=$year;
+       }
+       else {
+               print "ERROR: given budget_day $conf->{'budget_date'} is no 
valid date.\n";
+               pod2usage(2);
+               alarm(0);
+               exit $ERRORS{"UNKNOWN"};
+       }
+}
+elsif ( "$conf->{'budget_date'}" =~ /\d{1,2}\/\d{1,2}\/\d{4}/ ) {
+       my ( $day, $month, $year ) = split( '\/', $conf->{'budget_date'}, 3 );
+        if ( check_date( $year, $month, $day ) ) {
+               $conf->{'budget_day'}=$day;
+               $conf->{'budget_month'}=$month;
+               $conf->{'budget_year'}=$year;
+       }
+       else {
+                print "ERROR: given budget_day $conf->{'budget_date'} is no 
valid date.\n";
+                pod2usage(2);
+                alarm(0);
+                exit $ERRORS{"UNKNOWN"};
+        }
+}
+else {
+       print "ERROR: given budget_date $conf->{'budget_date'} is unkown\n";
+       pod2usage(2);
+       alarm(0);
+       exit $ERRORS{"UNKNOWN"};
+}
 
 my $dataref = read_maintenance_data( $conf->{'maint_file'} );
 
@@ -232,14 +280,20 @@
         $dataref->{$hostname}->{'day'},
     );
     my $today_since_ad = Date_to_Days( $year, $month, $day );
-    DEBUG "Today is: $today_since_ad";
-    DEBUG "Service : $service_since_ad";
+    my $budget_date    = Date_to_Days( $conf->{'budget_year'}, 
$conf->{'budget_month'}, $conf->{'budget_day'} );
+    DEBUG "Today is   : $today_since_ad";
+    DEBUG "Service    : $service_since_ad";
+    DEBUG "Budget Day : $budget_date";
 
     my $difference   = $service_since_ad - $today_since_ad;
     my $warndays     = $conf->{'warning'} * 7;
     my $criticaldays = $conf->{'critical'} * 7;
     use integer;
     my $weeks = $difference / 7;
+    my $budget_day_override=0;
+    if ( $today_since_ad >= $budget_date ){
+        $budget_day_override=1;
+    }
     DEBUG
         "Difference:$difference; Warndays:$warndays; 
Criticaldays:$criticaldays;";
 
@@ -253,16 +307,32 @@
                 = "CRITICAL: hardware is out of maintenance since "
                 . abs($weeks)
                 . " weeks";
-            $error = "CRITICAL";
+            if ( $budget_day_override ){
+                   $error = "CRITICAL";
+            } 
+            else {
+                    DEBUG "State is critical, but we did not reach the budget 
day\n";
+                    $error = "OK";
+            }
         }
         else {
             $ret_str = "CRITICAL: only " . $weeks . " weeks left";
-            $error   = "CRITICAL";
+            if ( $budget_day_override ){
+                $error   = "CRITICAL";
+            } else {
+                $error = "OK";
+            }
         }
     }
     elsif ( $difference < $warndays ) {
         $ret_str = "WARNING: only " . $weeks . " weeks left";
-        $error   = "WARNING";
+        if ( $budget_day_override ){
+            $error   = "WARNING";
+        }
+        else {
+            DEBUG "State is warning, but we did not reach the budget day\n";
+            $error = "OK";
+        }
     }
     else {
         $ret_str = "UNKOWN: got some misterious data";
@@ -276,6 +346,19 @@
     {
         $ret_str .= ";\nVendor: " . $dataref->{$hostname}->{'vendor'};
     }
+    if (   ( defined $dataref->{$hostname}->{'serial'} )
+        && ( $dataref->{$hostname}->{'serial'} ne "" ) )
+    {
+        $ret_str .= ";\n" . $dataref->{$hostname}->{'serial'};
+    }
+    if (   ( defined $dataref->{$hostname}->{'inventory'} )
+        && ( $dataref->{$hostname}->{'inventory'} ne "" ) )
+    {
+        $ret_str .= ";\n" . $dataref->{$hostname}->{'inventory'};
+    }
+    if ( "$conf->{'budget_day'}" ne "01.01.1970" ){
+        $ret_str .= ";\nBudget day: ".$conf->{'budget_date'};
+    }
     $ret_str .= ";\n" . $dataref->{$hostname}->{'comment'} . "\n";
     print "$ret_str";
     $exitcode = $ERRORS{$error};
@@ -305,6 +388,7 @@
     -w <int>         | --warning <int>
     -c <int>         | --critical <int>
     -f <file>        | --file <file>
+    -b <date>        | --budget_date <date>
 
     -h               | --help
     -d               | --debug
@@ -336,7 +420,7 @@
 
 or
 
-<hostname>|<last service date>|[Vendor]|[additional information shown in check 
output]
+<hostname>|<last service date>|[Vendor]|[Serial number]|Inventory/Asset 
number|[additional information shown in check output]
 
 =back
 
@@ -355,9 +439,14 @@
 
 B<Vendor> is not required, it is currently just an additional output value for 
the comment section.
 
-All lines without two '|' are currently ignored. Best way to mark a line as 
+All lines without '|' will result in a warning. Best way to mark a line as 
 comment is a '#' at the beginning, this allows further improvements in the 
future.
 
+=item B<--budget_day> F<date>
+
+Instead of issuing a warning/critical once the machine is running out of 
service, 
+do this only <warn> or <crit> days before the budget_day arrises.
+
 =item B<--help>
 
 Produces this output.

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to