Re: Patch: nagios-check module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Thu, Sep 29, 2011 at 11:52 AM, Greg Swift <gregswift@xxxxxxxxx> wrote:
you are correct. I just forgot to fix it. I think your suggestion of
matching the name to the base module is better than func's naming.


Sounds good, just had to check my assumptions as this is not my area of expertise. Thanks for the help. Here then is the revised patch:

-Erinn


diff --git a/func/minion/modules/nagios_check.py b/func/minion/modules/nagios_check.py
index c080e56..dc1fbd4 100644
--- a/func/minion/modules/nagios_check.py
+++ b/func/minion/modules/nagios_check.py
@@ -10,26 +10,38 @@
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
 """
-Abitrary command execution module for func.
+Arbitrary command execution module for func.
 """
 
+from certmaster.config import BaseConfig, Option
 import func_module
-import sub_process
+try:
+    import subprocess
+#Needed for compatibility with Python < 2.4
+except ImportError:
+    from func.minion import sub_process as subprocess
 
-class Nagios(func_module.FuncModule):
+class NagiosCheck(func_module.FuncModule):
 
-    version = "0.0.1"
+    version = "0.0.2"
     api_version = "0.0.1"
-    description = "Runs nagios checks."
+    description = "Runs Nagios checks."
+
+    class Config(BaseConfig):
+        nagios_path = Option('/usr/lib/nagios/plugins')
 
     def run(self, check_command):
         """
-        Runs a nagios check returning the return code, stdout, and stderr as a tuple.
+        Runs a Nagios check gathering the return code, stdout, and stderr
+        as a tuple.
         """
-        nagios_path='/usr/lib/nagios/plugins'
-        command = '%s/%s' % (nagios_path, check_command)
+        command = '%s/%s' % (self.options.nagios_path, check_command)
 
-        cmdref = sub_process.Popen(command.split(),stdout=sub_process.PIPE,stderr=sub_process.PIPE, shell=False, close_fds=True)
+        cmdref = subprocess.Popen(command.split(),
+                                   stdout=subprocess.PIPE,
+                                   stderr=subprocess.PIPE,
+                                   shell=False, close_fds=True)
+       
         data = "">          return (cmdref.returncode, data[0], data[1])


_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list

[Index of Archives]     [Fedora Users]     [Linux Networking]     [Fedora Legacy List]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux