Beispiel #1
0
def main(parms):
    global PARAMS
    config = monitoring.checkconfig(parms)
    PARAMS = monitoring.loadconfig(config)
    websocket.enableTrace(True)
    ws = websocket.WebSocketApp('wss://stream.tutum.co/v1/events?token={0}&user={1}'.format(PARAMS.get('TOKEN'), PARAMS.get('USERNAME')),
                                on_message=on_message,
                                on_error=on_error,
                                on_close=on_close,
                                on_open=on_open)

    ws.run_forever()
def main(parms):
    global PARAMS
    config = monitoring.checkconfig(parms)
    PARAMS = monitoring.loadconfig(config)
    while True:
        session = requests.Session()
        headers = {"Authorization": PARAMS.get('APIAUTH')}
        r = session.get(PARAMS.get('TUTUMURL') + SERVICESURL, headers=headers)
        r.raise_for_status()
        services = r.json()
        servicesUrl = list_services_url(services, [])
        vhosts = get_vhosts(servicesUrl)
        if PARAMS.get("MANUAL_URL"):
            vhosts = vhosts + PARAMS.get("MANUAL_URL")
        vhosts_fails = check_status(vhosts)
        if vhosts_fails:
            monitoring.send_mail_vhost(vhosts_fails)
        time.sleep(180)