Example #1
0
def get_alerts(session):
    try:
        ''' the dictionary qsp contains the filters, sort statements and others like pageSize'''
        qsp = {}
        if options.sort is not None:
            if options.sort.upper() == "DESC":
                qsp['sort'] = '[{"property": "last", "direction": "DESC"}]'
            else:
                qsp['sort'] = '[{"property": "last", "direction": "ASC"}]'
        else:
            qsp['sort'] = '[{"property": "last", "direction": "ASC"}]'

        qsp['pageSize'] = 10000  # if set too small the number of returned results is incorrect and does not match the timeframe

        queryResult = client.SppAPI(session, '').get(
            path='/api/endeavour/alert/message', params=qsp)
        #queryResult = client.SppAPI(session, '').get(path='/api/endeavour/alert/message')
    except requests.exceptions.HTTPError as err:
        print("HTTP Error: {0}".format(err))
        spputil.get_error_details(err)
        print("exiting ...")
        sys.exit(1)
    except:
        print("other ERROR: ", traceback.print_exc())
        print("exiting ...")
        sys.exit(1)

    return queryResult
Example #2
0
def session_start():
    try:
        session = client.SppSession(options.host, options.username,
                                    options.password)
        session.login()
    except requests.exceptions.HTTPError as err:
        spputil.get_error_details(err)
        print("exiting ...")
        sys.exit(1)
    except:
        #print("other Exception: ", sys.exc_info()[0])
        print("other Exception: ", traceback.print_exc())
        print("exiting ...")
        sys.exit(1)

    return session
Example #3
0
def query_endpoint(path = None):

    try:
        myQueryResult = client.SppAPI(session, '').get(path=path)
    except requests.exceptions.HTTPError as err:
        print("HTTP Error: {0}".format(err))
        spputil.get_error_details(err)
        print("exiting ...")
        sys.exit(1)
        #return
    except:
        print("unknown ERROR: ", sys.exc_info()[0])
        print(err)
        print("exiting ...")
        sys.exit(1)

    return myQueryResult
Example #4
0







validate_input()

try:
    session = client.SppSession(options.host, options.username, options.password)
    session.login()
except requests.exceptions.HTTPError as err:
    #print("HTTP Error: {0}".format(err))
    spputil.get_error_details(err)
    print("exiting ...")
    sys.exit(1)
except:
    print("unknown ERROR: ", sys.exc_info()[0])
    print("exiting ...")
    sys.exit(1)


indent = " " * 2
print()
print(indent + "=" * 50)
print(indent + " SPP Server information:")
print(indent + "=" * 50 + "\n")

result_metrics = query_endpoint(path="ngp/metrics")