Misc s/func/certmaster/ replacements
[certmaster.git] / certmaster / minion / modules / nagios-check.py
1 # Copyright 2007, Red Hat, Inc
2 # James Bowes <jbowes@redhat.com>
3 # Seth Vidal modified command.py to be nagios-check.py
4 #
5 # This software may be freely redistributed under the terms of the GNU
6 # general public license.
7 #
8 # You should have received a copy of the GNU General Public License
9 # along with this program; if not, write to the Free Software
10 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
11
12 """
13 Abitrary command execution module for func.
14 """
15
16 import func_module
17 import sub_process
18
19 class Nagios(func_module.FuncModule):
20
21 version = "0.0.1"
22 api_version = "0.0.1"
23 description = "Runs nagios checks."
24
25 def run(self, check_command):
26 """
27 Runs a nagios check returning the return code, stdout, and stderr as a tuple.
28 """
29 nagios_path='/usr/lib/nagios/plugins'
30 command = '%s/%s' % (nagios_path, check_command)
31
32 cmdref = sub_process.Popen(command.split(),stdout=sub_process.PIPE,stderr=sub_process.PIPE, shell=False)
33 data = cmdref.communicate()
34 return (cmdref.returncode, data[0], data[1])