1 # Copyright 2007, Red Hat, Inc
2 # James Bowes <jbowes@redhat.com>
3 # Seth Vidal modified command.py to be nagios-check.py
5 # This software may be freely redistributed under the terms of the GNU
6 # general public license.
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.
13 Abitrary command execution module for func.
19 class Nagios(func_module
.FuncModule
):
23 description
= "Runs nagios checks."
25 def run(self
, check_command
):
27 Runs a nagios check returning the return code, stdout, and stderr as a tuple.
29 nagios_path
='/usr/lib/nagios/plugins'
30 command
= '%s/%s' % (nagios_path
, check_command
)
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])