Exemplo n.º 1
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)
Exemplo n.º 2
0
def perfometer_check_mk_ibm_svc_host(row, check_command, perf_data):
    if len(perf_data) < 5:
        return "", ""

    active = int(perf_data[0][1])
    inactive = int(perf_data[1][1])
    degraded = int(perf_data[2][1])
    offline = int(perf_data[3][1])
    other = int(perf_data[4][1])
    total = active + inactive + degraded + offline + other
    data = []
    if active > 0:
        perc_active = active * 100.0 / total
        data.append((perc_active, "#008000"))
    if inactive > 0:
        perc_inactive = inactive * 100.0 / total
        data.append((perc_inactive, "#0000FF"))
    if degraded > 0:
        perc_degraded = degraded * 100.0 / total
        data.append((perc_degraded, "#F84"))
    if offline > 0:
        perc_offline = offline * 100.0 / total
        data.append((perc_offline, "#FF0000"))
    if other > 0:
        perc_other = other * 100.0 / total
        data.append((perc_other, "#000000"))
    if total == 0:
        data.append((100, get_themed_perfometer_bg_color()))
    return "%d active" % active, render_perfometer(data)
Exemplo n.º 3
0
def perfometer_bandwidth(in_traffic, out_traffic, in_bw, out_bw, unit="B"):
    traffic_multiplier = 1 if (unit == "B") else 8

    # if we do not have bandwith make logarithmic perf-o-meter
    if in_bw <= 0.0 or out_bw <= 0.0:
        MB = 1000000.0
        readable_in = number_human_readable(in_traffic * traffic_multiplier, 1,
                                            unit)
        readable_out = number_human_readable(out_traffic * traffic_multiplier,
                                             1, unit)
        text = "%s/s&nbsp;&nbsp;&nbsp;%s/s" % (readable_in, readable_out)
        return text, perfometer_logarithmic_dual(in_traffic, "#0e6",
                                                 out_traffic, "#2af", MB, 5)
    # if we have bandwidth
    txt, data = [], []
    for name, bytes_, bw, color in [("in", in_traffic, in_bw, "#0e6"),
                                    ("out", out_traffic, out_bw, "#2af")]:
        rrate = bytes_ / bw  # fixed: true-division
        drate = max(0.02, rrate**0.5**0.5)
        rperc = 100 * rrate
        dperc = 100 * drate
        a = (dperc / 2.0, color)
        b = (50 - dperc / 2.0, get_themed_perfometer_bg_color())

        txt.append("%.1f%%" % rperc)
        if name == "in":
            data.extend([b, a])  # white left, color right
        else:
            data.extend([a, b])  # color right, white left
    return " &nbsp; ".join(txt), render_perfometer(data)
Exemplo n.º 4
0
def perfometer_check_mk_ibm_svc_cache(row, check_command, perf_data):
    write_cache_pc = int(perf_data[0][1])
    total_cache_pc = int(perf_data[1][1])
    read_cache_pc = total_cache_pc - write_cache_pc
    free_cache_pc = 100 - total_cache_pc
    data = [(write_cache_pc, "#60e0a0"), (read_cache_pc, "#60a0e0"),
            (free_cache_pc, get_themed_perfometer_bg_color())]
    return "%d %% write, %d %% read" % (write_cache_pc, read_cache_pc), render_perfometer(data)
Exemplo n.º 5
0
def perfometer_hpux_snmp_cs_cpu(row, check_command, perf_data):
    data = [
        (float(perf_data[0][1]), "#60f020"),
        (float(perf_data[1][1]), "#ff6000"),
        (float(perf_data[2][1]), "#00d080"),
        (float(perf_data[3][1]), get_themed_perfometer_bg_color()),
    ]
    total = float(perf_data[0][1]) + float(perf_data[1][1]) + float(perf_data[2][1])
    return "%.0f%%" % total, render_perfometer(data)
Exemplo n.º 6
0
def perfometer_oracle_tablespaces(row, check_command, perf_data):
    current = float(perf_data[0][1])
    used = float(perf_data[1][1])
    max_ = float(perf_data[2][1])
    used_perc = used / max_ * 100  # fixed: true-division
    curr_perc = (current / max_ * 100) - used_perc  # fixed: true-division
    data = [
        (used_perc, "#f0b000"),
        (curr_perc, "#00ff80"),
        (100 - used_perc - curr_perc, "#80c0ff"),
    ]
    return "%.1f%%" % used_perc, render_perfometer(data)
Exemplo n.º 7
0
def perfometer_mssql_tablespaces(row, check_command, perf_data):
    reserved = float(perf_data[2][1])
    data = float(perf_data[3][1])
    indexes = float(perf_data[4][1])
    unused = float(perf_data[5][1])

    data_perc = data / reserved * 100  # fixed: true-division
    indexes_perc = indexes / reserved * 100  # fixed: true-division
    unused_perc = unused / reserved * 100  # fixed: true-division

    return ("%.1f%%" % (data_perc + indexes_perc),
            render_perfometer([(data_perc, "#80c0ff"), (indexes_perc, "#00ff80"),
                               (unused_perc, "#f0b000")]))
Exemplo n.º 8
0
def perfometer_check_mk_ntp(row, check_command, perf_data, unit="ms"):
    offset = float(perf_data[0][1])
    absoffset = abs(offset)
    crit = float(perf_data[0][4])
    max_ = crit * 2
    absoffset = min(absoffset, max_)
    rel = 50 * (absoffset / max_)  # fixed: true-division

    color = {0: "#0f8", 1: "#ff2", 2: "#f22", 3: "#fa2"}[row["service_state"]]
    if offset > 0:
        data = [(50, get_themed_perfometer_bg_color()), (rel, color),
                (50 - rel, get_themed_perfometer_bg_color())]
    else:
        data = [(50 - rel, get_themed_perfometer_bg_color()), (rel, color),
                (50, get_themed_perfometer_bg_color())]
    return "%.2f %s" % (offset, unit), render_perfometer(data)
Exemplo n.º 9
0
def perfometer_check_mk_mem_used(row, check_command, perf_data):
    ram_used = None

    for entry in perf_data:
        # Get total and used RAM
        if entry[0] == "ramused":
            ram_used = float(entry[1])  # mem.include
            ram_total = float(entry[6])  # mem.include
        elif entry[0] == "mem_used":
            ram_used = float(entry[1])  # mem.linux
        elif entry[0] == "mem_total":
            ram_total = float(entry[1])  # mem.linux

        # Get total and used SWAP
        elif entry[0] == "swapused":
            swap_used = float(entry[1])  # mem.include
            swap_total = float(entry[6])  # mem.include
        elif entry[0] == "swap_used":
            swap_used = float(entry[1])  # mem.linux
        elif entry[0] == "swap_total":
            swap_total = float(entry[1])  # mem.linux

    if not ram_used:
        return "", ""

    virt_total = ram_total + swap_total
    virt_used = ram_used + swap_used

    # paint used ram and swap
    ram_color, swap_color = "#80ff40", "#008030"

    data = [
        (ram_used * 100.0 / virt_total, ram_color),
        (swap_used * 100.0 / virt_total, swap_color),
    ]

    # used virtual memory < ram => show free ram and free total virtual memory
    if virt_used < ram_total:
        data.append(((ram_total - virt_used) * 100.0 / virt_total,
                     get_themed_perfometer_bg_color()))
        data.append(((virt_total - ram_total) * 100.0 / virt_total, "#ccc"))
    # usage exceeds ram => show only free virtual memory
    else:
        data.append((100 * (virt_total - virt_used), "#ccc"))
    return "%d%%" % (100 * (virt_used / ram_total)), render_perfometer(
        data)  # fixed: true-division
Exemplo n.º 10
0
def perfometer_esx_vsphere_datastores(row, check_command, perf_data):
    used_mb = perf_data[0][1]
    maxx = perf_data[0][-1]
    # perf data might be incomplete, if trending perfdata is off...
    uncommitted_mb = 0
    for entry in perf_data:
        if entry[0] == "uncommitted":
            uncommitted_mb = entry[1]
            break

    perc_used = 100 * (float(used_mb) / float(maxx))
    perc_uncommitted = 100 * (float(uncommitted_mb) / float(maxx))
    perc_totally_free = 100 - perc_used - perc_uncommitted

    if perc_used + perc_uncommitted <= 100:
        # Regular handling, no overcommitt
        data = [
            (perc_used, "#00ffc6"),
            (perc_uncommitted, "#eeccff"),
            (perc_totally_free, get_themed_perfometer_bg_color()),
        ]
    else:
        # Visualize overcommitted space by scaling to total overcommittment value
        # and drawing the capacity as red line in the perfometer
        total = perc_used + perc_uncommitted
        perc_used_bar = perc_used * 100.0 / total
        perc_free = (100 - perc_used) * 100.0 / total
        data = [
            (perc_used_bar, "#00ffc6"),
            (perc_free, "#eeccff"),
            (1, "red"),  # This line visualizes the capacity
            (perc_uncommitted - perc_free, "#eeccff"),
        ]

    legend = "%0.2f%%" % perc_used
    if uncommitted_mb:
        legend += " (+%0.2f%%)" % perc_uncommitted
    return legend, render_perfometer(data)
Exemplo n.º 11
0
def perfometer_mssql_counters_cache_hits(row, check_command, perf_data):
    perc = float(perf_data[0][1])
    data = [(perc, "#69EA96"), (100 - perc, get_themed_perfometer_bg_color())]
    return "%.1f%%" % perc, render_perfometer(data)