Batch configuration of zabbix items using import functionality
Posted on September 23rd, 2010
Zabbix import functionality let you a possibility of configuring large number if items at once. This may be useful for example in the case when you need to introduce number of changes but dont want to do that manually because of 1) this may be very time consuming and 2) human error prone. So, we will focus on automated creation of xml import file for zabbix. In our example we will create network interface traffic items.
First, please ensure that you have a database backup. If you make a mistake, you can destroy your installation quick. If possible, create second “test” zabbix database with just a mysql db and apache php frontend. It is not so hard even using modern laptop hardware. For example, I created second test zabbix installation in minutes using openSUSE linux and FS U9210 laptop and I’m using it when I need to test mass configuration changes to avoid database restore procedures if things goes wrong.
Ok, lets do some preparatory things, next we do some quick and dirty scripting and finally review and import resulted xml file.
First, at every server you need to monitor network traffic for we run the command to gather interface names, so that we can use these names when naming zabbix items keys later on. This command gives you a list of network interface names in one file, one name per line. We rely on name and format of that simple txt file later when creating shell script to parse number of these files for xml file generation. In the example we are using Solaris OS.
/sbin/ifconfig -a | grep UP \ | awk '{print $1}' | awk -F: '{print $1}' \ | uniq | grep -v lo0 > $HOSTNAME.txt
Ensure that every file has a list of network interfaces you want to monitor one per line.
For every server we create $HOSTNAME.txt file and collect them in one place. Next we create a script for parsing these files and generate xml. Please look at http://www.akamit.com/zabbix/imports and take a look at make_xml.sh. it supposed to be run from the same directory where .txt files resides. After you run the script, you get import.xml file, which you import into zabbix using Configuration -> Import/Export, then selecting Import from drop-down meny in the right topmost corner of the screen, then selecting xml file and pressing Import button. The hosts you have in import.xml will go to “Imported Hosts” group after import.
After you have tested the import on the test system, you do that in a production.
Filed under Configuration, Zabbix | No Comments »
Zabbix configuration helpers
Posted on September 16th, 2010
Sometimes we need to monitor some items using SNMP, but SNMP OIDs of the item is system dependent and vary from system to system, for example indexes of network interfaces and disk units. If you need to configure 1 or 2 systems, you can determine the OIDs by hand by snmp walking OID tree. But when you need to do that for large number of hosts, you need some helper scripts to calculate correct SNMP OIDs values for you.
These example helpers were useful when configuring number of items for Zabbix NMS.
1. Determine SNMP OIDs for network interfaces
2. Determine SNMP OIDs for CPU monitoring in Windows.
3. Determing SNMP OIDs for storage devices
Each helper is a little perl program, that has a built in usage help, you need to run it with -h option.
Filed under Configuration, Zabbix | No Comments »