ZenDMD Tip - Set Titles via Reverse Lookup (PTR record)
From Zenoss Wiki
Revision as of 19:44, 17 July 2012 by 18.104.22.168 $7
The following code will iterate through all devices and perform a reverse lookup of the proper hostname. If the devices title attribute doesn't match it's set t the hostname returned by DNS.
for d in dmd.Devices.getSubDevices(): hostname = socket.gethostbyaddr(d.manageIp) if d.titleOrId() != hostname: print "Device IP: " + str(d.manageIp) print "Device current ID: " + str(d.titleOrId()) print "Device new ID: " + str(hostname) d.title = str(hostname)
Don't forget to commit().
Best, --Shane (Hackman238)