Ejemplo n.º 1
0
def poll_osinfo(hostname):
    '''
    Create only one entry for any no. of polls
    '''
    hostname_obj, fetcho = fetchcli_wrapper(hostname)
    hostname_obj.save()
    d = fetcho.get_osinfo()
    osdevicename = d['osdevicename']
    osplatform = d['osplatform']
    ostime = d['ostime']
    osuptime = d['osuptime']
    if len(OSInfo.objects.filter(hostname=hostname_obj)) == 0:
        o = OSInfo(hostname=hostname_obj,
                   polling_timestamp=time.time(),
                   osdevicename=osdevicename,
                   osplatform=osplatform,
                   ostime=ostime,
                   osuptime=osuptime)
    else:
        o = OSInfo.objects.get(hostname=hostname_obj)
        o.polling_timestamp = time.time()
        o.osdevicename = osdevicename
        o.osplatform = osplatform
        o.ostime = ostime
        o.osuptime = osuptime
    o.save()
Ejemplo n.º 2
0
def poll_osinfo(hostname):
    """
    Create only one entry for any no. of polls
    """
    hostname_obj, fetcho = fetchcli_wrapper(hostname)
    hostname_obj.save()
    d = fetcho.get_osinfo()
    osdevicename = d["osdevicename"]
    osplatform = d["osplatform"]
    ostime = d["ostime"]
    osuptime = d["osuptime"]
    if len(OSInfo.objects.filter(hostname=hostname_obj)) == 0:
        o = OSInfo(
            hostname=hostname_obj,
            polling_timestamp=time.time(),
            osdevicename=osdevicename,
            osplatform=osplatform,
            ostime=ostime,
            osuptime=osuptime,
        )
    else:
        o = OSInfo.objects.get(hostname=hostname_obj)
        o.polling_timestamp = time.time()
        o.osdevicename = osdevicename
        o.osplatform = osplatform
        o.ostime = ostime
        o.osuptime = osuptime
    o.save()
Ejemplo n.º 3
0
def poll_memstats(hostname):
    '''
    Create new entry for every poll
    '''
    hostname_obj, fetcho = fetchcli_wrapper(hostname)
    hostname_obj.save()
    d = fetcho.get_memstats()
    o = MemStats(hostname=hostname_obj, polling_timestamp=time.time(), **d)
    o.save()
Ejemplo n.º 4
0
def poll_memstats(hostname):
    '''
    Create new entry for every poll
    '''
    hostname_obj, fetcho = fetchcli_wrapper(hostname)
    hostname_obj.save()
    d = fetcho.get_memstats()
    o = MemStats(hostname=hostname_obj, polling_timestamp=time.time(), **d)
    o.save()
Ejemplo n.º 5
0
def poll_cpustats(hostname):
    """
    Create new entry for every poll
    """
    hostname_obj, fetcho = fetchcli_wrapper(hostname)
    hostname_obj.save()
    d = fetcho.get_cpustats()
    o = CpuStats(hostname=hostname_obj, polling_timestamp=time.time(), **d)
    o.save()
Ejemplo n.º 6
0
def poll_dirstats(hostname):
    """
    Create new entry for every poll
    """
    hostname_obj, fetcho = fetchcli_wrapper(hostname)
    hostname_obj.save()
    list_of_modules = fetcho.get_dirstats()
    timestamp = time.time()  # Using one common timestamp for one query to device
    for d in list_of_modules:
        o = DirStats(hostname=hostname_obj, polling_timestamp=timestamp, **d)
        o.save()
Ejemplo n.º 7
0
def poll_dirstats(hostname):
    '''
    Create new entry for every poll
    '''
    hostname_obj, fetcho = fetchcli_wrapper(hostname)
    hostname_obj.save()
    list_of_modules = fetcho.get_dirstats()
    timestamp = time.time(
    )  # Using one common timestamp for one query to device
    for d in list_of_modules:
        o = DirStats(hostname=hostname_obj, polling_timestamp=timestamp, **d)
        o.save()
Ejemplo n.º 8
0
def _poll_intstats(hostname):
    """
    This is done in order to allow polling of intstats
    periodically for all hostnames
    """
    hostname_obj, fetcho = fetchcli_wrapper(hostname)
    hostname_obj.save()
    list_of_ints = fetcho.get_intstats()
    timestamp = time.time()  # Using one common timestamp for one query to device
    for d in list_of_ints:
        o = InterfacesStats(hostname=hostname_obj, polling_timestamp=timestamp, **d)
        o.save()
Ejemplo n.º 9
0
def _poll_intstats(hostname):
    '''
    This is done in order to allow polling of intstats
    periodically for all hostnames
    '''
    hostname_obj, fetcho = fetchcli_wrapper(hostname)
    hostname_obj.save()
    list_of_ints = fetcho.get_intstats()
    timestamp = time.time(
    )  # Using one common timestamp for one query to device
    for d in list_of_ints:
        o = InterfacesStats(hostname=hostname_obj,
                            polling_timestamp=timestamp,
                            **d)
        o.save()
Ejemplo n.º 10
0
def poll_healthinfo(hostname):
    '''
    Try connecting to the device and do initial health check
    Save hostname entry in HostNames table
    
    @param hostname: hostname being submitted by post request to add a new device by user
    '''
    # The provided input has already been saved by form submission LoginForm.save()
    # Updating the entry now...
    hostname_obj, fetcho = fetchcli_wrapper(hostname)
    hostname_obj.is_healthy = fetcho.is_healthy
    hostname_obj.is_online = fetcho.is_online
    hostname_obj.os_type = fetcho.sw_version
    hostname_obj.error_online = fetcho.error_online
    hostname_obj.health_statuses = fetcho.health_statuses
    hostname_obj.save()
Ejemplo n.º 11
0
def poll_healthinfo(hostname):
    '''
    Try connecting to the device and do initial health check
    Save hostname entry in HostNames table
    
    @param hostname: hostname being submitted by post request to add a new device by user
    '''
    # The provided input has already been saved by form submission LoginForm.save()
    # Updating the entry now...
    hostname_obj, fetcho = fetchcli_wrapper(hostname)
    hostname_obj.is_healthy = fetcho.is_healthy
    hostname_obj.is_online = fetcho.is_online
    hostname_obj.os_type = fetcho.sw_version
    hostname_obj.error_online = fetcho.error_online
    hostname_obj.health_statuses = fetcho.health_statuses
    hostname_obj.save()