1) Determine if the IP exists in Zabbix
Ideas: 1) Use User.login to get authID2) using Hostinterface.get to obtain the host HostID (if using the hostname, you can use Host.get to get HostID) 3) main function implementation: if __name__ == "__main__": file = raw_input ("Please enter file name:") fp = open (file) hostname_list = fp.readlines () fp.close () hostids = [] j = 0 if os.path.exists (' Error_ip.txt '): os.remove (' Error_ip.txt ') if os.path.exists (' Correct_ip.txt '): os.remove (' Correct_ip.txT ') for i in hostname_ List: hostname = i.strip (). Split (' ') [0] hostids.append (Host_ Get (hostname)) if hostids[j] == None: print hostids[j] fp1 = open (' Error_ip.txt ', ' a ') fp1.write (i) fp1.close () else: print hostids[j] fp2 = open (' Correct_ip.txt ', ' a ') fp2.write (i) fp2.close () j = j + 1
"Python Small example" small example to pick up memories