Re: Zabbix

Top Page
Attachments:
Message as email
+ (text/plain)
+ (text/html)
+ (text/plain)
Delete this message
Reply to this message
Author: Shawn Badger
Date:  
To: Main PLUG discussion list
Subject: Re: Zabbix
I use this script to generate a template for switch like devices.
It isn't elegant, but it does the job!
After you run it make sure output has .xml extension then just import the
file.
This template says for a "Template_Brocade_5300", so if you want to change
it to something else then just search and replace all the
"Template_Brocade_5300" strings with whatever you want to call it.

Good luck


#!/bin/sh
# script to build snmp config for Zabbix

echo "Please fill in the following"
read -p "SNMP Community string? " SNMP
read -p "How many ports? " COUNT
read -p "Port SNMP starting number? " ID
read -p "Output filename? " OUTPUT

PORT="00"
GPORT="00"
GCOUNT=$COUNT
GID=$ID

# create the base of the file
echo -en "<?xml version=\"1.0\"?>
<zabbix_export version=\"1.0\" date=\"21.04.10\" time=\"18.15\">
\t<hosts>
\t\t<host name=\"Template_Brocade_5300\">
\t\t\t<useip>1</useip>
\t\t\t<dns></dns>
\t\t\t<ip>0.0.0.0</ip>
\t\t\t<port>10050</port>
\t\t\t<status>3</status>
\t\t\t<groups>
\t\t\t\t<group>Templates</group>
\t\t\t</groups>
" > $OUTPUT

