mirror of
https://github.com/shouptech/nagios-plugin-check-rabbitmq.git
synced 2026-02-03 14:49:41 +00:00
Fix exit call on python 2.4.3
PEP 8 style fixes (pylint)
This commit is contained in:
parent
f247cf0b05
commit
0ba59c23bb
1 changed files with 12 additions and 8 deletions
|
|
@ -6,6 +6,7 @@
|
||||||
the management API available."""
|
the management API available."""
|
||||||
|
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
import sys
|
||||||
import urllib2
|
import urllib2
|
||||||
import base64
|
import base64
|
||||||
import math
|
import math
|
||||||
|
|
@ -75,7 +76,7 @@ class RabbitAPIChecker(object):
|
||||||
message = "OK - %d%% of sockets in use" % per_sockets_used
|
message = "OK - %d%% of sockets in use" % per_sockets_used
|
||||||
state_code = self.STATE_OK
|
state_code = self.STATE_OK
|
||||||
|
|
||||||
return (message,state_code)
|
return (message, state_code)
|
||||||
|
|
||||||
def check_fd(self, args, critical=90, warning=80):
|
def check_fd(self, args, critical=90, warning=80):
|
||||||
"""Checks the percentage of file descriptors used"""
|
"""Checks the percentage of file descriptors used"""
|
||||||
|
|
@ -91,17 +92,20 @@ class RabbitAPIChecker(object):
|
||||||
message = "CRITICAL - %d%% of file descriptors in use" % per_fd_used
|
message = "CRITICAL - %d%% of file descriptors in use" % per_fd_used
|
||||||
state_code = self.STATE_CRITICAL
|
state_code = self.STATE_CRITICAL
|
||||||
elif per_fd_used >= warning:
|
elif per_fd_used >= warning:
|
||||||
message = "WARNING - %d%% of file descriptors in use" % per_fd_used
|
message = "WARNING - %d%% of file descriptors in use" % per_fd_used
|
||||||
state_code = self.STATE_WARNING
|
state_code = self.STATE_WARNING
|
||||||
else:
|
else:
|
||||||
message = "OK - %d%% of file descriptors in use" % per_fd_used
|
message = "OK - %d%% of file descriptors in use" % per_fd_used
|
||||||
state_code = self.STATE_OK
|
state_code = self.STATE_OK
|
||||||
|
|
||||||
return (message,state_code)
|
return (message, state_code)
|
||||||
|
|
||||||
def check_nodes(self, args=None, critical=2, warning=1):
|
def check_nodes(self, args=None, critical=2, warning=1):
|
||||||
""" Checks if all nodes on the cluster are running"""
|
""" Checks if all nodes on the cluster are running"""
|
||||||
|
|
||||||
|
if args:
|
||||||
|
return ("UNKNOWN - Unexpected arguments found", self.STATE_UNKNOWN)
|
||||||
|
|
||||||
url = "http://%s:%s/api/nodes" % (self.hostname, self.port)
|
url = "http://%s:%s/api/nodes" % (self.hostname, self.port)
|
||||||
results = self.fetch_from_api(url)
|
results = self.fetch_from_api(url)
|
||||||
|
|
||||||
|
|
@ -174,15 +178,15 @@ def main():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if options.critical and options.warning:
|
if options.critical and options.warning:
|
||||||
(message,state_code) = actions[args[0]](
|
(message, state_code) = actions[args[0]](
|
||||||
args[0:], options.critical, options.warning)
|
args[0:], options.critical, options.warning)
|
||||||
elif options.critical:
|
elif options.critical:
|
||||||
(message,state_code) = actions[args[0]](args[0:], options.critical)
|
(message, state_code) = actions[args[0]](args[0:], options.critical)
|
||||||
elif options.warning:
|
elif options.warning:
|
||||||
(message,state_code) = actions[args[0]](
|
(message, state_code) = actions[args[0]](
|
||||||
args[0:], warning=options.warning)
|
args[0:], warning=options.warning)
|
||||||
else:
|
else:
|
||||||
(message,state_code) = actions[args[0]](args[0:])
|
(message, state_code) = actions[args[0]](args[0:])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print "UNKNOWN - %s is not a valid action" % args[0]
|
print "UNKNOWN - %s is not a valid action" % args[0]
|
||||||
return RabbitAPIChecker.STATE_UNKNOWN
|
return RabbitAPIChecker.STATE_UNKNOWN
|
||||||
|
|
@ -197,4 +201,4 @@ def main():
|
||||||
return state_code
|
return state_code
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
exit(main())
|
sys.exit(main())
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue