mirror of
https://github.com/opinkerfi/nagios-plugins.git
synced 2024-11-23 10:53:44 +01:00
Revert to working copy.
This commit is contained in:
parent
1420e93c5c
commit
9060a171f0
@ -4,8 +4,6 @@ from pynag.Plugins import simple as Plugin, WARNING, CRITICAL, UNKNOWN, OK
|
|||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
import os
|
import os
|
||||||
|
|
||||||
class PluginException(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
global plugin
|
global plugin
|
||||||
@ -19,7 +17,7 @@ def main():
|
|||||||
required=False)
|
required=False)
|
||||||
plugin.add_arg("a", "check-all", "Check all LVs", required=False,
|
plugin.add_arg("a", "check-all", "Check all LVs", required=False,
|
||||||
action="store_true")
|
action="store_true")
|
||||||
plugin.activate() print lvs_output
|
plugin.activate()
|
||||||
|
|
||||||
lvs = plugin["logical-volume"] and plugin["logical-volume"].split(
|
lvs = plugin["logical-volume"] and plugin["logical-volume"].split(
|
||||||
",") or []
|
",") or []
|
||||||
@ -37,7 +35,13 @@ def main():
|
|||||||
(code, message) = (plugin.check_messages(joinallstr="\n"))
|
(code, message) = (plugin.check_messages(joinallstr="\n"))
|
||||||
plugin.nagios_exit(code, message)
|
plugin.nagios_exit(code, message)
|
||||||
|
|
||||||
def get_lv_list(hostname=None):
|
|
||||||
|
def check_mirror(lv_list, vg_list, check_all, hostname):
|
||||||
|
# Ensure the right locale for text parsing
|
||||||
|
"""
|
||||||
|
|
||||||
|
:rtype : None
|
||||||
|
"""
|
||||||
# Change lang setting for string consitency
|
# Change lang setting for string consitency
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
env['LC_ALL'] = 'C'
|
env['LC_ALL'] = 'C'
|
||||||
@ -56,18 +60,16 @@ def get_lv_list(hostname=None):
|
|||||||
lvs = Popen(cmd, stdout=PIPE, shell=False, env=env)
|
lvs = Popen(cmd, stdout=PIPE, shell=False, env=env)
|
||||||
ret = lvs.wait()
|
ret = lvs.wait()
|
||||||
lvs_output = lvs.stdout.readlines()
|
lvs_output = lvs.stdout.readlines()
|
||||||
except Exception as error:
|
except Exception, e:
|
||||||
raise PluginException("Unable to execute lvs: %s" % error)
|
plugin.nagios_exit(UNKNOWN, "Unable to execute lvs: %s" % (e))
|
||||||
|
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
raise PluginException("Bad return code from lvs command %i" % ret)
|
plugin.nagios_exit(CRITICAL,
|
||||||
|
"lvs execution failed, return code %i" % (ret))
|
||||||
logical_volume = parse_lvs(lvs_output)
|
|
||||||
|
|
||||||
def parse_lvs(lvs_output):
|
|
||||||
all_lvs = []
|
all_lvs = []
|
||||||
all_vgs = []
|
all_vgs = []
|
||||||
|
|
||||||
|
# Loop through lvs output
|
||||||
linenumber = 0
|
linenumber = 0
|
||||||
for l in lvs_output:
|
for l in lvs_output:
|
||||||
linenumber += 1
|
linenumber += 1
|
||||||
@ -99,16 +101,6 @@ def parse_lvs(lvs_output):
|
|||||||
else:
|
else:
|
||||||
plugin.add_message(OK, "LV %s/%s functioning" % (vg_name, lv_name))
|
plugin.add_message(OK, "LV %s/%s functioning" % (vg_name, lv_name))
|
||||||
|
|
||||||
def check_mirror(lv_list, vg_list, check_all, hostname):
|
|
||||||
# Ensure the right locale for text parsing
|
|
||||||
"""
|
|
||||||
|
|
||||||
:rtype : None
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
# Loop through lvs output
|
|
||||||
|
|
||||||
# Find lvs that were specified in cmd line but were not found via lvs
|
# Find lvs that were specified in cmd line but were not found via lvs
|
||||||
for v in vg_list:
|
for v in vg_list:
|
||||||
if v not in all_vgs:
|
if v not in all_vgs:
|
||||||
|
Loading…
Reference in New Issue
Block a user