예제 #1
0
파일: autoscan.py 프로젝트: fossabot/ralph
def _autoscan_address(address):
    """Autoscans a single address on the worker."""

    try:
        ipaddress = IPAddress.objects.get(address=unicode(address))
    except IPAddress.DoesNotExist:
        ipaddress = None
    if ipaddress and ipaddress.is_buried:
        return
    pinged = ping(address)
    if pinged:
        if not ipaddress:
            ipaddress, created = IPAddress.objects.get_or_create(
                address=unicode(address),
            )
        ipaddress.http_family = get_http_family(ipaddress.address)
        (
            ipaddress.snmp_name,
            ipaddress.snmp_community,
            ipaddress.snmp_version,
        ) = get_snmp(ipaddress)
        ipaddress.dead_ping_count = 0
        ipaddress.save(update_last_seen=True)
    else:
        if ipaddress:
            ipaddress.dead_ping_count += 1
            if ipaddress.dead_ping_count >= settings.DEAD_PING_COUNT:
                # remove previous values only if this IP address already died
                ipaddress.http_family = None
                ipaddress.snmp_name = None
                ipaddress.snmp_community = None
                ipaddress.snmp_version = None
            ipaddress.save(update_last_seen=False)
예제 #2
0
파일: autoscan.py 프로젝트: smagowr/ralph
def _autoscan_address(address):
    """Autoscans a single address on the worker."""

    try:
        ipaddress = IPAddress.objects.get(address=address)
    except IPAddress.DoesNotExist:
        ipaddress = None
    if ipaddress and ipaddress.is_buried:
        return
    pinged = ping(address)
    if pinged:
        if not ipaddress:
            ipaddress, created = IPAddress.objects.get_or_create(
                address=address, )
        ipaddress.http_family = get_http_family(ipaddress.address)
        (
            ipaddress.snmp_name,
            ipaddress.snmp_community,
            ipaddress.snmp_version,
        ) = get_snmp(ipaddress)
        ipaddress.dead_ping_count = 0
        ipaddress.save(update_last_seen=True)
    else:
        if ipaddress:
            ipaddress.http_family = None
            ipaddress.snmp_name = None
            ipaddress.snmp_community = None
            ipaddress.snmp_version = None
            ipaddress.dead_ping_count += 1
            ipaddress.save(update_last_seen=False)
예제 #3
0
파일: autoscan.py 프로젝트: quamilek/ralph
def _autoscan_address(address):
    """Autoscans a single address on the worker."""

    try:
        ipaddress = IPAddress.objects.get(address=address)
    except IPAddress.DoesNotExist:
        ipaddress = None
    if ipaddress and ipaddress.is_buried:
        return
    pinged = ping(address)
    if pinged:
        if not ipaddress:
            ipaddress, created = IPAddress.objects.get_or_create(address=address)
        ipaddress.http_family = get_http_family(ipaddress.address)
        (ipaddress.snmp_name, ipaddress.snmp_community, ipaddress.snmp_version) = get_snmp(ipaddress)
        ipaddress.dead_ping_count = 0
        ipaddress.save(update_last_seen=True)
    else:
        if ipaddress:
            ipaddress.http_family = None
            ipaddress.snmp_name = None
            ipaddress.snmp_community = None
            ipaddress.snmp_version = None
            ipaddress.dead_ping_count += 1
            ipaddress.save(update_last_seen=False)