# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
"""Nagios plugin to test the status of all arrays on all Lsi MegaRaid
controllers on the local machine. Uses the megarc.bin program written by Lsi to
"""Nagios plugin to test the status of all arrays on all Lsi MegaRaid
controllers on the local machine. Uses the megarc.bin program written by Lsi to
MEGADEV = "/dev/megadev0"
def end(status, message):
"""exits the plugin with first arg as the return code and the second
arg as the message to output"""
MEGADEV = "/dev/megadev0"
def end(status, message):
"""exits the plugin with first arg as the return code and the second
arg as the message to output"""
cmd = "mknod /dev/megadev0 c %s 2" % major_number
print >> sys.stderr, "running in shell: %s" % cmd
try:
cmd = "mknod /dev/megadev0 c %s 2" % major_number
print >> sys.stderr, "running in shell: %s" % cmd
try:
if not os.path.exists(BIN):
end(UNKNOWN, "Lsi MegaRaid utility '%s' was not found" % BIN)
if not os.path.exists(BIN):
end(UNKNOWN, "Lsi MegaRaid utility '%s' was not found" % BIN)
if not os.path.exists(MEGADEV):
print >> sys.stderr, "Megaraid device node not found (possible first " \
if not os.path.exists(MEGADEV):
print >> sys.stderr, "Megaraid device node not found (possible first " \
print "UNKNOWN: internal python error",
print "- no cmd supplied for Lsi MegaRaid utility"
sys.exit(UNKNOWN)
print "UNKNOWN: internal python error",
print "- no cmd supplied for Lsi MegaRaid utility"
sys.exit(UNKNOWN)
result, output = commands.getstatusoutput(cmd)
lines = output.split("\n")
if result != 0:
result, output = commands.getstatusoutput(cmd)
lines = output.split("\n")
if result != 0:
else:
end(UNKNOWN, "Error using MegaRaid utility - %s" \
% output.replace("\n", "|"))
else:
end(UNKNOWN, "Error using MegaRaid utility - %s" \
% output.replace("\n", "|"))
- # inconsistent way that the LSI tools count arrays.
- # This brings it back in line with the view in the bios
- # and from megamgr.bin where the array counting starts at
+ # inconsistent way that the LSI tools count arrays.
+ # This brings it back in line with the view in the bios
+ # and from megamgr.bin where the array counting starts at
# 1 instead of 0
message += 'Array %s status is "%s"' % (int(drive)+1, state)
message += '(Raid-%s on adapter %s), ' \
# 1 instead of 0
message += 'Array %s status is "%s"' % (int(drive)+1, state)
message += '(Raid-%s on adapter %s), ' \