当前位置:首页 > 开发 > 操作系统 > 正文

linux cacti监控

发表于: 2013-10-15   作者:Catherine_luo   来源:转载   浏览:
摘要: 基本的环境LAMP,SNMP 安装23个包 yum -y install pango pango-devel freetype freetype-devel libpng libpng-devel gettext gettext-devel libjpeg libjpeg-devel gd gd-devel libxml2 libxml2-devel libiconv libi

基本的环境LAMP,SNMP


安装23个包
yum -y install pango pango-devel
freetype freetype-devel libpng libpng-devel
gettext gettext-devel libjpeg libjpeg-devel
gd gd-devel libxml2 libxml2-devel
libiconv libiconv-devel qpixman pqixman-devel
glib glib-devel cairo cairo-devel libart*

装rrdtool
解压 tar xzf rrdtool-1.4.5.tar.gz
跳转 cd rrdtool-1.4.5
生成配置地图 ./configure --prefix=/usr/local/rrdtool
编译 make
安装 make install

装Cacti
解压 tar xzf cacti-0.8.8b.tar.gz
拷贝 rsync -a cacti-0.8.8b /usr/local/apache/htdocs/cacti
转到mysql   /usr/local/mysql mysql -uroot -proot
创建数据库  create database cactidb
导入数据    mysql -uroot -proot cactidb</usr/local/apache/htdocs/cacti/cacti.sql
修改项目的配置文件 /usr/local/apache/htdocs/cacti/include/config.php
$database_default = "cactidb";//数据库名
$database_hostname = "localhost";
$database_username = "root";
$database_password = "root";
$url_path = "/";


文件授权
setfacl -m u:apache:rwx -R cacti/
setfacl -m d:u:apache:rwx -R cacti/


进入cacti: http://cacti.com网站,配置时把rrdtool,php的位置填写好
注意:确保路径的最后一个是可执行的命令,而不是目录,要不然rrdtool画图时会出错
/usr/local/rrdtool/bin/rrdtool
/usr/local/php/bin/php

在网站中添加,操作要监控的硬件以及监控的内容


运行一次画图
/usr/local/php/bin/php /usr/local/apache/htdocs/cacti/poller.php  &>/dev/null

定时任务:5分钟绘一次图
crontab -e
*/5 * * * * /usr/local/php/bin/php /usr/local/apache/htdocs/cacti/poller.php  &>/dev/null

监控nginx
添加配置
vi /usr/local/nginx/conf/nginx.conf

在配置文件中加入
location /NginxStatus {
stub_status on;
access_log off;
allow 192.168.0.0/16;#意思是只允许内网能看到监控信息
deny all;
}

平滑重启nginx
/usr/local/nginx/sbin/nginx -s reload

访问http://cacti.com/NginxStatus,如果有内容,则配置成功

导入数据
tar xzf cacti-nginx.tar.gz
cd cacti-nginx
cp get_nginx_clients_status.pl /usr/local/apache/htdocs/cacti/scripts/
cp get_nginx_socket_status.pl  /usr/local/apache/htdocs/cacti/scripts/
chmod 0755 /usr/local/apache/htdocs/cacti/scripts/get_nginx_clients_status.pl
chmod 0755 /usr/local/apache/htdocs/cacti/scripts/get_nginx_socket_status.pl


导入模板
到http://cacti.com/下console->Import Templates把cacti_graph_template_nginx_clients_stat.xml 和 cacti_graph_template_nginx_sockets_stat.xml导入

测试是否成功添加监控
/usr/local/apache/htdocs/cacti/scripts/get_nginx_clients_status.pl http://cacti.com/NginxStatus
如果有数据则成功
如果显示no (LWP::UserAgent not found)
则需要添加perl包
yum install perl-CPAN
perl -MCPAN -e shell
install LWP::UserAgent



最后到http://cacti.com/下console下添加监控项目




linux cacti监控

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号