CentOS 6.4安裝net-snmp服務

 

#!/bin/bash

#install net-snmp rpm
yum -y install net-snmp net-snmp-utils

#backup snmpd.conf
mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.orig

#create snmpd.conf
echo "rocommunity public" > /etc/snmp/snmpd.conf

#disable snmpd access log
echo -en "# snmpd command line options\nOPTIONS=\"-Lf /dev/null -p /var/run/snmpd.pid\"" > /etc/sysconfig/snmpd

#set snmpd start on boot
chkconfig snmpd on

#restart to apply new snmpd.conf 
service snmpd restart

 

bond0網卡SNMP ifSpeed/ifHighSpeed欄位數值顯示錯誤造成cacti繪圖異常解法

參考資料: http://forum.nedi.ch/index.php?topic=1323.0

 

bond0(2000M) = eth0(1000M) + eth1(1000M)

在ifSpeed應該是顯示2000000000(2000M)但是卻是顯示10000000(10M),造成cacti在繪圖時有10M上限的錯誤限制導致流量大時顯示破圖

[root@storage-sata.idc.local ~]# snmpwalk -c public -v 2c localhost ifSpeed
IF-MIB::ifSpeed.1 = Gauge32: 10000000
IF-MIB::ifSpeed.2 = Gauge32: 4294967295
IF-MIB::ifSpeed.3 = Gauge32: 4294967295
IF-MIB::ifSpeed.4 = Gauge32: 1000000000
IF-MIB::ifSpeed.5 = Gauge32: 100000000
IF-MIB::ifSpeed.6 = Gauge32: 1000000000
IF-MIB::ifSpeed.7 = Gauge32: 1000000000
IF-MIB::ifSpeed.8 = Gauge32: 100000000
IF-MIB::ifSpeed.9 = Gauge32: 100000000
IF-MIB::ifSpeed.10 = Gauge32: 10000000
IF-MIB::ifSpeed.11 = Gauge32: 0
[root@storage-sata.idc.local ~]# snmpwalk -c public -v 2c localhost ifDesc
IF-MIB::ifDescr.1 = STRING: lo
IF-MIB::ifDescr.2 = STRING: eth6
IF-MIB::ifDescr.3 = STRING: eth7
IF-MIB::ifDescr.4 = STRING: eth2
IF-MIB::ifDescr.5 = STRING: eth3
IF-MIB::ifDescr.6 = STRING: eth0
IF-MIB::ifDescr.7 = STRING: eth1
IF-MIB::ifDescr.8 = STRING: eth4
IF-MIB::ifDescr.9 = STRING: eth5
IF-MIB::ifDescr.10 = STRING: bond0
IF-MIB::ifDescr.11 = STRING: br0

 

修正的方式為編輯/etc/snmp/snmpd.conf加入下面這行

interface bond0 6 2000000000

執行service snmpd restart

[root@storage-sata.idc.local ~]# snmpwalk -c public -v 2c localhost ifSpeed
IF-MIB::ifSpeed.1 = Gauge32: 10000000
IF-MIB::ifSpeed.2 = Gauge32: 4294967295
IF-MIB::ifSpeed.3 = Gauge32: 4294967295
IF-MIB::ifSpeed.4 = Gauge32: 1000000000
IF-MIB::ifSpeed.5 = Gauge32: 100000000
IF-MIB::ifSpeed.6 = Gauge32: 1000000000
IF-MIB::ifSpeed.7 = Gauge32: 1000000000
IF-MIB::ifSpeed.8 = Gauge32: 100000000
IF-MIB::ifSpeed.9 = Gauge32: 100000000
IF-MIB::ifSpeed.10 = Gauge32: 2000000000
IF-MIB::ifSpeed.11 = Gauge32: 0

修正後cacti的圖表

bonding

 

 

 

 

OmniOS啟用net-snmp

參考來源:http://itnotepad.wordpress.com/2013/08/22/net-snmp-on-omnios/

 

建立並編輯/etc/net-snmp/snmp/snmpd.conf此檔案,加入下列內容

#提供本台設備的一些資訊
syscontact "flight@netos.net"
syslocation "DB8F F26"
#唯讀的community,可從任何地方存取
rocommunity public
#可讀可寫的community,僅可從本機存取
rwcommunity private 127.0.0.1
#修正10GbE網卡ifHighSpeed欄位抓取錯誤問題
interface ixgbe0 6 10000000000

啟用服務

svcadm enable net-snmp

重新啟動net-snmp

svcadm restart net-snmp

 

 

測試一

#!/bin/bash

#dynamic html
URL='http://chtos.net/web11.php'

if [ "$#" -eq 1 ];then
  URL=$1
fi

echo "Fetching $URL"
echo -e "Location\ttotal\tcode\tnamelookup\tconnect\tptrans\tredir\tstrans\ts_download"
curl --header 'Accept-Encoding: gzip,deflate,sdch' --no-keepalive -s --write-out '  Direct:\t%{time_total}\t%{http_code}\t%{time_namelookup}\t\t%{time_connect}\t%{time_pretransfer}\t%{time_redirect}\t%{time_starttransfer}\t%{size_download}\n' $URL -o 1.txt
curl --header 'Accept-Encoding: gzip,deflate,sdch' --no-keepalive -s --write-out 'NH Proxy:\t%{time_total}\t%{http_code}\t%{time_namelookup}\t\t%{time_connect}\t%{time_pretransfer}\t%{time_redirect}\t%{time_starttransfer}\t%{size_download}\n' $URL -o 2.txt --proxy 10.10.10.1:80
curl --header 'Accept-Encoding: gzip,deflate,sdch' --no-keepalive -s --write-out 'TP Proxy:\t%{time_total}\t%{http_code}\t%{time_namelookup}\t\t%{time_connect}\t%{time_pretransfer}\t%{time_redirect}\t%{time_starttransfer}\t%{size_download}\n' $URL -o 3.txt --proxy 20.20.20.2:80