Skip to content

Commit

Permalink
Support shell commands
Browse files Browse the repository at this point in the history
  • Loading branch information
ludovic-gasc committed Mar 21, 2015
1 parent b00a7b8 commit 3c41bd4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
5 changes: 5 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Release History
---------------

1.1.1 (YYYY-MM-DD)
``````````````````

- Support shell commands

1.1 (2014-05-12)
````````````````

Expand Down
31 changes: 17 additions & 14 deletions monitoring_agent/inputs/nagios_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import logging
import subprocess
import os
import time

from monitoring_agent import configurator
Expand Down Expand Up @@ -36,26 +35,30 @@ def launch_plugin(self):
# nagios_plugins probes
for plugin in self.plugins:
# Construct the nagios_plugin command
command = ('%s%s' % (self.plugins[plugin]['path'], self.plugins[plugin]['command'])).split(' ')
command = ('%s%s' % (self.plugins[plugin]['path'], self.plugins[plugin]['command']))

try:
nagios_plugin = subprocess.Popen(command,
shell=False,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
except OSError:
LOG.error("[nagios_plugins]: '%s' executable is missing",
command[0])
command)
else:
output = nagios_plugin.communicate()[0].strip()
return_code = nagios_plugin.returncode
LOG.log(STATUSES[return_code][1],
"[nagios_plugins][%s] (%s status): %s",
plugin,
STATUSES[return_code][0],
output)
yield {'return_code': int(return_code),
'output': str(output),
'time_stamp': int(time.time()),
'service_description': plugin,
'specific_servers': self.plugins[plugin]['servers']}
if return_code >= len(STATUSES):
LOG.error("[nagios_plugins]: '%s' executable has an issue, return code: %s",
command, return_code)
else:
LOG.log(STATUSES[return_code][1],
"[nagios_plugins][%s] (%s status): %s",
plugin,
STATUSES[return_code][0],
output)
yield {'return_code': int(return_code),
'output': str(output),
'time_stamp': int(time.time()),
'service_description': plugin,
'specific_servers': self.plugins[plugin]['servers']}
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

setup(
name='tanto',
version='1.1',
version='1.1.1',
description='Takes monitoring data from Nagios-plugins to push with NSCA (Nagios or Icinga) or WS-Shinken.',
long_description=long_description,
author='Ludovic Gasc',
Expand Down

0 comments on commit 3c41bd4

Please sign in to comment.