Removing Commas From IDs and Names
If you imported devices into Zenoss and ended up with devices with IDs and names that include commas, the page will not display in the UI, essentially breaking the device. To remove the commas, run the following Python script. Edit the password in the "baseUrl" line, and change the text after the @ symbol to reflect the FQDN and port number you use to access Zenoss. Note, you may also need to change HTTP to HTTPS if you require that.
This script may also be used to replace other text in the ID/Name fields, simply change the "newname = string.replace(d.id, ',', )" line. In this example it is searching for a comma and replacing it with <blank>.
from xmlrpclib import ServerProxy, ProtocolError import string baseUrl = 'http://admin:password@localhost:8080' for d in dmd.Devices.getSubDevices(): try: oldname = d.id newname = string.replace(d.id, ',', '') newname = string.replace(newname, '%2C', '') if newname != oldname: devpath = d.getPrimaryUrlPath() print "Renaming %s to %s" % (oldname, newname) url = '/'.join([baseUrl, devpath]) serv = ServerProxy( url ) serv.renameDevice(newname) sync() commit() sync() except: pass
Chmod the script and run it from your ZenHub server:
$ chmod 755 commafix.py $ zendmd --script=commafix.py