您的位置:首页 > 运维架构 > Linux

Centos安装Cacti监控

2012-06-27 17:00 351 查看
本次试验的所有包都可以去

http://blog.lubingit.com/Downing/cactipackname目录里下载

安装cacti 的步骤就不写了,去网上搜索有教程,本次试验软件版本为:

cacti-0.8.7e.tar.gz

rrdtool-1.2.26.tar.gz

snmpd centos5.3自带的,snmpd.conf文件只需修改三个地方:1 把default修改成cacit主机地址 2 把

access notConfigGroup "" any noauth exact roview none none 中的roview修改成all 就可以了 3 去掉

view all included .1 80 前面的注释号

*/5 * * * * root /usr/local/php5/bin/php /usr/local/apache2/cacti.lubingit.com/poller.php >/dev/null 2>&1 放入到任务计划里 刷新图像,根据实际安装路径进行修改。

[newpage]

监控mysql http://hi.baidu.com/shengit/blog/item/11174c13b24b5558f819b8d8.html

1 wget http://mysql-cacti-templates.googlecode.com/files/mysql-cacti-templates-1.1.2.tar.gz 就用了里面的mysql 插件 其他的都没有用

tar -xzvf mysql-cacti-templates-1.1.2.tar.gz

cd mysql-cacti-templates-1.1.2

cp ss_get_mysql_stats.php /xok.la/cacti/scripts

可以看到里面有多个监控项目,报告监控apache和nginx.我这只测试mysql,mysql相关的就2个文件:

模板文件:cacti_host_template_x_db_server_ht_0.8.6i.xml

插件:ss_get_mysql_stats.php

修改ss_get_mysql_stats.php 文件 第30行

$mysql_user = 'cacti';

$mysql_pass = 'cacti';

$cache_dir = "/xok.la/cacti/cache/";

设置准备监控的数据库的账户相关信息

mkdir /xok.la/cacti/cache/

chown -R vhost.vhost /xok.la/cacti/cache/

chmod 777 -R /xok.la/cacti/cache/

默认在获取的数据/tmp/下,会有cacti不能读取的情况。所以放在cacti目录来。

二,创建监控Mysql需要的账户以及权限

配置MySQL服务器,让cacti所在机器能够访问MySQL服务器的状态信息,必须拥有”process”权限。如果要监控InnoDB状态,还必须有”SUPER”权限。

mysql> grant process,super on *.* to 'cacti'@'%' identified by 'cacti';

mysql> grant all privileges on cacti.* to cacti@"%" identified by "cacti";

三,模板导入

在cacti管理界面(Import Templates)导入cacti_host_template_x_db_server_ht_0.8.6i.xml。

四,添加设备

创建Graph。在Console选项卡下的左侧菜单栏中选择Devices,为要监控的主机新建一个Devices或选择已有Devices。在 Associated Graph Templates中添加想要监控MySQL状态的Graph Templates(如X MySQL Connections GT模板)。并点击最上面的Create Graphs for this Host链接,在Graph Templates的选择框中选择X MySQL Connections GT,然后点击Create按钮,出现以下WEB页。

[newpage]

监控 ping http://blog.sina.com.cn/s/blog_4e424e2101000b77.html

1.Advance Ping 脚本及模板

下载地址:http://forums.cacti.net/about10049.html

注:要使用此模板,编译PHP时必须加上--enable-sockets选项来支持套接字。

1).功能:此模板用来监控一个TCP/UDP端口、ICMP的延时情况和丢包情况。

2).下载ss_fping.php脚本并放到/usr/local/apache/htdocs/cacti /scripts/目录下,下载cacti_graph_template_ping_advanced_ping_v1_3.xml模板,用cacti 的模板导入页将此模板导入。

3).在Console选项卡下的左侧菜单栏中选择Devices,为要监控的主机新建一个Devices或选择已有Devices。在Associated Graph Templates中添加Advanced Pingv1.3模板。并点击最上面的Create Graphs for this Host链接。

在Graph Templates的选择框中选择PING - Advanced Ping v1.3,然后点击Create按钮,出现以下WEB页

第一项意思是一次向要监控的端口发送多少个探测包(默认20个),第二项是使用的协议,可以是ICMP、TCP、UDP,第三项是要监控的端口号(只有第二项为TCP或是UDP时使用),填写完成后点击create按钮。

在Console控制台选项卡下的左侧菜单中选择Date Sources,选择以上新建的数据源可以修改以上填写的信息。

[newpage]

监控 nginx http://www.puppeter.cn/?p=106 编译安装nginx时必须要加 http_stub_status_module参数 ,然后还需要给系统安装LWP::UserAgent模块 安装方法:yum -y install perl-libwww-perl 或者cpan -i LWP::UserAgent 如果没有安装 在下面的 /data/cacti/scripts/get_nginx_clients_status.pl http://192.168.1.100/nginx_status 会出错

# vi /usr/local/nginx/conf/nginx.conf

location /nginx_status {

stub_status on;

access_log off;

allow 192.168.1.100;

deny all;

}

# kill -HUP `cat /usr/local/nginx/logs/nginx.pid`

# wget http://forums.cacti.net/download.php?id=12676

# tar xvfz cacti-nginx.tar.gz

# cp cacti-nginx/get_nginx_socket_status.pl /data/cacti/scripts/

# cp cacti-nginx/get_nginx_clients_status.pl /data/cacti/scripts/

# chmod 755 /data/cacti/scripts/get_nginx*

检测插件

# /data/cacti/scripts/get_nginx_clients_status.pl http://192.168.1.100/nginx_status

在cacti管理面板导入

cacti_graph_template_nginx_clients_stat.xml

cacti_graph_template_nginx_sockets_stat.xml

[newpage]

监控apache http://xok.la/2009/05/cacti_apache_templates.html

对Apache的状态管理的模块是LoadModule status_module modules/mod_status.so,

vim httpd.conf

增加

ExtendedStatus On 注意:如果是vH 不能加到vh里面,而要加到vh外面

<location /server-status> locaton左边需要加一个<号 最下面的也是如此

SetHandler server-status

Order Deny,Allow

Deny from all

Allow from www.xok.la

</location>

下载模板和脚本

http://forums.cacti.net/about25227.html&highlight=apachestats

也可以本站直接下载:

http://xok.la/file/2009/05/ApacheStats_0.8.1.zip

在上面的地址下载一个叫 ApacheStats08.zip的,中间有二个文件,一个处理脚本php的,另一个是xml的文件.

1.其中的ss_apache_stats.php是脚本文件,它是一个php的文件,放到你的cacti/scripts/下面.

2.接下来在cacti界面导入cacti_host_template_webserver_-_apache.xml这个文件

安装cacti 插件 可以参照 http://www.cublog.cn/u1/40349/showart_1271097.html

monitor 等等都安装0.9版本的

[root@centos53 src]# wget http://docs.cacti.net/_media/plugin:monitor-latest.tgz

[root@centos53 src]# wget http://docs.cacti.net/_media/plugin:thold-latest.tgz

[root@centos53 src]# wget http://docs.cacti.net/_media/plugin:settings-latest.tgz

但是在安装后有一个问题,就是点击monitor 时会报错

报错信息如下:Undefined index: action in /usr/local/apache/htdocs/cacti/include/top_graph_header.php

解决方法:解压cacti-plugin-0.8.7e-PA-v2.6.zip 然后cp cacti-plugin-arch/files-0.8.7e/include/top_graph_header.php to

include/top_graph_header.php

就可以了。

本文出自 “决胜千里之外” 博客,谢绝转载!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: