日期:2014-05-16  浏览次数:20739 次

Linux上简单配置安装cacti(六)snmp再次安装
Linux上简单配置安装cacti(六)snmp再次安装

以前确认过机器上安装了snmp,但是这是redhat自带的,据说里面是没有snmpwalk,snmpget这些命令的,所以我这里要重新
编译安装NET-SNMP
官方网站
http://www.net-snmp.org/
下载文件
wget http://nchc.dl.sourceforge.net/project/net-snmp/net-snmp/5.5/net-snmp-5.5.tar.gz
解开压缩包
tar zxvf net-snmp-5.5.tar.gz
配置
./configure --prefix=/usr/local/net-snmp --enable-developer
中间有提示,一路回车下去
make
报错如下:
grep: /usr/lib/libbeecrypt.la: No such file or directory
/bin/sed: can't read /usr/lib/libbeecrypt.la: No such file or directory
libtool: link: `/usr/lib/libbeecrypt.la' is not a valid libtool archive
make[1]: *** [libnetsnmpmibs.la] 错误 1
make[1]: Leaving directory `/var/tmp/net-snmp-5.5/agent'
make: *** [subdirs] 错误 1
解决办法:
安装beecrypt
wget http://nchc.dl.sourceforge.net/sourceforge/beecrypt/beecrypt-4.1.2.tar.gz
tar zxvf beecrypt-4.1.2.tar.gz
./configure --prefix=/usr
make
make install

重新make,又报错了,报错如下:
/usr/bin/ld: cannot find -lelf
collect2: ld returned 1 exit status
make[1]: *** [libnetsnmpmibs.la] 错误 1
make[1]: Leaving directory `/var/tmp/net-snmp-5.5/agent'
make: *** [subdirs] 错误 1
解决办法:
ln -s libelf.so.1 /usr/lib/libelf.so

继续make,成功了:)
make install
安装成功。

链接过去
ln -s /usr/local/net-snmp/bin/* /usr/local/bin/

cp EXAMPLE.conf /usr/local/net-snmp/share/snmp/snmpd.conf

/usr/local/net-snmp/sbin/snmpd //启动SNMP服务

vi /etc/rc.d/rc.local
//在rc.local上加入一行/usr/local/net-snmp/sbin/snmpd,系统启动时启动SNMP服务

现在再回头看看cacti的错误
错误:/usr/local/bin/snmpwalk
错误:/usr/local/bin/snmpget
错误:/usr/local/bin/snmpbulkwalk
错误:/usr/local/bin/snmpgetnext
再次点开,这次就没有以上的错误啦。点Finish
输入用户名和密码admin/admin

登陆后点击graph图标,图没有出来。继续查找下原因,快要成功了:)
查看后台日志cacti里面的log/cacti.log,日志如下:
POLLER: Poller[0] Maximum runtime of 298 seconds exceeded. Exiting

点击控制面板console----->Data Sources
选择列表中的一个Localhost-Load Average
点击右上角的Turn Off Data Source Debug Mode
下面会出现对应的命令Data Source Debug
/usr/local/bin/rrdtool create \
/usr/local/apache2/htdocs/cacti/rra/localhost_load_1min_5.rrd \
--step 300 \
DS:load_1min:GAUGE:600:0:500 \
DS:load_5min:GAUGE:600:0:500 \
DS:load_15min:GAUGE:600:0:500 \
RRA:AVERAGE:0.5:1:600 \
RRA:AVERAGE:0.5:6:700 \
RRA:AVERAGE:0.5:24:775 \
RRA:AVERAGE:0.5:288:797 \
RRA:MAX:0.5:1:600 \
RRA:MAX:0.5:6:700 \
RRA:MAX:0.5:24:775 \
RRA:MAX:0.5:288:797 \

su cacti,执行该命令,报错如下:
ERROR: creating '/usr/local/apache2/htdocs/cacti/rra/localhost_load_1min_5.rrd': 权限不够
晕,前面不是赋予了权限了嘛,难道搞错了。再赋予一次。
chown -R cacti rra
chown -R cacti log
执行命令,OK了,检查一下目录rra,哈哈,已经有一个文件了。去看看图看。图有了,但是是否有正确的每5分钟采集一次
就要等等,等好几个5分钟再来看看了。等了一会儿,还是没有数据,唉,好事多磨啊,有图像了,又没有数据。。。。
检查snmp
snmpwalk -c public -v 2c 10.206.19.59 if 有很多信息返回
检查数据
rrdtool fetch localhost_mem_swap_4.rrd AVERAGE,返回的都是
1261452300: nan
1261452600: nan
文件更新信息
rrdtool lastupdate localhost_mem_swap_4.rrd --template,返回数据
users
1261535656: U
文件信息
rrdtool info localhost_users_6.rrd,返回信息:
filename = "localhost_users_6.rrd"
rrd_version = "0003"
step = 300
last_update = 1261535656
ds[users].type = "GAUGE"
ds[users].minimal_heartbeat = 600
ds[users].min = 0.0000000000e+00
ds[users].max = 5.0000000000e+02
ds[users].last_ds = "U"
ds[users].value = 0.0000000000e+00

网上搜索资料,可能是SNMP没有配置好
vi /usr/local/net-snmp/share/snmp/snmpd.conf
cp /etc/snmp/snmpd.conf /usr/local/net-snmp/share/snmp/snmpd.conf
重启snmp
/usr/local/net-snmp/sbin/snmpd

修改定时任务
[root@dev1 snmp]# crontab -e -u cacti
*/5 * * * * /usr/local/bin/php -q /usr/local/apache2/htdocs/cacti/poller.php > /var/log/poller.l