FreeBSD下搭建cacti环境,所有准备都完成了,但就是网卡流量图出不来,于是就在console->settings->General中把Poller Logging Level改成DEBUG模式,然后查看了一下日志,发现如下信息。
01/13/2010 10:45:01 AM - CMDPHP: Poller[0] Host[1] DS[8] SNMP: v2: 127.0.0.1, dsname: traffic_out, oid: .1.3.6.1.2.1.31.1.1.1.10.1, output: U 01/13/2010 10:45:01 AM - CMDPHP: Poller[0] Host[1] DS[8] WARNING: Result from SNMP not valid. Partial Result: U 01/13/2010 10:45:01 AM - CMDPHP: Poller[0] Host[1] DS[8] SNMP: v2: 127.0.0.1, dsname: traffic_in, oid: .1.3.6.1.2.1.31.1.1.1.6.1, output: U 01/13/2010 10:45:01 AM - CMDPHP: Poller[0] Host[1] DS[8] WARNING: Result from SNMP not valid. Partial Result: U
于是登陆到服务器上手动执行了snmpwalk命令
test# snmpwalk -v 2c -c public localhost .1.3.6.1.2.1.31.1.1.1.10.1 IF-MIB::ifHCOutOctets.1 = No Such Object available on this agent at this OID test# snmpwalk -v 2c -c public localhost .1.3.6.1.2.1.31.1.1.1.6.1 IF-MIB::ifHCInOctets.1 = No Such Object available on this agent at this OID
然后在网上搜了一下,发现是Freebsd默认安装的net-snmp就不支持Counter64,于是在网上找了一下,解决办法如下
cd /usr/ports/net-mgmt/net-snmp/
编辑Makefile文件
vi Makefile
在CONFIGURE_ARGS内容后加入如下内容
–with-mib-modules=if-mib –enable-mfd-rewrites
修改后的部分内容如下
CONFIGURE_ARGS+=–enable-shared –enable-internal-md5
–with-mib-modules=”${_NET_SNMP_MIB_MODULES}”
–with-default-snmp-version=”${DEFAULT_SNMP_VERSION}”
–with-sys-contact=”${NET_SNMP_SYS_CONTACT}”
–with-sys-location=”${NET_SNMP_SYS_LOCATION}”
–with-logfile=”${NET_SNMP_LOGFILE}”
–with-persistent-directory=”${NET_SNMP_PERSISTENTDIR}”
–with-gnu-ld –with-libwrap –with-libs=”-lm -lkvm -ldevstat”
–with-mib-modules=if-mib –enable-mfd-rewrites
然后重新编译snmp
make
make deinstall # 只有在你已经装过snmp的时候执行此条
make reinstlal # 如果还没有装过snmp就执行此条
make clean
注意:如果执行make deinstall的时候提示由于关联文件无法执行,如下
test# make deinstall
===> Deinstalling for net-mgmt/net-snmp
===> Deinstalling net-snmp-5.4.2.1_6
pkg_delete: package ‘net-snmp-5.4.2.1_6’ is required by these other packages
and may not be deinstalled (but I’ll delete it anyway):
php5-snmp-5.2.12
cacti-0.8.7e4
可以直接执行make reinstall进行安装
安装完成后就可以重启snmp服务了
/usr/local/etc/rc.d/snmpd restart
查看Counter64是否被激活
snmpwalk -v 2c -c public localhost .1.3.6.1.2.1.31.1.1 | grep Counter64
如果一切正常的话,可以看到如下内容:
IF-MIB::ifHCInOctets.1 = Counter64: 1680605
IF-MIB::ifHCInOctets.2 = Counter64: 0
IF-MIB::ifHCInOctets.3 = Counter64: 735920
IF-MIB::ifHCInOctets.4 = Counter64: 0
IF-MIB::ifHCInUcastPkts.1 = Counter64: 15124
IF-MIB::ifHCInUcastPkts.2 = Counter64: 0
IF-MIB::ifHCInUcastPkts.3 = Counter64: 8446
IF-MIB::ifHCInUcastPkts.4 = Counter64: 0
IF-MIB::ifHCInMulticastPkts.1 = Counter64: 75
IF-MIB::ifHCInMulticastPkts.2 = Counter64: 0
IF-MIB::ifHCInMulticastPkts.3 = Counter64: 0
IF-MIB::ifHCInMulticastPkts.4 = Counter64: 0
IF-MIB::ifHCInBroadcastPkts.1 = Counter64: 0
IF-MIB::ifHCInBroadcastPkts.2 = Counter64: 0
IF-MIB::ifHCInBroadcastPkts.3 = Counter64: 0
IF-MIB::ifHCInBroadcastPkts.4 = Counter64: 0
IF-MIB::ifHCOutOctets.1 = Counter64: 11440579
IF-MIB::ifHCOutOctets.2 = Counter64: 0
IF-MIB::ifHCOutOctets.3 = Counter64: 735920
IF-MIB::ifHCOutOctets.4 = Counter64: 0
IF-MIB::ifHCOutUcastPkts.1 = Counter64: 19577
IF-MIB::ifHCOutUcastPkts.2 = Counter64: 0
IF-MIB::ifHCOutUcastPkts.3 = Counter64: 8446
IF-MIB::ifHCOutUcastPkts.4 = Counter64: 0
IF-MIB::ifHCOutMulticastPkts.1 = Counter64: 0
IF-MIB::ifHCOutMulticastPkts.2 = Counter64: 0
IF-MIB::ifHCOutMulticastPkts.3 = Counter64: 0
IF-MIB::ifHCOutMulticastPkts.4 = Counter64: 0
IF-MIB::ifHCOutBroadcastPkts.1 = Counter64: 0
IF-MIB::ifHCOutBroadcastPkts.2 = Counter64: 0
IF-MIB::ifHCOutBroadcastPkts.3 = Counter64: 0
IF-MIB::ifHCOutBroadcastPkts.4 = Counter64: 0
重装snmp后,cacti的图像就可以正常显示出来了
转载请注明:爱开源 » FreeBSD下开启Counter64的支持