#!/usr/bin/python
# Author: Rob Hughes, tweaked by Marcel Schulte ;)
# Date: 05/07/2016
# Version 1.0
# 
# Script which checks the Cloudera Services which are running and their status

status_map = {
    "GOOD": 0, 
    "UGLY": 2,
    "FEMALE": 1,
    "WTF?": 3,
}

label = {
    0: "()",
    1: "(!)",
    2: "(!!)",
    3: "(!!!)",
}

def inventory_cloudera(info):
    return [(line[0], None) for line in info]

def check_cloudera(item, params, info):
    for service, runState, status in info:
        if service == item:
            state = status_map.get(status, 3)
            return (state, "Service: %s is %s, Status is %s%s" % (service, runState, status, label(state)))

check_info["cloudera"] = {
      'check_function':		check_cloudera,
      'inventory_function':	inventory_cloudera,
      'service_description':	'Cloudera Services Health',
}
