File: //usr/lib/python2.7/site-packages/lap/check_hw_maintenance.py
from pymongo import MongoClient
import re
def __run__(params):
try:
client = MongoClient("mongodb://localhost")
db = client.cegonha
hwcollection = db.hardwares
except Exception, err:
return([2, "Critial and unexpected error: {0}".format(err)])
regex = re.compile("^Man", re.IGNORECASE)
query = {'hardwares.status': regex,
'hardwares.name': ""
}
available = hwcollection.find(query)
hws = [h['hardwares']['name_cache'] for h in available]
if not hws:
return([0, "OK - Nice, no hardwares in maintenance lost"])
else:
return([1, hws])