Esempio n. 1
0
def perfometer_check_mk_printer_supply(row, check_command, perf_data):
    left = utils.savefloat(perf_data[0][1])
    maxi = utils.savefloat(perf_data[0][6])
    if maxi < 0:
        return "", ""  # Printer does not supply a max value

    # If there is no 100% given, calculate the percentage
    if maxi != 100.0 and maxi != 0.0:
        left = left * 100.0 / maxi

    s = row['service_description'].lower()

    if 'black' in s or ("ink" not in s and s[-1] == 'k'):
        colors = ['#000000', '#6E6F00', '#6F0000']
    elif 'magenta' in s or s[-1] == 'm':
        colors = ['#FC00FF', '#FC7FFF', '#FEDFFF']
    elif 'yellow' in s or s[-1] == 'y':
        colors = ['#FFFF00', '#FEFF7F', '#FFFFCF']
    elif 'cyan' in s or s[-1] == 'c':
        colors = ['#00FFFF', '#7FFFFF', '#DFFFFF']
    else:
        colors = ['#CCCCCC', '#ffff00', '#ff0000']

    st = min(2, row['service_state'])
    color = colors[st]

    return "%.0f%%" % left, perfometer_linear(left, color)
Esempio n. 2
0
def perfometer_check_mk_brocade_fcport(row, check_command, perf_data):
    return perfometer_bandwidth(
        in_traffic=utils.savefloat(perf_data[0][1]),
        out_traffic=utils.savefloat(perf_data[1][1]),
        in_bw=utils.savefloat(perf_data[0][6]),
        out_bw=utils.savefloat(perf_data[1][6]),
    )
Esempio n. 3
0
def perfometer_check_mk_cisco_qos(row, check_command, perf_data):
    unit = "Bit" if "Bit/s" in row["service_plugin_output"] else "B"
    return perfometer_bandwidth(in_traffic=utils.savefloat(perf_data[0][1]),
                                out_traffic=utils.savefloat(perf_data[1][1]),
                                in_bw=utils.savefloat(perf_data[0][5]),
                                out_bw=utils.savefloat(perf_data[1][5]),
                                unit=unit)
Esempio n. 4
0
def perfometer_check_mk_fc_port(row, check_command, perf_data):
    unit = "B"
    return perfometer_bandwidth(in_traffic=utils.savefloat(perf_data[0][1]),
                                out_traffic=utils.savefloat(perf_data[1][1]),
                                in_bw=utils.savefloat(perf_data[0][6]),
                                out_bw=utils.savefloat(perf_data[1][6]),
                                unit=unit)
Esempio n. 5
0
 def cmp(self, r1, r2):
     return (
         (utils.savefloat(get_perfdata_nth_value(r1, self._num - 1, True)) >
          utils.savefloat(get_perfdata_nth_value(r2, self._num - 1, True)))
         -
         (utils.savefloat(get_perfdata_nth_value(r1, self._num - 1, True)) <
          utils.savefloat(get_perfdata_nth_value(r2, self._num - 1, True))))
Esempio n. 6
0
def perfometer_power(row, check_command, perf_data):
    display_color = "#60f020"

    value = utils.savefloat(perf_data[0][1])
    crit = utils.savefloat(perf_data[0][4])
    warn = utils.savefloat(perf_data[0][3])
    power_perc = value / crit * 90  # critical is at 90% to allow for more than crit # fixed: true-division

    if value > warn:
        display_color = "#FFC840"
    if value > crit:
        display_color = "#FF0000"

    display_string = "%.1f Watt" % value
    return display_string, perfometer_linear(power_perc, display_color)
Esempio n. 7
0
def perfometer_current(row, check_command, perf_data):
    display_color = "#50f020"

    value = utils.savefloat(perf_data[0][1])
    crit = utils.savefloat(perf_data[0][4])
    warn = utils.savefloat(perf_data[0][3])
    current_perc = value / crit * 90  # critical is at 90% to allow for more than crit

    if value > warn:
        display_color = "#FDC840"
    if value > crit:
        display_color = "#FF0000"

    display_string = "%.1f Ampere" % value
    return display_string, perfometer_linear(current_perc, display_color)
Esempio n. 8
0
def perfometer_ipmi_sensors(row, check_command, perf_data):
    state = row["service_state"]
    color = "#39f"
    value = float(perf_data[0][1])
    crit = utils.savefloat(perf_data[0][4])
    if not crit:
        return "%d" % int(value), perfometer_logarithmic(value, 40, 1.2, color)

    perc = value * 100.0 / crit
    # some sensors get critical if the value is < crit (fans), some if > crit (temp)
    if value <= crit:
        data = [(perc, color), (100 - perc, get_themed_perfometer_bg_color())]
    elif state == 0:  # fan, OK
        m = max(value, 10000.0)
        perc_crit = crit * 100.0 / m
        perc_value = (value - crit) * 100.0 / m
        perc_free = (m - value) * 100.0 / m
        data = [(perc_crit, color), (perc_value, color),
                (perc_free, get_themed_perfometer_bg_color())]
    else:
        data = []

    if perf_data[0][0] == "temp":
        unit = "°C"
    else:
        unit = ""
    return (u"%d%s" % (int(value), unit)), render_perfometer(data)
Esempio n. 9
0
def float_or_int(value):
    from cmk.gui.utils import saveint, savefloat
    if isinstance(value, int):
        return saveint(value)

    if isinstance(value, float):
        return savefloat(value)

    if isinstance(value, basestring):
        value_int = saveint(value)
        value_float = savefloat(value)

        if str(value_int) == str(value):
            return value_int

        if str(value_float) == str(value):
            return value_float
Esempio n. 10
0
def perfometer_apc_mod_pdu_modules(row, check_command, perf_data):
    value = int(utils.savefloat(perf_data[0][1]) * 100)
    return "%skw" % perf_data[0][1], perfometer_logarithmic(
        value, 500, 2, "#3366CC")
Esempio n. 11
0
def perfometer_el_inphase(row, check_command, perf_data):
    for data in perf_data:
        if data[0] == "power":
            power = utils.savefloat(data[1])
    return "%.0f W" % power, perfometer_linear(power, "#8050ff")
Esempio n. 12
0
 def cmp(self, r1, r2):
     v1 = utils.savefloat(get_perfdata_nth_value(r1, self._num - 1, True))
     v2 = utils.savefloat(get_perfdata_nth_value(r2, self._num - 1, True))
     return (v1 > v2) - (v1 < v2)