Example #1
0
def main():
    # See ex_create.py
#    api = HttpAPI(namespace='ns', apikey='apikey', hostname='localhost',
#        port=2000, timeout=20)
#    print api.retrieve_last(attributes={'type': 'A'}, limit=2)
#    print api.retrieve_last(attributes={'type': 'A'}, limit=3)
#    print api.retrieve_last(attributes={'type': ['A', 'B']}, limit=5)
    api = HttpAPI(namespace='windows', apikey='apikey', hostname='129.10.112.144',
        port=2000, timeout=20)
    print api.retrieve_last(attributes={'hostname': 'bulbasaur'})
Example #2
0
def get_linux_current():
    api = HttpAPI(namespace='linux', apikey='test',
        url=settings.FLAMONGO_ENDPOINT)
    newlist = []
    for m in linmachines:
        np = m['point']
        ret = api.retrieve_last(
            attributes={'hostname': '%s.ccs.neu.edu' % np['name'],
                'is_local': True})[0]
        # XXX: temporary fix.
        timestamp = datetime.fromtimestamp(ret['timestamp'] - 3600 * 4)
        newlist.append({'hostname': np['name'], 'longitude': np['longitude'],
            'latitude': np['latitude'], 'floor': np['floor'],
            # last event was a login (so it's in use)
            'inuse': (ret['event'] == 'login'),
            'timestamp': timestamp})
    return newlist
Example #3
0
def get_windows_current():
    api = HttpAPI(namespace='windows', apikey='test',
        url=settings.FLAMONGO_ENDPOINT)
    now = time.time()
    # pad with an extra minute
    then = now - 660
    newlist = []
    for m in winmachines:
        np = m['point']
        ret = api.retrieve_last(attributes={'hostname': np['name']})[0]
        # NOTE: The time below appears to be unreliable.
        # XXX: temporary fix.
        timestamp = datetime.fromtimestamp(ret['timestamp'] - 3600 * 4)
        newlist.append({'hostname': np['name'], 'longitude': np['longitude'],
            'latitude': np['latitude'], 'floor': np['floor'],
            'inuse': (ret['timestamp'] >= then), 'timestamp': timestamp})
    return newlist