(2)配置mariadb
[root@cacti-server ~]# yum -y install mariadb-server mysql-devel
[root@cacti-server ~]# systemctl start mariadb
[root@cacti-server ~]# mysql_secure_installation
Set root password? [Y/n]
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
[root@cacti-server ~]# mysql -u root -p
MariaDB [(none)]> grant all privileges on *.* to test@localhost identified by 'redhat'; #创建用于测试php和mariadb连通性的用户
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
(1)下载软件
[root@cacti-server ~]# cd /usr/local/src/
[root@cacti-server src]# wget http://www.cacti.net/downloads/cacti-0.8.8f.tar.gz
[root@cacti-server src]# tar zxvf cacti-0.8.8f.tar.gz
[root@cacti-server src]# mv cacti-0.8.8f /var/www/html/cacti
(2)创建cacti数据库和cacti用户,赋予权限
[root@cacti-server ~]# mysql -u root -p
MariaDB [(none)]> create database cacti default character set utf8;
MariaDB [(none)]> grant all privileges on cacti.* to cacti@localhost identified by 'redhat';
MariaDB [(none)]> flush privileges;
(3)把cacti.sql导入数据库
[root@cacti-server cacti]# mysql -ucacti -predhat cacti < /var/www/html/cacti/cacti.sql
(7)编辑配置文件
[root@cacti-server ~]# vim /etc/snmp/snmpd.conf
41 com2sec notConfigUser 127.0.0.1 public
62 access notConfigGroup "" any noauth exact all none none
85 view all included .1 80
(2)编辑配置文件
[root@cacti-client ~]# vim /etc/snmp/snmpd.conf
41 com2sec notConfigUser 192.168.23.156 public
62 access notConfigGroup "" any noauth exact all none none
85 view all included .1 80
(1)编辑apache的配置文件,加入server-status模块的设置
[root@cacti-client ~]# vim /etc/httpd/conf/httpd.conf
ExtendedStatus On
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from all
</Location>
[root@cacti-client ~]# systemctl restart httpd
[root@cacti-client ~]# systemctl enable httpd
(2)查看apache加载的模块
[root@cacti-client ~]# apachectl -t -D DUMP_MODULES|grep status
status_module (shared)
(6)添加服务器并创建图表
登录Cacti Web界面,添加被监控mariabdb服务器设备,并创建相应图表:
Devices->Add->dbServer–Mysql模板->Create New Graphs,添加所需图表即可。等待一段时间就会出图
7.邮件报警
(1)下载插件
[root@cacti-server ~]# cd /usr/local/src/
[root@cacti-server src]# tar zxvf settings-v0.71-1.tgz
[root@cacti-server src]# mv settings /var/www/html/cacti/plugins/
[root@cacti-server src]# tar zxvf thold-v0.5.0.tgz
[root@cacti-server src]# mv thold /var/www/html/cacti/plugins/
(2)访问cacti管理页面安装插件
(3)测试
(4)告警被触发,查看邮件
[root@cacti-server ~]# cat /var/spool/mail/root
..................................
..................................
To: root@192.168.23.156
Subject: ALERT: test - Used Space - / [hdd_used] [hdd_used] went above threshold of 25 with 36.8871
From: Cacti <Cacti@localhost.localdomain>
Date: Mon, 24 Oct 2016 14:00:03 +0800
..................................
An alert has been issued that requires your attention.
..................................
Host: test (192.168.23.157)
URL: http://192.168.23.156/cacti//graph.php?local_graph_id=103&rra_id=1
Message: ALERT: test - Used Space - / [hdd_used] [hdd_used] went above threshold of 25 with 36.8871
..................................
Content-Type: image/jpg
Content-Disposition: inline; filename="103.jpg"
...................................
...................................