服务器监控cacti

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了服务器监控cacti相关的知识,希望对你有一定的参考价值。

服务器监控 cacti

cacti(仙人掌)是一款用php语言开发的监控软件,结合net-snmp来采集数据,RRDtool记录数据并绘制图片,以web页面的形式监控主机性能和流量。

catcti 部署

服务器端: 192.168.137.129

客户端:192.168.137.185

部署过程:
服务器端:
1.安装lamp环境
[[email protected] ~]# yum -y install httpd mysql mysql-server php php-mysql php-gd mysql-devel zlib freetype  libxml2 gd libjpeg

[[email protected] ~]# sed -i ‘276 s/#//‘ /etc/httpd/conf/httpd.conf
[[email protected] ~]# sed -i ‘402 s/$/ index.php/‘ /etc/httpd/conf/httpd.conf
[[email protected] ~]# awk ‘NR==276||NR==402{print}‘ /etc/httpd/conf/httpd.conf
ServerName www.example.com:80
DirectoryIndex index.html index.html.var index.php
[[email protected] ~]# for i in httpd mysqld
> do
> service $i start
> chkconfig $i on
> done
正在启动 httpd:                                           [确定]
正在启动 mysqld:                                          [确定]
[[email protected] ~]#
[[email protected] ~]# cat >> /var/www/html/test.php  <<EQF
> >?php
> phpinfo();
> ?>
> EQF

技术分享
2安装snmp数据采集工具
[[email protected] ~]# yum -y install net-snmp net-snmp-utils
[[email protected] ~]# service snmpd start
正在启动 snmpd:                                           [确定]
[[email protected] ~]# chkconfig snmpd on

3.安装rrdtool软件包
[[email protected] ~]# yum -y install cairo-devel  zlib libxml2 libxml2-devel glib2 glib2-devel  libpng libpng-devel freetype freetype-devel libart_lgpl pango pango-devel perl-CPAN
[[email protected] ~]# tar xf rrdtool-1.4.8.tar.gz -C /usr/src/
[[email protected] rrdtool-1.4.8]# ./configure --prefix=/usr/local/ && make && make install


4.安装cacti
[[email protected] ~]# tar xf cacti-0.8.8b.tar.gz -C /usr/src/
[[email protected] cacti-0.8.8b]# mv /usr/src/cacti-0.8.8b/ /var/www/html/cacti
[[email protected] cacti-0.8.8b]# useradd -M -s /sbin/nologin cacti
[[email protected] cacti-0.8.8b]# chown -R cacti:cacti /var/www/html/cacti/


5.创建cacti数据库用户,并授权
mysql> create database cactidb default character set utf8;
Query OK, 1 row affected (0.05 sec)

mysql> grant all on cactidb.* to ‘cacti‘@localhost  identified by ‘cacti‘
    -> ;
Query OK, 0 rows affected, 1 warning (0.20 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.15 sec)


使用cacti目录下的cacti.sql 脚本  ,导入预设的各种数据表

[[email protected] ~]#mysql  -ucacti    -pcacti   cactidb <  /var/www/html/cacti/cacti.sql


6.调整cacti数据库配置文件

[[email protected] ~]# vim /var/www/html/cacti/include/config.php
$database_type = "mysql";
$database_default = "cactidb";      cacti数据库
$database_hostname = "localhost";
$database_username = "cacti";       cacti用户
$database_password = "cacti";       cacti用户登录密码
$database_port = "3306";            连接数据库端口号
$database_ssl = false;
$url_path = "/";   指定cacti目录相对于网站根目录的位置


7.调整Apache主配置文件,修改默认发布路径
[[email protected] ~]# vim /etc/httpd/conf/httpd.conf
[[email protected] ~]# awk ‘NR==292||NR==317{print}‘ /etc/httpd/conf/httpd.conf
DocumentRoot "/var/www/html/cacti"
<Directory "/var/www/html/cacti">
[[email protected] ~]# service httpd restart

技术分享


停止 httpd:                                               [确定]
正在启动 httpd:                                           [确定]技术分享

默认用户密码都是admin,之后再用cacti登录

技术分享

客户端配置(被监控端)
1.安装net-snmpruanjianbao
[[email protected] ~]# yum -y install net-snmp lm_sensors

2.修改snmp配置文件,设置SNMP访问权限
[[email protected] ~]# cp /etc/snmp/snmpd.conf{,.`date +%F`}
[[email protected] ~]# vim /etc/snmp/snmpd.conf
com2sec notConfigUser  192.168.137.129       public
ccess  notConfigGroup ""      any       noauth    exact  all none none
view all    included  .1                               80
3.调整防火墙策略允许cacti服务器开启SNMP服务并通过
[[email protected] ~]# iptables -I INPUT -s 192.168.137.129 -p udp --dport 161 -j ACCEPT
[[email protected] ~]# iptables -I OUTPUT -s 192.168.137.129 -p udp --sport 161 -j ACCEPT
[[email protected] ~]# iptables -nvL --line
[[email protected] ~]# /etc/init.d/iptables save
启动SNMP服务
[[email protected] ~]# service snmpd start
正在启动 snmpd:                                           [确定]
[[email protected] ~]# chkconfig snmpd on
[[email protected] ~]# netstat -anptu |grep 161
udp        0      0 0.0.0.0:161                 0.0.0.0:*                               2393/snmpd  


添加监控的主机

技术分享


本文出自 “13138249” 博客,转载请与作者联系!

以上是关于服务器监控cacti的主要内容,如果未能解决你的问题,请参考以下文章

05: Cacti监控服务 Cacti监控实战

部署监控三剑客 Cacti 服务器监控

服务器监控cacti

服务器监控系统cacti

Linux 搭建Cacti 监控服务器

服务器监控cacti