rhel5上配置cacti监控
1.安装所需要的包
a.zlib-1.2.3.tar.gz
b.libpng
c.freetype
d.Fontconfig
e.gd
f.libjpeg
g.cgilib-0.5.tar.gz
cd cgilib-0.5
make
cp libcgi.a /usr/local/lib
cp cgi.h /usr/include
注意:装0.7的可能报错:
./configure: line 1246: syntax error near unexpected token `cgilib,'
./configure: line 1246: `AM_INIT_AUTOMAKE(cgilib, 0.7)'
h.pango-1.17.5.tar.gz
i.pixman
j.libxml2
k.libart_lgpl
l.cairo
2.Linux+Apache+Mysql+PHP环境的安装(见本blog)
注意:要装cacti,编译PHP 参数
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --enable-xml --with-zlib --enable-sockets --with-jpeg-dir --with-png-dir --with-freetype-dir
3.安装rrdtool
tar zxvf rrdtool-1.4.1.tar.gz
./configure --prefix=/usr/local/rrdtool
make
make install
ln -s /usr/local/rrdtool/bin/* /usr/local/bin/
4.安装net-snmp
tar zxvf net-snmp-5.5.tar.gz
./configure --prefix=/usr/local/net-snmp --enable-developer
make
make install
ln –s /usr/local/net-snmp/bin/* /usr/local/bin/
cp EXAMPLE.conf /usr/local/net-snmp/share/snmp/snmpd.conf
vi /usr/local/net-snmp/share/snmp/snmpd.conf 添加2行:
com2sec local localhost public
com2sec mynetwork 192.168.20.0/24 public
5.安装cacti
tar zxvf cacti-0.8.7e.tar.gz
cp cacti-0.8.7e /usr/local/apache/htdocs/cacti
vi /usr/local/apache/htdocs/cacti/include/config.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "root";
$database_password = "123456";
useradd cacti
chown -R cacti /usr/local/apache/htdocs/cacti/rra
chgrp -R cacti /usr/local/apache/htdocs/cacti
mysql -u root -p
create database cacti
mysql -u root -p cacti < cacti.sql # 导入数据
crontab -e -u cacti
*/5 * * * * /usr/local/php/bin/php /usr/local/apache/htdocs/cacti/poller.php > /dev/null 2>&1
在浏览器中输入: 完成cacti的安装
su - cacti
/usr/local/php/bin/php /usr/local/apache/htdocs/cacti/poller.php --force > /dev/null 2>&1
6.安装cacti-spine(cactid)
tar zxvf cacti-spine-0.8.7e.tar.gz
cd cacti-spine-0.8.7e
aclocal
注意:会提示一个警告:
“/usr/share/aclocal/libmcrypt.m4:17: warning: underquoted definition of
AM_PATH_LIBMCRYPT
run info '(automake)Extending aclocal'
or see ”
解决方法:
打开/usr/share/aclocal/libmcrypt.m4 文件,找到17行的“AC_DEFUN(AM_PATH_LIBMCRYPT,”改成 “AC_DEFUN([AM_PATH_LIBMCRYPT]
libtoolize --force
autoconf
autoheader
automake
chmod u+x configure
./configure --prefix=/usr/local/spine --with-mysql=/usr/local/mysql --with-snmp=/usr/local/net-snmp
make
make install
cd /usr/local/spine/etc
vi spine.conf
DB_Host localhost
DB_Database cacti
DB_User root
DB_Pass 123456
DB_Port 3306
/usr/local/spine/bin/spine -C /usr/local/spine/etc/spine.conf
ldd /usr/local/spine/bin/spine (看是否缺包)
默认用户名:admin 密码:admin
注意:会强制要求改密码
登陆console--Configuration--Settings--poller--Poller Type改为spine
登陆console--Configuration--Settings--paths--Spine Poller File Path添加/usr/local/spine/bin/spine
实际应用
1.监控Linux主机
a.安装net-snmp包
b.vi /etc/snmp/snmpd.conf
1)、查找以下字段:
#sec.name source community
com2sec notConfigUser default public
将"comunity"字段改为你要设置的密码.比如"public".
将“default”改为你想哪台机器可以看到你的snmp信息,如10.10.10.10。
2)、查找以下字段:
# Finally, grant the group read-only access to the systemview view.
# group context sec.model sec.level prefix read write notif
access notConfigGroup "" any noauth exact all none none
将"read"字段改为all.
3)、查找以下字段:
## incl/excl subtree mask
#view all included .1 80
将该行前面的"#"去掉.
c.运行/etc/init.d/snmpd start命令运行snmpd.
最后运行netstat -ln查看161端口是否打开了.
d.在console里"devices"-"add" 输入主机描述和IP,然后选择"local linux machine" 即可
2.监控windows主机
1.添加删除程序里添加snmp组件。
2.启动snmp服务。
3.右单击snmp服务点"属性"-"安全" -"添加" 团体名称:public, 权限:只读
4.下半部分添加可信任的主机名、IP 或是 IPX 名称。这里就也是添加监控服务器的IP
5.在console里"devices"-"add" 输入主机描述和IP,然后选择"windows xp/2000 host" 即可
3.监控MySQL
1.下载 mysql 模版
2.将mysql_stats.php 和 dumpMemcachedStats.php脚本放到cacti脚本目录下(/usr/local/apache/htdocs/cacti/scripts/),导入模板时注意选择cacti_host_template_temysql_host-step300-heartbeat600.xml和cacti_host_template_memcached_host-step300-heartbeat600.xml模板(默认cacti 5分钟取一次数据)。
3.配置MySQL服务器,让cacti所在机器能够访问MySQL服务器的状态信息,必须拥有"process"权限。如果要监控InnoDB状态,还必须有"SUPER"权限。(root用户不需要配置这步)
GRANT PROCESS ON *.* TO cacti@'cactimachine' IDENTIFIED by 'cacti';
GRANT SUPER ON *.* TO cacti@'cactimachine' IDENTIFIED BY 'cacti';
4.创建Graph。在Console选项卡下的左侧菜单栏中选择Devices,为要监控的主机新建一个Devices或选择已有Devices。在Associated Graph Templates中添加想要监控MySQL状态的Graph Templates(如teMySQL – Index Usage模板,此套模板是以teMySQL开头的一系列模板)。并点击最上面的Create Graphs for this Host链接,在Graph Templates的选择框中选择teMySQL – Index Usage,然后点击Create按钮,出现以下WEB页。
需要输入数据库用户和密码 然后点击create按钮。
4.插件安装
1.要安装插件都必须先装cacti-plugin-arch插件(下载与cacti相对应的版本)
2.解压放到/usr/local/apache/htdocs/cacti/ 下
3.cd /usr/local/apache/htdocs/cacti/
4.mysql -uroot -p cacti < pa.sql
5.patch -p1 -N < cacti-plugin-0.8.7e-PA-v2.5.diff
6.安装完cacti-plugin-arch后需要修改include/global.php文件
将 $config['url_path'] = '/'; 改为 $config['url_path'] = '/cacti/';
注意:如果你的cacti能够在浏览器中使用以下方法直接访问,则不用修改cacti配置文件。
或
如果cacti在浏览器中使用以下方法直接访问,
/cacti 或
则$config['url_path'] = "/";必须被修改为$config['url_path'] = "/cacti/";
注意前后的/不能丢。
7.进入"用户管理"->点admin->区域权限->Plugin Management 勾上
5.安装其他插件(如:monitor)
1.解压monitor-0.9.tar.gz 并放到/usr/local/apache/htdocs/plugins/monitor
2.vi include/global.php
查找:$plugins = array();
添加如下:$plugins[] = 'monitor';
3.点击console后在setting下面有一个“Plugin Management”,点进去可以进行plugin的管理,点击install.然后点击enabled