matteocorti / nagios_plugins

18 stars 7 forks source link

Be able to add arguments to check_updates in the form of ./check_updates --arguments="--disablerepo=epel" #119

Closed matteocorti closed 8 years ago

matteocorti commented 8 years ago

Original reporter: _joopboonen@web.de

It's useful to disable checking of specific repo's when you maintain the repo yourself. So you will only be warned when you get a warning about updates of repo sources you don't maintain.

Can this patch please be committed and maybe improved?

--- check_updates.orig  2012-12-10 20:19:24.000000000 +0100
+++ check_updates       2013-03-20 13:12:08.063994139 +0100
@@ -387,15 +387,17 @@
 # Usage     : check_yum();
 # Purpose   : checks a yum based system for updates
 # Returns   : n/a
-# Arguments : n/a
+# Arguments : string with the command line arguments
 # Throws    : n/a
 # Comments  : n/a
 # See also  : n/a
 ## no critic (ProhibitExcessComplexity)
 sub check_yum {

+    my $arguments = shift;
+
     my $message;
-    my @outdated = run_yum(q{});
+    my @outdated = run_yum($arguments);
     my @security_updates;

     $plugin->add_perfdata(
@@ -443,7 +445,7 @@
                 $status = OK;
             }

-            @security_updates = run_yum('--security');
+            @security_updates = run_yum('--security ' . $arguments);

             if ( @security_updates > 0 ) {

@@ -755,6 +757,12 @@
         help => 'Ignores non-security updates',
     );

+    $options->arg(
+        spec => 'arguments|a=s',
+        help => 'specific yum arguments as STRING',
+
+    );
+
     $options->getopts();

     ###############
@@ -786,6 +794,14 @@
     }

     #########
+    # Arguments
+
+    my $arguments = '';
+    if ( $options->get('arguments') ) {
+        $arguments = $options->get('arguments');
+    }
+
+    #########
     # Timeout

     alarm $options->timeout;
@@ -802,7 +818,7 @@
         if ( $updater eq 'yum' ) {
             verbose "Using yum\n";
             check_running_kernel();
-            check_yum();
+            check_yum($arguments);
         }
         elsif ( $updater eq 'up2date' ) {
             verbose "Using up2date\n";
matteocorti commented 8 years ago

Original reporter: matteo@corti.li

Thanks for the patch. I'll take a look and include it in the next release

matteocorti commented 8 years ago

Original reporter: matteo@corti.li

I added the patch and released 1.6.2