#Generate the items portion
# interface description, octets in, octets out, operational status and speed
echo -en "\t\t\t<items>
" >>$OUTPUT
while [ $PORT -lt $COUNT ] ; do
echo -en "\t\t\t\t<item type=\"1\" key=\"ifDescr.$(printf "%02.2d" $PORT)\"
value_type=\"1\">
\t\t\t\t\t<description>Port $(printf "%02.2d" $PORT)
description</description>
\t\t\t\t\t<ipmi_sensor></ipmi_sensor>
\t\t\t\t\t<delay>600</delay>
\t\t\t\t\t<history>35</history>
\t\t\t\t\t<trends>0</trends>
\t\t\t\t\t<status>0</status>
\t\t\t\t\t<units></units>
\t\t\t\t\t<multiplier>0</multiplier>
\t\t\t\t\t<delta>0</delta>
\t\t\t\t\t<formula>1</formula>
\t\t\t\t\t<lastlogsize>0</lastlogsize>
\t\t\t\t\t<logtimefmt></logtimefmt>
\t\t\t\t\t<delay_flex></delay_flex>
\t\t\t\t\t<params></params>
\t\t\t\t\t<trapper_hosts></trapper_hosts>
\t\t\t\t\t<snmp_community>$SNMP</snmp_community>
\t\t\t\t\t<snmp_oid>IF-MIB::ifDescr.$ID</snmp_oid>
\t\t\t\t\t<snmp_port>161</snmp_port>
\t\t\t\t\t<snmpv3_securityname></snmpv3_securityname>
\t\t\t\t\t<snmpv3_securitylevel>0</snmpv3_securitylevel>
\t\t\t\t\t<snmpv3_authpassphrase></snmpv3_authpassphrase>
\t\t\t\t\t<snmpv3_privpassphrase></snmpv3_privpassphrase>
\t\t\t\t\t<applications>
\t\t\t\t\t\t<application></application>
\t\t\t\t\t</applications>
\t\t\t\t</item>
\t\t\t\t<item type=\"1\" key=\"ifInOctets.$(printf "%02.2d" $PORT)\"
value_type=\"0\">
\t\t\t\t\t<description>Port $(printf "%02.2d" $PORT) data in</description>
\t\t\t\t\t<ipmi_sensor></ipmi_sensor>
\t\t\t\t\t<delay>60</delay>
\t\t\t\t\t<history>35</history>
\t\t\t\t\t<trends>365</trends>
\t\t\t\t\t<status>0</status>
\t\t\t\t\t<units>bps</units>
\t\t\t\t\t<multiplier>1</multiplier>
\t\t\t\t\t<delta>1</delta>
\t\t\t\t\t<formula>0.125</formula>
\t\t\t\t\t<lastlogsize>0</lastlogsize>
\t\t\t\t\t<logtimefmt></logtimefmt>
\t\t\t\t\t<delay_flex></delay_flex>
\t\t\t\t\t<params></params>
\t\t\t\t\t<trapper_hosts></trapper_hosts>
\t\t\t\t\t<snmp_community>$SNMP</snmp_community>
\t\t\t\t\t<snmp_oid>IF-MIB::ifInOctets.$ID</snmp_oid>
\t\t\t\t\t<snmp_port>161</snmp_port>
\t\t\t\t\t<snmpv3_securityname></snmpv3_securityname>
\t\t\t\t\t<snmpv3_securitylevel>0</snmpv3_securitylevel>
\t\t\t\t\t<snmpv3_authpassphrase></snmpv3_authpassphrase>
\t\t\t\t\t<snmpv3_privpassphrase></snmpv3_privpassphrase>
\t\t\t\t\t<applications>
\t\t\t\t\t\t<application></application>
\t\t\t\t\t</applications>
\t\t\t\t</item>
\t\t\t\t<item type=\"1\" key=\"ifOperStatus.$(printf "%02.2d" $PORT)\"
value_type=\"0\">
\t\t\t\t\t<description>Port $(printf "%02.2d" $PORT) operationsal
status</description>
\t\t\t\t\t<ipmi_sensor></ipmi_sensor>
\t\t\t\t\t<delay>60</delay>
\t\t\t\t\t<history>35</history>
\t\t\t\t\t<trends>365</trends>
\t\t\t\t\t<status>0</status>
\t\t\t\t\t<units></units>
\t\t\t\t\t<multiplier>0</multiplier>
\t\t\t\t\t<delta>0</delta>
\t\t\t\t\t<formula>1</formula>
\t\t\t\t\t<lastlogsize>0</lastlogsize>
\t\t\t\t\t<logtimefmt></logtimefmt>
\t\t\t\t\t<delay_flex></delay_flex>
\t\t\t\t\t<params></params>
\t\t\t\t\t<trapper_hosts></trapper_hosts>
\t\t\t\t\t<snmp_community>$SNMP</snmp_community>
\t\t\t\t\t<snmp_oid>IF-MIB::ifOperStatus.$ID</snmp_oid>
\t\t\t\t\t<snmp_port>161</snmp_port>
\t\t\t\t\t<snmpv3_securityname></snmpv3_securityname>
\t\t\t\t\t<snmpv3_securitylevel>0</snmpv3_securitylevel>
\t\t\t\t\t<snmpv3_authpassphrase></snmpv3_authpassphrase>
\t\t\t\t\t<snmpv3_privpassphrase></snmpv3_privpassphrase>
\t\t\t\t\t<applications>
\t\t\t\t\t\t<application></application>
\t\t\t\t\t</applications>
\t\t\t\t</item>
\t\t\t\t<item type=\"1\" key=\"ifOutOctets.$(printf "%02.2d" $PORT)\"
value_type=\"0\">
\t\t\t\t\t<description>Port $(printf "%02.2d" $PORT) data out</description>
\t\t\t\t\t<ipmi_sensor></ipmi_sensor>
\t\t\t\t\t<delay>60</delay>
\t\t\t\t\t<history>35</history>
\t\t\t\t\t<trends>365</trends>
\t\t\t\t\t<status>0</status>
\t\t\t\t\t<units>bps</units>
\t\t\t\t\t<multiplier>1</multiplier>
\t\t\t\t\t<delta>1</delta>
\t\t\t\t\t<formula>0.125</formula>
\t\t\t\t\t<lastlogsize>0</lastlogsize>
\t\t\t\t\t<logtimefmt></logtimefmt>
\t\t\t\t\t<delay_flex></delay_flex>
\t\t\t\t\t<params></params>
\t\t\t\t\t<trapper_hosts></trapper_hosts>
\t\t\t\t\t<snmp_community>$SNMP</snmp_community>
\t\t\t\t\t<snmp_oid>IF-MIB::ifOutOctets.$ID</snmp_oid>
\t\t\t\t\t<snmp_port>161</snmp_port>
\t\t\t\t\t<snmpv3_securityname></snmpv3_securityname>
\t\t\t\t\t<snmpv3_securitylevel>0</snmpv3_securitylevel>
\t\t\t\t\t<snmpv3_authpassphrase></snmpv3_authpassphrase>
\t\t\t\t\t<snmpv3_privpassphrase></snmpv3_privpassphrase>
\t\t\t\t\t<applications>
\t\t\t\t\t\t<application></application>
\t\t\t\t\t</applications>
\t\t\t\t</item>
\t\t\t\t<item type=\"1\" key=\"ifSpeed.$(printf "%02.2d" $PORT)\"
value_type=\"0\">
\t\t\t\t\t<description>Port $(printf "%02.2d" $PORT) speed</description>
\t\t\t\t\t<ipmi_sensor></ipmi_sensor>
\t\t\t\t\t<delay>600</delay>
\t\t\t\t\t<history>35</history>
\t\t\t\t\t<trends>365</trends>
\t\t\t\t\t<status>0</status>
\t\t\t\t\t<units>bps</units>
\t\t\t\t\t<multiplier>0</multiplier>
\t\t\t\t\t<delta>0</delta>
\t\t\t\t\t<formula>1</formula>
\t\t\t\t\t<lastlogsize>0</lastlogsize>
\t\t\t\t\t<logtimefmt></logtimefmt>
\t\t\t\t\t<delay_flex></delay_flex>
\t\t\t\t\t<params></params>
\t\t\t\t\t<trapper_hosts></trapper_hosts>
\t\t\t\t\t<snmp_community>$SNMP</snmp_community>
\t\t\t\t\t<snmp_oid>IF-MIB::ifSpeed.$ID</snmp_oid>
\t\t\t\t\t<snmp_port>161</snmp_port>
\t\t\t\t\t<snmpv3_securityname></snmpv3_securityname>
\t\t\t\t\t<snmpv3_securitylevel>0</snmpv3_securitylevel>
\t\t\t\t\t<snmpv3_authpassphrase></snmpv3_authpassphrase>
\t\t\t\t\t<snmpv3_privpassphrase></snmpv3_privpassphrase>
\t\t\t\t\t<applications>
\t\t\t\t\t\t<application></application>
\t\t\t\t\t</applications>
\t\t\t\t</item>
" >> $OUTPUT


#increment the counters
PORT=$[$PORT+1]
ID=$[$ID+1]

done

echo -en "\t\t\t</items>
" >>$OUTPUT

#Generate the graphs
#Interface octets in (Green) and octets out (Blue)

echo -en "\t\t\t<graphs>
" >>$OUTPUT
while [ $GPORT -lt $GCOUNT ] ; do
echo -en "\t\t\t\t<graph name=\"Interface utilization on Port $(printf
"%02.2d" $GPORT)\" width=\"900\" height=\"200\">
\t\t\t\t\t<yaxistype>0</yaxistype>
\t\t\t\t\t<show_work_period>1</show_work_period>
\t\t\t\t\t<show_triggers>1</show_triggers>
\t\t\t\t\t<graphtype>0</graphtype>
\t\t\t\t\t<yaxismin>0.0000</yaxismin>
\t\t\t\t\t<yaxismax>100.0000</yaxismax>
\t\t\t\t\t<show_legend>0</show_legend>
\t\t\t\t\t<show_3d>0</show_3d>
\t\t\t\t\t<percent_left>0.0000</percent_left>
\t\t\t\t\t<percent_right>0.0000</percent_right>
\t\t\t\t\t<graph_elements>
\t\t\t\t\t\t<graph_element item=\"Template_Brocade_5300:ifInOctets.$(printf
"%02.2d" $GPORT)\">
\t\t\t\t\t\t\t<drawtype>0</drawtype>
\t\t\t\t\t\t\t<sortorder>1</sortorder>
\t\t\t\t\t\t\t<color>009900</color>
\t\t\t\t\t\t\t<yaxisside>1</yaxisside>
\t\t\t\t\t\t\t<calc_fnc>2</calc_fnc>
\t\t\t\t\t\t\t<type>0</type>
\t\t\t\t\t\t\t<periods_cnt>5</periods_cnt>
\t\t\t\t\t\t</graph_element>
\t\t\t\t\t\t<graph_element item=\"Template_Brocade_5300:ifOutOctets.$(printf
"%02.2d" $GPORT)\">
\t\t\t\t\t\t\t<drawtype>0</drawtype>
\t\t\t\t\t\t\t<sortorder>2</sortorder>
\t\t\t\t\t\t\t<color>0000CC</color>
\t\t\t\t\t\t\t<yaxisside>1</yaxisside>
\t\t\t\t\t\t\t<calc_fnc>2</calc_fnc>
\t\t\t\t\t\t\t<type>0</type>
\t\t\t\t\t\t\t<periods_cnt>5</periods_cnt>
\t\t\t\t\t\t</graph_element>
\t\t\t\t\t</graph_elements>
\t\t\t\t</graph>
" >>$OUTPUT

#increment the counters
GPORT=$[$GPORT+1]
GID=$[$GID+1]

done

echo -en "\t\t\t</graphs>
" >>$OUTPUT


# create the end of the file
echo -en "\t\t</host>
\t</hosts>
\t<dependencies>
\t</dependencies>
</zabbix_export>
" >>$OUTPUT

echo "Done!"
exit
---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change your mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss