File: //lib/python2.7/site-packages/lap/check_raid_hp.py
import subprocess
import re
import os
import string
def __run__(params):
if not os.path.exists('/usr/lib/check_mk_agent/need_sudo/check_raid_hp'):
return [2, '/need_sudo/check_raid_hp is not installed, please reinstall locaweb-plugins']
if not os.path.exists('/usr/sbin/hpacucli'):
return [2, 'hpacucli is not installed, please install hpacucli']
try:
p = subprocess.Popen(['/usr/bin/sudo',
'/usr/lib/check_mk_agent/need_sudo/check_raid_hp'],
stdout=subprocess.PIPE)
except Exception as e:
return [2, 'CRITICAL - Problems executing check_raid_hp %s' % repr(e)]
bad_chars = "(){}<>[],'"
out = str(p.stdout.read().split('\n'))
out = out.translate(string.maketrans("", "", ), bad_chars)
if "CRITICAL" in out:
return [2, '%s' % out]
elif "WARNING" in out:
return [1, '%s' % out]
else:
return [0, '%s' % out]