whosonline/netcheck.py
async def netcheck_loop(network):
    '''
    ASYNC VERSION of netcheck main
    Main function of netcheck module called from executable
    '''

    # import logfacility
    # LOGGER = logfacility.build_logger()

    # save results to show notifications if something changes
    results = {}

    # set up network object and build ip strings from it using get_ips filter
    network_obj = ipaddress.ip_network(network, strict=True)
    ip_addresses = [str(address_obj) for address_obj in get_ips(network_obj)]

    # get the network device responsible for given network
    netdevice = get_netdevice(network.split('/')[0])  # cut off cidr netmask

    # get local hostname to add to OMIT_HOSTS list
    local_hostname = socket.gethostname()
    OMIT_HOSTS.append(local_hostname)

    # abort if not device can be found
    assert netdevice, "Unable to find network device belonging to network %s" % network
    print('Device associated to network %s : %s' % (network, netdevice))

    # main loop
    while True:
        for ip_str in ip_addresses:
            hostname = get_hostname(ip_str)
            if hostname and hostname not in OMIT_HOSTS:
                last_result = results.get(hostname)
                ping_result = arping(ip_str, netdevice)  # or ping(hostname)
                results[hostname] = ping_result
                print('Host %s online: %s' % (hostname, ping_result))
                await asyncio.sleep(2)

    ASYNC VERSION of netcheck main
    Main function of netcheck module called from executable
    
ASYNC VERSION of netcheck main
Main function of netcheck module called from executable
ASYNC VERSION of netcheck main Main function of netcheck module called from executable
async def netcheck_loop(network):
    results = {}
    network_obj = ipaddress.ip_network(network, strict=True)
    ip_addresses = [str(address_obj) for address_obj in get_ips(network_obj)]
    netdevice = get_netdevice(network.split('/')[0])  
    local_hostname = socket.gethostname()
    OMIT_HOSTS.append(local_hostname)
    assert netdevice, "Unable to find network device belonging to network %s" % network
    print('Device associated to network %s : %s' % (network, netdevice))
    while True:
        for ip_str in ip_addresses:
            hostname = get_hostname(ip_str)
            if hostname and hostname not in OMIT_HOSTS:
                last_result = results.get(hostname)
                ping_result = arping(ip_str, netdevice)  
                results[hostname] = ping_result
                print('Host %s online: %s' % (hostname, ping_result))
                await asyncio.sleep(2)
async def netcheck_loop ( network ) : results = { } network_obj = ipaddress . ip_network ( network , strict = True ) ip_addresses = [ str ( address_obj ) for address_obj in get_ips ( network_obj ) ] netdevice = get_netdevice ( network . split ( '/' ) [ 0 ] ) local_hostname = socket . gethostname ( ) OMIT_HOSTS . append ( local_hostname ) assert netdevice , "Unable to find network device belonging to network %s" % network print ( 'Device associated to network %s : %s' % ( network , netdevice ) ) while True : for ip_str in ip_addresses : hostname = get_hostname ( ip_str ) if hostname and hostname not in OMIT_HOSTS : last_result = results . get ( hostname ) ping_result = arping ( ip_str , netdevice ) results [ hostname ] = ping_result print ( 'Host %s online: %s' % ( hostname , ping_result ) ) await asyncio . sleep ( 2 )
ASYNC VERSION of netcheck main
Main function of netcheck module called from executable
ASYNC VERSION of netcheck main Main function of netcheck module called from executable
'''
    ASYNC VERSION of netcheck main
    Main function of netcheck module called from executable
    ''' # import logfacility # LOGGER = logfacility.build_logger() # save results to show notifications if something changes # set up network object and build ip strings from it using get_ips filter # get the network device responsible for given network # cut off cidr netmask # get local hostname to add to OMIT_HOSTS list # abort if not device can be found # main loop # or ping(hostname)
network