Beispiel #1
0
def main():

    setupLogging()

    args = parseArguments()
    job_id = args.jobid

    # Create the REST API client
    engine_client = EngineApiClient(args.host, BASE_URL, args.port)

    logging.info("Subscribing to job '" + job_id + "' for alerts")

    printHeader()

    while True:

        try:
            (http_status_code, response) = engine_client.alerts_longpoll(job_id,
                normalized_probability_threshold=args.normalizedProbability,
                anomaly_score_threshold=args.anomalyScore, timeout=args.timeout)
            if http_status_code != 200:
                print (http_status_code, json.dumps(response))
                break

            if response['timeout'] == False:
                printAlert(response)

        except KeyboardInterrupt:
            print "Exiting script..."