1004 linux系统监控软件cacti安装与配置<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
内容概要:
cacti基本安装
cacti插件安装
cacti NPC安装
linux/windows下snmp的安装与配置
cacti简单使用
关于Cacti相关可参考以下站点:
安装软件之前先要安装操作系统(这里以CentOS 5.2为例),搭建lamp环境(可以参考http://shawonline.blog.51cto.com/304978/162882其中至php安装结束部分)。
1.0 系统监控软件cacti
1.1 cacti基本安装
yum install -y net-snmp net-snmp-utils php-snmp
rpm -ivh rrdtool-<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />1.2.23-3.rhel3.i386.rpm
useradd cactiuser ;echo "cactiuser" |passwd cactiuser --stdin
cd /data/src
tar -xzvf cacti-0.8.7b.tar.gz
mv cacti-0.8.7b /var/www/html/cacti
chown -R cactiuser /var/www/html/cacti/rra
chown -R cactiuser /var/www/html/cacti/log
chgrp -R cactiuser /var/www/html/cacti
echo '*/5 * * * * cactiuser /usr/local/php/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1' >>/etc/crontab
mysql>create database cacti;
#这里先使用cactiuser作为用户名和密码,因为默认的配置文件里就是使用这个帐密。
#如果使用自定义的帐密,则需要更改以下两个配置文件里相应部分:
#/var/www/html/cacti/include/config.php
#/usr/local/spine//spine.conf(后面会介绍spine的安装)
mysql>grant all privileges on cacti.* to 'cactiuser'@'localhost' identified by 'cactiuser';
mysql>flush privileges;
mysql>exit;
less /var/www/html/cacti/cacti.sql |mysql -uroot cacti
cd /data/src
tar -xzvf cacti-spine-0.8.7a.tar.gz
cd cacti-spine-0.8.7a
./configure --with-mysql=/usr/local/mysql/
make
mkdir /usr/local/spine
cp spine spine.conf /usr/local/spine/
解决安装之后无法运行/usr/local/spine/spine问题,提示如下:
./spine: error while loading shared libraries: libmysqlclient_r.so.15: cannot open shared object file: No such file or directory
cp -p /usr/local/mysql/lib/libmysqlclient_r.so.15 /usr/lib/
默认的登录帐密为admin,进入设置界面后需要查看如果设置:
console
|-Configuration
|-Settings
|-Paths(根据自己安装的路径确认所有路径是否正确)
|-RRDTool Binary Path /usr/share/rrdtool/fonts/DejaVuSansMono-Roman.ttf
|-Spine Poller File Path /usr/local/spine/spine
记得点save保存呵!
poller
|- Poller Type spine
记得点save保存呵!
1.2 cacti插件安装
cp -rp /var/www/html/cacti /var/www/html/cacti.bak
1.安装cacti-plugin-arch
cd /data/src
tar -xzvf cacti-plugin-arch.tar.gz
cd cacti-plugin-arch
mysql -u root cacti < pa.sql #plugin management
cp ./cacti-plugin-0.8.7b-PA-v2.1.diff /var/www/html/cacti/
cd /var/www/html/cacti/
patch -p1 -N < cacti-plugin-0.8.7b-PA-v2.1.diff
注意: 此时需要修改/var/www/html/cacti/include/global.php, 否则会乱图
$config['url_path'] = '/cacti/';
2.安装settings,thold(thresholds),monitor
tar -xzvf settings-0.5.tar.gz
tar -xzvf thold-0.3.9.tar.gz
tar -xzvf monitor-0.8.2.tar.gz
cp -r settings thold monitor /var/www/html/cacti/plugins/
vi /var/www/html/cacti/include/global.php
$plugins = array();
$plugins[] = 'settings';
$plugins[] = 'thold';
$plugins[] = 'monitor';
http://ServerIP/cacti
|-console
|-Utilities
|-User Managerment
|-admin
|-Configure Thresholds
|-View Thresholds
|-View Monitoring
1.3 cacti NPC安装
个人觉得这个插件使用不太方便也没有多大用途,我是把cacti与nagios安装在一台服务器上,使用不同路径访问两个软件的,如果要安装的话可以按下面步骤操作。
1.安装nagios
后面会介绍nagios报警软件的安装与配置的。
2.安装NPC插件
前一节安装cacti插件时有一项plugin management,现在就需要使用到。
cd /data/src
tar -xzvf npc-2.0.0b.166.gz
cp -r npc /var/www/html/cacti/plugins/
http://cacti.monitor.com
|-console
|-Configuration
|-Plugin Management
|-Uninstalled
|-Install
|-Installed
|-Enable
1.4 snmp的安装与配置
1.4.1 linux下snmp的安装与配置
yum install -y net-snmp
下面是一个关于snmpd.conf的例子:
com2sec notConfigUser 192.168.0.119 community_name
#com2sec notConfigUser 192.168.0.120 community_name
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.25.1.1
access notConfigGroup "" any noauth exact all none none
view all included .1
说明:
192.168.0.119为安装监控软件的服务器(可以为多台)
community_name为自定义的团体名称
chkconfig –level 3 snmpd on
service snmpd start
1.4.2 windows下snmp的安装与配置
使用“添加或删除程序”里的“添加/删除windows组件”,选中“管理和监视工具”,点击详细信息,勾选“简单网络管理协议”,……,安装结束。
安装结束后需要进行一些配置:
开始-运行-services.msc打开服务管理控制台-SNMP Service属性设置如下:
确认常规选项下地启动类型为自动,重启服务即可生效。
1.5 cacti简单使用
经过上面的安装与配置已经完成cacti监控端与被监控端的基本设置,这样我们就可以使用cacti监控每台服务器。
1.我们可以到console-Settings-General做一些关于snmp的默认设置,如下图:
(我们的被监控机的snmp团体名均被设置为community_name,这样的话我们以后再增加每个节点的时候就不用再手动输入了呵。)
再到Poller下做一些设置,如下图:
2.新增一台被监控机
依次点击console-Devices-Add,相关信息可以参考下图:
点击create,页面左上角会返回一个关于snmp的信息,正常的正确的返回信息如下图:
3.这时我们可以把刚刚添加的设备添加到一个Graph Trees后可能到graphs大选项下看到被监控设备。
依次点击console-Graph Trees-Add-自定义一个Name(如:WebServers)-create-(Tree Items)Add-相关信息可以参考下图:
大约10分钟左右我们就可以在graphs下的WebServers里看到被监控机web_server001的相关状态了
转载于:https://blog.51cto.com/ppp1013/199675