- 主机架构:
角色 ip地址 cacti服务器 192.168.8.81 被监控机器 192.168.8.82
- 客户端配置:
a. 安装软件:yum -y install net-snmp lm_sensors
b. 修改配置文件:vim /etc/snmp/snmpd.conf
com2sec notConfigUser default public group notConfigGroup v1 notConfigUser group notConfigGroup v2c notConfigUser view systemview included .1.3.6.1.2.1.1 view systemview included .1.3.6.1.2.1.25.1.1 access notConfigGroup "" any noauth exact all none none view all included .1 syslocation Unknown (edit /etc/snmp/snmpd.conf) syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf) dontLogTCPWrappersConnects yes
c. 防火墙配置:
iptables -I INPUT -p tcp --dport 199 -j ACCEPT iptables -I INPUT -p udp --dport 161 -j ACCEPT iptables-save
d. 启动服务:
systemctl start snmpd
- 服务端配置:
a. 安装软件:yum -y install net-snmp net-snmp-devel net-snmp-utils snmp-libs lm_sensors httpd mariadb php php-mysql php-xml zlib libpng freetype cairo-devel pango-devel gd rrdtool
b. 配置apache虚拟主机:vim /etc/httpd/conf/httpd.conf
AddType application/x-httpd-php .php .phtml .php3 .inc #使apache支持php ... <VirtualHost *:80> DocumentRoot "/var/www/html/cacti" ServerName cacti.lee.com DirectoryIndex index.php </VirtualHost>
c. 修改php默认时区:vim /etc/php.ini
date.timezone = "PRC"
d. 下载cacti软件:
https://www.cacti.net/downloads/cacti-0.8.8a.tar.gz #软件地址 wget https://www.cacti.net/downloads/cacti-0.8.8a.tar.gz tar -xzf cacti-0.8.8a.tar.gz -C /var/www/html/cacti
e. 修改cacti所属权限为apache:
chown -R apache.apache /var/www/html/cacti
f. 在mariadb中添加一个数据库cacti并导入数据:
mysql -uroot -p -e "create database cacti" mysql -uroot -p cacti < /var/www/html/cacti/cacti.sql
g. 修改cacti配置文件:vim /var/www/html/cacti/include/config.php
<?php $database_type = "mysql"; $database_default = "cacti"; $database_hostname = "localhost"; $database_username = "root"; $database_password = "123456"; $database_port = "3306"; $database_ssl = false; $url_path = "/"; ?>
- 测试:
本文转自 Lee_吉 51CTO博客,原文链接:http://blog.51cto.com/12173069/2049075