Forum Discussion
Wade_Miller_113
Nimbostratus
Mar 04, 2009MRTG for vip bandwidth and connections anyone?
!/bin/bash
This script will build an mrtg config to gather bandwidth and connections stats from a V9 LTM.
Wade wrote this on and around March 3, 2009.
Target=$1
Community=$2
Contact_email="someone@my.domain"
VIP_Names_OID=".1.3.6.1.4.1.3375.2.2.10.2.3.1.1"
VIP_Base_OID=".1.3.6.1.4.1.3375.2.2.10.2.3.1"
VIP_Names_OID="enterprises.3375.2.2.10.2.3.1.1"
VIP_Base_OID="enterprises.3375.2.2.10.2.3.1"
SNMPV3 stuff
UserName=`grep SecurityName ~/.snmp/snmp.conf | awk '{print $2}'`
AuthKey=`grep AuthType ~/.snmp/snmp.conf | awk '{print $2}'`
AuthProtocol=`grep AuthType ~/.snmp/snmp.conf | awk '{print $2}'`
AuthPass=`grep Passphrase ~/.snmp/snmp.conf | awk '{print $2}'`
VIP_Names=`snmpwalk -v 3 $Target $VIP_Names_OID |awk -F: '{print $3, $4}' |sed "s/^$VIP_Names_OID.//"|sed 's/"//g' | awk '{print $4, $2, $1}' | sed 's/ //g'`
VIP_Names=`snmpwalk -v 2c -c $Community $Target $VIP_Names_OID |awk -F: '{print $3, $4}' |sed "s/^$VIP_Names_OID.//"|sed 's/"//g' | awk '{print $4, $2, $1}' | sed 's/ //g'`
echo "WorkDir: /var/www/mrtg/$Target-vip/" >> $Target-vip-mrtg.cfg
echo "LogDir: /var/log/mrtg/" > $Target-vip-mrtg.cfg
echo "HtmlDir: /var/www/mrtg/" >> $Target-vip-mrtg.cfg
echo "ImageDir: /var/www/mrtg/images/" >> $Target-vip-mrtg.cfg
echo "IconDir: /var/www/mrtg/images/" >> $Target-vip-mrtg.cfg
echo "Forks: 4" >> $Target-vip-mrtg.cfg
echo "EnableSnmpV3: yes" >> $Target-vip-mrtg.cfg
for x in `echo $VIP_Names`
do
Name_OID=`echo $x | awk -F= '{print $2}'`
echo $Name_OID
Text_Name=`echo $x | awk -F= '{print $1}'`
Name=$Text_Name
echo $Name
Octets_In_OID="$VIP_Base_OID.7.$Name_OID"
snmpget -v 2c -c $Community $Target $Octets_In_OID
Octets_Out_OID="$VIP_Base_OID.9.$Name_OID"
snmpget -v 2c -c $Community $Target $Octets_Out_OID
Connections_OID="$VIP_Base_OID.12.$Name_OID"
snmpget -v 2c -c $Community $Target $Connections_OID
echo >> $Target-vip-mrtg.cfg
echo "Target[$Name]: $Octets_In_OID&$Octets_Out_OID:$Community@$Target:::::2" >> $Target-vip-mrtg.cfg
echo "MaxBytes[$Name]: 100000000" >> $Target-vip-mrtg.cfg
echo "AbsMax[$Name]: 100000000" >> $Target-vip-mrtg.cfg
echo "Options[$Name]: growright" >> $Target-vip-mrtg.cfg
echo "Title[$Name]: Bytes per second for Virtual Server $Name" >> $Target-vip-mrtg.cfg
echo "PageTop[$Name]: Bytes Per Second for $Name" >> $Target-vip-mrtg.cfg
echo " " >> $Target-vip-mrtg.cfg
echo " " >> $Target-vip-mrtg.cfg echo " System:$Target" >> $Target-vip-mrtg.cfg echo " Maintainer:$Contact_email" >> $Target-vip-mrtg.cfg echo " Object:VIP $Name - b/s " >> $Target-vip-mrtg.cfg echo " " >> $Target-vip-mrtg.cfg
echo "YLegend[$Name]: bytes/s" >> $Target-vip-mrtg.cfg
echo "ShortLegend[$Name]: bytes/s" >> $Target-vip-mrtg.cfg
echo "Legend1[$Name]: Bytes In" >> $Target-vip-mrtg.cfg
echo "Legend2[$Name]: Bytes Out" >> $Target-vip-mrtg.cfg
echo "LegendI[$Name]: In" >> $Target-vip-mrtg.cfg
echo "LegendO[$Name]: Out" >> $Target-vip-mrtg.cfg
echo >> $Target-vip-mrtg.cfg
echo >> $Target-vip-mrtg.cfg
echo "Target[$Name-conn]: $Connections_OID&$Connections_OID:$Community@$Target:::::2" >> $Target-vip-mrtg.cfg
echo "MaxBytes[$Name-conn]: 100000000" >> $Target-vip-mrtg.cfg
echo "AbsMax[$Name-conn]: 100000000" >> $Target-vip-mrtg.cfg
echo "Options[$Name-conn]: growright" >> $Target-vip-mrtg.cfg
echo "Options[$Name-conn]: growright,gauge" >> $Target-vip-mrtg.cfg
echo "Title[$Name-conn]: Connections for $Name" >> $Target-vip-mrtg.cfg
echo "PageTop[$Name-conn]: Connections for $Name" >> $Target-vip-mrtg.cfg
echo " " >> $Target-vip-mrtg.cfg
echo " " >> $Target-vip-mrtg.cfg echo " System:$Target" >> $Target-vip-mrtg.cfg echo " Maintainer:$Contact_email" >> $Target-vip-mrtg.cfg echo " Object:Pool $Name - Connections " >> $Target-vip-mrtg.cfg echo " " >> $Target-vip-mrtg.cfg
echo "YLegend[$Name-conn]: $Name Connections" >> $Target-vip-mrtg.cfg
echo "ShortLegend[$Name-conn]: Connections" >> $Target-vip-mrtg.cfg
echo >> $Target-vip-mrtg.cfg
echo >> $Target-vip-mrtg.cfg
done
- Deb_Allen_18Historic F5 Accountnice!
- Wade_Miller_113
Nimbostratus
sure. - johnko05_45751
Nimbostratus
I ran the script, however when I run mrtg against the config file the script created, I get these types of errors. Any ideas? Thanks in advance!
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects