File: //usr/lib/python2.7/site-packages/lap/check_lxc.py
import commands
import yaml
def __run__(params):
try:
down = []
for server in yaml.load(params.get('instances')).split(','):
output = commands.getoutput('/usr/bin/lxc-info -s -n %s' % server)
if 'STOPPED' in output.split()[0]:
down.append(server)
if len(down):
return [2, "CRITICAL - Error, %d instances down: %s" % ( len(down), ','.join([ x for x in down ]) ) ]
else:
return [0, "OK - All instances is working fine" ]
except Exception, e:
return [2, "CRITICAL - Error: %s" % repr(e) ]