Importing a list of devices with zenbatchload

So far, we've seen ways to build our device inventory through the web interface. In one case, we auto-discover everything and in the other case, we add the devices one at a time.

What if you already have a list of the SNMP capable devices by hostname or IP address? Wouldn't it be nice to import those devices. Zenoss Core can import a list of devices and attributes via the zenbatchload command.

In its simplest form, zebatchload will process a text file that lists one device per line. Here's a sample list of devices that I will call deviceList.txt:

	device01
	router02
	web03

Since zenbatchload is a Zenoss Core daemon, we need to run it as the zenoss user. Here are the commands:

su zenoss
<enter zenoss user's password>
zenbatchload deviceList.txt

The zenbatchload command will attempt to run SNMP on each device. If the device doesn't support SNMP, it won't be added to the inventory. The zenbatchload command accepts device classes, options, and zProperties in the text file. We'll talk about zProperties in the Chapter 3,

Let's modify deviceList.txt with some options:

	/Network/Router
	device01 comments ='Sample Device'
	/Server/Linux
	router2 zSnmpMonitorIgnore='true'
	web03 serialNumber='013478783'

The first thing we added was device class definitions. That's the /Network/Router and /Server/Linux lines. The second thing we added was a list of comma-separated options for each device. The option's value is enclosed in quotes.

When you specify the device class, zenbatchload will identify the class name and assign all subsequent devices to that class name until it detects a new class name. So, in our example, device01 is automatically assigned to/Network/Router, router2 and web3 are assigned to /Server/Linux. Classes are coming up in the next chapter.

If you want to see which options you can use within the zenbatchload text file, run the following command:

zenbatchload --show_options

Note

The zenbatchload import utility will not update devices that are already in the device inventory.

The zenbatchload file is a harness file for the $ZENHOME/Products/ZenModel/BatchDeviceLoader.py file. It's well documented and gives more usage examples.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.12.23