Forum Discussion

Wade_Miller_113's avatar
Wade_Miller_113
Icon for Nimbostratus rankNimbostratus
Mar 04, 2009

MRTG 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 
 
  • 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!

     

     

    2009-05-29 09:31:40: ERROR: Target[midware_webservices_http-conn][_OUT_] 'enterp

     

    rises.3375.2.2.10.2.3.1.12.ltmVirtualServStatName.MidWare_WebServices_HTTP&enter

     

    prises.3375.2.2.10.2.3.1.12.ltmVirtualServStatName.MidWare_WebServices_HTTP:publ

     

    ic@10.17.40.12:::::2' (warn): Bareword "::::" refers to nonexistent package at (

     

    eval 255) line 1.