Created
January 27, 2012 14:55
-
-
Save manoot/1689146 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#========================================================= | |
# Avaya PRI UP/Down Check | |
# Travis Mathis - travis.mathis@gdit.com | |
# Version 1.1 | |
# Change Log: Moved Total Channels from seperate script 1/9/2012 | |
#========================================================= | |
# VARIABLES | |
act='0' | |
idl='0' | |
bus='0' | |
dis='0' | |
oos='0' | |
oid='1.3.6.1.4.1.6889.2.8.1.14.1.1.3' | |
z_server='10.51.154.80' | |
community='phoneguys' | |
ip=$1 | |
hostname=`echo $@ | cut -d " " -f 2-` | |
item_idl='Trunk_Idle' | |
item_act='Trunk_Active' | |
item_bus='Trunk_Busy' | |
item_dis='Trunk_Disconnected' | |
item_oos='Trunk_Out_Of_Service' | |
item_total='Trunk_Total' | |
# get_trunk_data() ---- do snmpwalk of TrunkServiceState OID and store as variable | |
get_trunk_data() { | |
snmpwalk -v1 -c $community $ip $oid | awk '{print $4}' | |
} | |
# sort through $TRUNK_DATA and count service states | |
while read -r line | |
do | |
case $line in | |
*idle*) | |
((idl++));; | |
*active*) | |
((act++));; | |
*disconnected*) | |
((dis++));; | |
*out-of-service*) | |
((oos++));; | |
*busy*) | |
((bus++));; | |
esac; | |
done < <(get_trunk_data) | |
# Send Data to Correct Host in Zabbix using zabbix_sender | |
total=$(($idl+$act+$dis+$oos+$bus)) | |
array=("$idl" "$act" "$bus" "$dis" "$oos" "$total") | |
array2=("$item_idl" "$item_act" "$item_bus" "$item_dis" "$item_oos" "$item_total") | |
array_pos='0' | |
item=("${array2["$array_pos"]}") | |
for z_value in "${array[@]}" | |
do | |
zabbix_sender -z $z_server -s "$hostname" -k $item -o $z_value | |
((array_pos++)) | |
item=("${array2["$array_pos"]}") | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment