Exemplo n.º 1
0
def get_capacity(session):
    response = session.get('https://mslnrcorpsan3/api/1.15/array?space=true', verify=False)
    results = json.loads(response.text)
    # create sensor result
    output = CustomSensorResult("PURE array capacity")
    for item in results:
        output.add_channel(name="Capacity", unit="Bytes", value=item['capacity'])
        output.add_channel(name="Snapshot", unit="Bytes", value=item['snapshots'])
        output.add_channel(name="Used space", unit="Bytes", value=item['total'])
        output.add_primary_channel(name="Used %", unit=ValueUnit.PERCENT, value= (item['total'] * 100 / item['capacity']), is_limit_mode=True, limit_max_warning=SIZE_WARNING_THRESHOLD, limit_warning_msg="High array disk space usage", limit_max_error=SIZE_ERROR_THRESHOLD, limit_error_msg="Very high array disk space usage")
        output.add_channel(name="Data reduction", is_float=True, value=item['data_reduction'])
    print(output.json_result)
Exemplo n.º 2
0
def get_performance(session):
    response = session.get('https://mslnrcorpsan3/api/1.15/array?action=monitor', verify=False)
    results = json.loads(response.text)
    # create sensor result
    output = CustomSensorResult("PURE array performance")
    for item in results:
        output.add_channel(name="Write bytes per second", unit="Bytes", value=item['output_per_sec'])
        output.add_channel(name="Read bytes per second", unit="Bytes", value=item['input_per_sec'])
        output.add_primary_channel(name="Queue depth", value=item['queue_depth'], is_limit_mode=True, limit_max_warning=60, limit_warning_msg="Large queue depth")
        output.add_channel(name="Write IOPS per second", unit="IOPS", value=item['writes_per_sec'])
        output.add_channel(name="Read IOPS per second", unit="IOPS", value=item['reads_per_sec'])
        output.add_channel(name="Write latency", unit="usec", value=item['usec_per_write_op'])
        output.add_channel(name="Read latency", unit="usec", value=item['usec_per_read_op'])
    print(output.json_result)
Exemplo n.º 3
0
json_default = {}

url_web_service = 'http://localhost:7778/caducidadEmpresaDiasAll'

try:
    url_contenido = urllib.request.urlopen(url_web_service)
    parametros = json.loads(url_contenido.read().decode("utf-8"))
except Exception as inst:
    parametros = json_default

# lTiempoCaducidad = parametros["valor"]["lCaducidad"]
# lNombreEmpresa = parametros["valor"]["nombre_empresa"]

# print("Nombre Empresa: ", lNombreEmpresa)
# print("Estos son los dias para que caduque el contrato: ", lTiempoCaducidad)

lParametros = parametros["valor"]

if __name__ == "__main__":
    # interpreta el primer parámetro de línea de comando como objeto json
    data = json.loads(sys.argv[1])
    # crear resultado del sensor
    result = CustomSensorResult("OK")
    # Añadir canal
    for parametros in lParametros:
        result.add_primary_channel(name=parametros["nombre_empresa"],
                                   unit="Count",
                                   value=parametros["lCaducidad"],
                                   is_float=False)
    print(result.json_result)
Exemplo n.º 4
0
import json
import psutil
import sys

from prtg.sensor.result import CustomSensorResult
from prtg.sensor.units import ValueUnit

if __name__ == "__main__":
    try:
        data = json.loads(sys.argv[1])
        csr = CustomSensorResult(text="This sensor runs on %s" % data["host"])
        csr.add_primary_channel(name="Percentage",
                                value=87,
                                unit=ValueUnit.PERCENT,
                                is_float=False,
                                is_limit_mode=True,
                                limit_min_error=10,
                                limit_max_error=90,
                                limit_error_msg="Percentage too high")
        csr.add_channel(name="Response Time",
                        value=4711,
                        unit=ValueUnit.TIMERESPONSE)
        print(csr.json_result)
    except Exception as e:
        csr = CustomSensorResult(text="Python Script execution error")
        csr.error = "Python Script execution error: %s" % str(e)
        print(csr.json_result)

# ------------------------------------------------------------
#
# Citation(s)
Exemplo n.º 5
0
        ps_status_list = []
        for ps_item in ps_items:
            ps_status = []
            ps_des = ''.join(ps_item.itertext())
            ps_status.append(ps_des)
            for sb_item in ps_item.itersiblings(preceding=True):
                ps_status.append(sb_item.text)
            ps_status_list.append(ps_status)
        num_ps_found = len(ps_status_list)

        csr = CustomSensorResult(
            text="This sensor runs on {}".format(data["host"]))
        csr.add_primary_channel(
            name="Node need {} Power supplies".format(num_ps_found),
            value=num_ps_found,
            unit=ValueUnit.CUSTOM,
            is_limit_mode=True,
            limit_min_error=num_ps_found,
            show_table=False,
            limit_error_msg="power module is missing")

        for channel in range(num_ps_found):
            power_supply_item = ps_status_list.pop()
            p_name = power_supply_item[0]
            if power_supply_item[1] == "True":
                insert_status = 1
            else:
                insert_status = 0
            if power_supply_item[2] == "True":
                alarm_status = 1
            else:
                alarm_status = 0
Exemplo n.º 6
0
        return int(return_message['emeter']['get_realtime']['power_mw']) / 1000


if __name__ == "__main__":
    try:
        data = json.loads(sys.argv[1])

        # Setup the handler class for the smartplug connection
        sp_handler = SmartPlugHandler(data["host"], 9999)
        # Sends request to get the wattage consumption of the plug
        wattage_consumption = sp_handler.get_wattage_consumption()
        # Sends request to get the relay state of the plug
        relay_state = sp_handler.get_relay_state()

        csr = CustomSensorResult(text="This sensor runs on %s" % data["host"])

        csr.add_primary_channel(name="Power Usage",
                                value=wattage_consumption,
                                unit="Watt",
                                is_float=True)

        csr.add_channel(name="Power State",
                        value=relay_state,
                        unit=ValueUnit.PERCENT)

        print(csr.json_result)
    except Exception as e:
        csr = CustomSensorResult(text="Python Script execution error")
        csr.error = "Python Script execution error: %s" % str(e)
        print(csr.json_result)
Exemplo n.º 7
0
        csr.add_channel(name="Lüftungsstufe",
                        value=sensor_data[SENSOR_FAN_SPEED_MODE],
                        unit="Stufe",
                        is_limit_mode=True,
                        limit_min_warning=-0.1,
                        limit_max_warning=3.1)

        csr.add_channel(name="Volumen Fortluftventilator",
                        value=sensor_data[SENSOR_FAN_EXHAUST_FLOW],
                        unit="m³/h",
                        is_limit_mode=True,
                        limit_min_warning=40)

        csr.add_primary_channel(name="Volumen Zuluftventilator",
                                value=sensor_data[SENSOR_FAN_SUPPLY_FLOW],
                                unit="m³/h",
                                is_limit_mode=True,
                                limit_min_warning=40)

        csr.add_channel(name="Drehzahl Fortluftventilator",
                        value=sensor_data[SENSOR_FAN_EXHAUST_SPEED],
                        unit="rpm")

        csr.add_channel(name="Drehzahl Zuluftventilator",
                        value=sensor_data[SENSOR_FAN_SUPPLY_SPEED],
                        is_limit_mode=True,
                        limit_min_error=1,
                        limit_error_msg="Ventilator steht!",
                        unit="rpm")

        csr.add_channel(name="Energieverbrauch Lüftung",