On 09/30/2011 10:29 AM, Tim Bielawa wrote:
>
> I'm having trouble applying this patch. I think one of our mail clients
> is wrapping parts of it because it's inlined.
>
> $ git am < ~/nagios-check-fix.patch
> Applying: Patch: nagios-check module
> fatal: corrupt patch at line 39
> Patch failed at 0001 Patch: nagios-check module
>
> Also, the diff header of the patch is referring to a file that does not
> exist yet if you are applying it against what's in git.
>
> Can you: Make and commit all your changes in git locally and then:
>
> git format-patch origin/master
>
> After that can you respond to this thread with it as an attachment?
>
> Thanks,
>
>
> p.s. the patch looks fine, but honestly I just can't even apply it to
> give it a simple smoke-test
>
>
Sorry about that, let me know if the attached works better. As for the
file name, since nagios-check.py can not be import directly in python
due to the hyphen:
In [1]: import nagios-check
File "<ipython-input-1-6ddeeb3cbbd2>", line 1
import nagios-check
^
SyntaxError: invalid syntax
I renamed it nagios_check.py, not sure if this is the best for the
future but that is where that confusion lay. Is there a way to capture a
name change in a patch? The name has been changed back so this "should"
apply cleanly.
-Erinn
>From 3247d450269fa16d72b0e6afbab8186e70886e77 Mon Sep 17 00:00:00 2001
From: Erinn Looney-Triggs <[email protected]>
Date: Fri, 30 Sep 2011 10:38:02 -0800
Subject: [PATCH] Clean up nagios-check module. Allow it to work with config
files, change class name to avoid collision, import
sub_process properly and allow it to work with subprocess
when needed.
---
func/minion/modules/nagios-check.py | 30 +++++++++++++++++++++---------
1 files changed, 21 insertions(+), 9 deletions(-)
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 = cmdref.communicate()
return (cmdref.returncode, data[0], data[1])
--
1.7.6.4
_______________________________________________
Func-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/func-list