1.【被监控端】SNMP安装
yum install net-snmp* -y
2.配置
ll /etc/snmp/snmpd.conf cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.bak cat >/etc/snmp/snmpd.conf<<EOF com2sec local localhost public com2sec mynetwork 192.168.1.0/24 public group MyRWGroup v1 local group MyRWGroup v2c local group MyRWGroup usm local group MyROGroup v1 mynetwork group MyROGroup v2c mynetwork group MyROGroup usm mynetwork view all included .1 80 access MyROGroup "" any noauth exact all none none access MyRWGroup "" any noauth exact all all none syslocation qinzc.me syscontact Me <542129333@qq.com> proc mountd proc ntalkd 4 proc sendmail 10 1 proc httpd 10 1 exec echotest /bin/echo hello world exec disk_used_shell /bin/sh /root/current_disk_used.sh exec httpd_proc /bin/sh /root/current_httpd_proc.sh disk / 10000 disk /boot 10000 load 12 14 14 EOF
#提示: com2sec local localhost public com2sec mynetwork 192.168.1.0/24 public #其中public团体名,可以随意起名 #10.0.0.0/24为允许访问SNMP的IP段,多个IP换行写。
3.启动snmp
/etc/init.d/snmpd start [root@A-LB ~]# lsof -i :161 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME snmpd 2026 root 8u IPv4 13368 0t0 UDP *:snmp [root@A-LB ~]# netstat -lntup|grep 161 udp 0 0 0.0.0.0:161 0.0.0.0:* 2026/snmpd [root@A-LB ~]# ps -ef|grep snmpd|grep -v grep root 2026 1 0 09:18 ? 00:00:00 /usr/sbin/snmpd -LS0-6d -Lf /dev/null -p /var/run/snmpd.pid
4.测试是否正常
snmpget -v 1 -c public localhost system.sysUpTime.0
5.【监控端】安装RRDtool cacti_tools.tar.gz
tar xf cacti_tools.tar.gz cd cacti_tools #libart tar zxf libart_lgpl-2.3.17.tar.gz cd libart_lgpl-2.3.17 ./configure make make install /bin/cp -r /usr/local/include/libart-2.0 /usr/include cd ../ #RRDtoo tar xf rrdtool-1.2.30.tar.gz cd rrdtool-1.2.30 ./configure make && make install ls -l /usr/local/bin/rrdtool ls -l /usr/local/rrdtool-1.2.30/bin/rrdtool && ln -s /usr/local/rrdtool-1.2.30/bin/rrdtool ls -l /usr/local/bin/rrdtool ls -l /usr/local/rrdtool-1.2.30/bin/rrdtool && ln -s /usr/local/rrdtool-1.2.30/bin/rrdtool /usr/local/bin/rrdtool ls -l /usr/local/bin/rrdtool
6.安装依赖包
yum install gcc glibc glibc-common cairo pango zlib zlib-devel freetype freetype-devel gd gd-devel -y yum install mysql* httpd* php* --skip-broken -y
7.配置apache并启动apache与mysql
cd /etc/httpd/conf cp httpd.conf httpd.conf.oldboy.bak sed -i 's#\#ServerName www.example.com:80#ServerName 127.0.0.1:80#' /etc/httpd/conf/httpd.conf sed -i 's#DirectoryIndex index.html index.html.var#DirectoryIndex index.php index.html #' /etc/httpd/conf/httpd.conf egrep "127.0.0.1|index.php" /etc/httpd/conf/httpd.conf #启动apache /etc/init.d/httpd restart #启动mysql /etc/init.d/mysqld start
8.测试apache是否正常
grep DocumentRoot etc/httpd/conf/httpd.conf echo -e "<?php \nphpinfo(); \n?>" >/var/www/html/index.php cat /var/www/html/index.php
9.数据库配置
mysql grant all on cacti.* to 'cactiuser'@'localhost' identified by 'cactiuser'; flush privileges; create database cacti; show databases;
10.安装部署cacti
#回来cacti包安装目录 tar xf cacti-0.8.8a.tar.gz cd cacti-0.8.8a mysql cacti <cacti.sql mysql -e "use cacti;show tables;" grep database include/config.php grep apache /etc/httpd/conf/httpd.conf chown -R apache rra/ log/ mv ../cacti-0.8.8a /var/www/html/cacti cd /var/www/html/cacti chown -R apache.apache /var/www/html/cacti chmod 755 /var/www/html/cacti/poller.php chmod 755 /var/www/html/cacti/poller.php #配置php.ini vim /etc/php.ini date.timezone = Asia/Shanghai #定时收集数据(做定时任务) echo '*/5 * * * * /usr/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1' >>/var/spool/cron/root crontab -l #测试 /usr/bin/php /var/www/html/cacti/poller.php
停留在世界边缘,与之惜别