def initHost(ip): #print('Scanning', ip) host = Host(ip) host.getInterfaces() if host.online == False: #print('Host with ip', ip, 'offline!') print(ip) host.hasBridge() return host
def checkZabbixAgainstArp(self): # When Zabbix and ARP think that an address is registered to a # different MAC address, that can be cause for alarm. #FIXME Use the ORM q = 'select zabhosts.mac as zabmac, zabhosts.ip, arp.mac as arpmac from ' +\ 'zabhosts, arp where zabhosts.mac is not null and zabhosts.ip is not '+\ 'null and zabhosts.ip = arp.ip and zabhosts.mac != arp.mac;' mismatches = self.execute(q) offline = [] unknown = [] differentLink = [] if mismatches: for mismatch in mismatches: #print(mismatch.ip) # Make a host, get the data from the host. host = Host(mismatch.ip) host.getInterfaces() if host.online: # See if the address is among its interfaces. if host.hasMac(mismatch.zabmac): differentLink.append(mismatch) else: print(mismatch.ip, 'mismatched for unknown reasons.') unknown.append(mismatch) #print(len(unknown)) else: offline.append(mismatch) else: print('There are no mismatched addresses.') print('There are', len(offline), 'offline hosts.') print('There are', len(differentLink), 'hosts that were simply', 'detected on a different link.') print('There are', len(unknown), 'undiagnosed hosts.') print('Undiagnosed hosts: %s' % unknown)
def initHost(ip): host = Host(ip) print(ip) host.getInterfaces() host.hasBridge() return host