一.準備三台機器:
Server 192.168.1.19
Client1 192.168.1.11
二.配置(s/c都要安裝)
1.yum install -y net-snmp*
2.cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.$(date +%F-%H)
3.cat >/etc/snmp/snmpd.conf<<EOF
com2sec local localhost public
com2sec mynetwork 10.0.0.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 etiantian.org
syscontact Me <hyran@126.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
4.cat -n /etc/snmp/snmpd.conf
5./etc/init.d/snmpd start
6.lsof -i :161
7.ps -ef|grep snmpd|grep -v grep
8.snmpget -v 1 -c public localhost system.sysUpTime.0
Server端安裝:
1.tar zxvf libart_lgpl-2.3.17.tar.gz
2../configure
3.make && make install
4./bin/cp -r /usr/local/include/libart-2.0 /usr/include
5.tar zxvf rrdtool-1.2.30.tar.gz
6../configure
报错:configure: error: Please fix the library issues listed above and try again.
解决:yum install -y pango-devel* cairo-devel*
然后:./configure --prefix=/usr/local/rrdtool
7.make && make install
8.ls -l /usr/local/rrdtool/
9.ls -l /usr/local/rrdtool/bin/rrdtool && ln -s /usr/local/rrdtool/bin/rrdtool /usr/local/bin/rrdtool 存在则执行
1.yum install -y gcc glibc glibc-common cairo pango zlib zlib-devel freetype freetype-devel gd
2.yum -y install httpd php mysql mysql-server php-mysql
cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.ori
yum -y remove http*(卸載http服務)
3.sed -i 's##ServerName www.example.com:80#ServerName 127.0.0.1:80#g' /etc/httpd/conf/httpd.conf
4.sed -i 's#DirectoryIndex index.html index.html.var#DirectoryIndex index.php index.html#g' /etc/httpd/conf/httpd.conf 配置首頁文件
6.egrep "127.0.0.1|index" /etc/httpd/conf/httpd.conf 查看信息
7./etc/init.d/httpd start
8.lsof -i :80
9.grep DocumentRoot httpd.conf 查看站點目錄
10.echo -e "<?php phpinfo(); ?>" /var/www/html/index.php
IE登錄192.168.1.19/index.php 查看是否有php顯示
11./etc/init.d/mysqld start
12.lsof -i :3306
13.mysql
14.GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY'cactiuser';創建用戶密碼,并授權
15.flush privileges; 權限刷新
16.create database cacti;
17.quit
18.tar zxvf cacti-0.8.8a.tar.gz
19.cd cacti-0.8.8a
20.mysql cacti <cacti.sql 初始化cacti数据库
21.mysql -e "use cacti;show tables;"
22.vim include/config.php 在其中修改信息
23.grep database include/config.php
24.chown -R apache rra/ log/ 授权Apache访问
25.mv ../cacti-0.8.8a /var/www/html/cacti 页面拷贝
26.chown -R apache.apache cacti
27./usr/bin/php /var/www/html/cacti/poller.php 测试收集php文件
28.chown 755 /var/www/html/cacti/poller.php
29.echo '*/5 * * * * /usr/bin/php /var/www/html/cacti/poller.php >/dev/null 2>&1' >>/var/spool/cron/root
30.setenforce 0
31./etc/init.d/iptables stop
通过cacti监控服务器并发连接数配置
1.unzip get_netstat_conn.zip
2.tree get_netstat_conn
3.mv get_netstat_conn/get_netstat_tcp_oldboytrainning.pl /var/www/html/cacti/scripts/
4.chmod 755 /var/www/html/cacti/scripts/get_netstat_tcp_oldboytrainning.pl
cd /var/www/html/cacti/scripts/
perl get_netstat_tcp_oldboytrainning.pl 127.0.0.1 2c public 161 500 只有返回数据,才能监控到数据出图