个人网站logo需要备案吗,鑫灵锐做网站多少钱,临沂网站建设公司哪家好,服装行业网站建设及推广cacti是什么#xff1f;1. cacti是用php语言实现的一个软件#xff0c;它的主要功能是用snmp服务获取数据#xff0c;然后用rrdtool储存和更新数据#xff0c;当用户需要查看数据的时候用rrdtool生成图表呈现给用户。因此#xff0c;snmp和rrdtool是cacti的关键。Snmp关系… cacti是什么1. cacti是用php语言实现的一个软件它的主要功能是用snmp服务获取数据然后用rrdtool储存和更新数据当用户需要查看数据的时候用rrdtool生成图表呈现给用户。因此snmp和rrdtool是cacti的关键。Snmp关系着数据的收集rrdtool关系着数据存储和图表的生成。2. Mysql配合PHP程序存储一些变量数据并对变量数据进行调用如主机名、主机ip、snmp团体名、端口号、模板信息等变量。3. snmp抓到数据不是存储在mysql中而是存在rrdtool生成的rrd文件中在cacti根目录的rra文件夹下。rrdtool对数据的更新和存储就是对rrd文件的处理rrd文件是大小固定的档案文件Round Robin Archive它能够存储的数据笔数在创建时就已经定义。cacti的工作流程可以用下图表示cacti的安装配置本地yum[rootcacti ~]# vim /etc/yum.repos.d/rhel-debuginfo.repo[rhel-Server]nameRed Hat Enterprise Linux Serverbaseurlfile:///mnt/cdrom/Serverenabled1gpgcheck1gpgkeyfile:///mnt/cdrom/RPM-GPG-KEY-redhat-release[rootcacti ~]# mkdir /mnt/cdrom[rootcacti ~]# mount /dev/cdrom/mnt/cdrom/mount: block device /dev/cdrom iswrite-protected, mounting read-only[rootcacti ~]# yum install httpd php php-mysql php-snmp mysql-serverperl-DBD-MySQL php-pdo net-snmp net-snmp-libs net-snmp-utils net-snmp-develruby –y[rootcacti ~]# service httpd start[rootcacti ~]# chkconfig httpd on[rootcacti ~]# service mysqld start[rootcacti ~]# chkconfig mysqld on[rootcacti ~]# mysqladmin -u root -ppassword 123[rootcacti ~]# mysql -u root –pmysql CREATE DATABASE cacti;mysql grant all privileges on cacti.* to cactilocalhostidentified by cacti;mysql grant all privileges on cacti.* to cacti127.0.0.1identified by cacti;mysql grant all privileges on cacti.* tocacti192.168.2.0 identified by cacti;mysql flush privileges;mysql quit上传需要用的软件软件资料下载地址http://down.51cto.com/data/994246cacti-0.8.7g.tar.gz cacti的主程序cacti-plugin-0.8.7g-PA-v2.8.tar.gz 插件管理器feition.tar.bz2 用于飞信报警的程序monitor-latest.tgz 实现只管监测的插件sendMsg.zip 发送MSN消息的应用settings-latest.tgz 增强功能的插件例如发送电子邮件thold-latest.tgz 实现达到预值告警的插件[rootcacti software]# yum localinstallrrdtool* --nogpgcheck –y安装cacti的主程序[rootcacti software]# tar -zxvf cacti-0.8.7g.tar.gz -C /var/www/html/[rootcacti software]# cd /var/www/html/[rootcacti html]# mv cacti-0.8.7g/ cacti[rootcacti html]# service snmpd start[rootcacti html]# chkconfig snmpd on[rootcacti html]# vim /etc/snmp/snmpd.conf添加一行view systemview included .1.3.6.1.2.1.25.1.6 /使能监控tcp流量编辑计划任务[rootcacti html]# crontab -e*/5 * * * * php/var/www/html/cacti/poller.php /dev/null 21导入数据库[rootcacti html]# mysql -u root -p cacti/var/www/html/cacti/cacti.sql输入mysql管理员口令编辑cacti连接数据库的文件[rootcacti html]# vim cacti/include/config.php29 $database_username cacti;30 $database_password cacti;新建一个用户cacti口令也为cacti[rootcacti html]# useradd cacti[rootcacti html]# passwd cacti[rootcacti html]# cd cacti/[rootcacti cacti]# chown -R cacti rra log此时就可以通过页面登录cacti了用户和口令都为admin实现对apache的监控[rootcacti software]# cd ApacheStats_0.8.2/[rootcacti ApacheStats_0.8.2]#lltotal 116-rw-r--r-- 1 root root 102879 Oct 27 18:51 cacti_host_template_webserver_-_apache.xml-rw-r--r-- 1 root root 4108 Oct 27 18:51 ss_apache_stats.php[rootcacti ApacheStats_0.8.2]#cp ss_apache_stats.php /var/www/html/cacti/scripts/[rootcacti ApacheStats_0.8.2]#chown 1000:users /var/www/html/cacti/scripts/ss_apache_stats.phpcacti_host_template_webserver_-_apache.xml 为下面要导入的模版文件通过控制台导入模版修改apache的配置文件[rootcacti ApacheStats_0.8.2]#cd[rootcacti ~]# vim/etc/httpd/conf/httpd.conf217 ExtendedStatus On /打开这一行903 #Location /server-status904 # SetHandler server-status905 # Order deny,allow906 # Deny from all907 # Allow from .example.com908 #/Location909 Location /server-status910 SetHandler server-status911 Order deny,allow912 Deny from all913 Allow from all914 /Location将apache重启[rootcacti ~]# service httpd restart在安装插件之前要先安装插件管理器[rootcacti cacti]# cd /root/software/[rootcacti software]# tar -zxvf cacti-plugin-0.8.7g-PA-v2.8.tar.gz[rootcacti software]# cp -R cacti-plugin-arch/* /var/www/html/cacti/[rootcacti software]# cd /var/www/html/cacti/[rootcacti cacti]# mysql -u root -pcactipa.sql[rootcacti cacti]# patch -p1 -Ncacti-plugin-0.8.7g-PA-v2.8.diff[rootcacti cacti]# vim include/config.php42 $url_path /cacti/; /修改这一行的路径安装插件[rootcacti cacti]# cd /root/software/[rootcacti software]# tar -zxvf monitor-latest.tgz[rootcacti software]# tar -zxvf settings-latest.tgz[rootcacti software]# tar -zxvf thold-latest.tgz[rootcacti software]# mv monitor-0.9/ /var/www/html/cacti/plugins/monitor[rootcacti software]# mv settings-0.6/ /var/www/html/cacti/plugins/settings[rootcacti software]# mv thold-0.41/ /var/www/html/cacti/plugins/thold在控制台启用插件配置支持发送msn消息[rootcacti software]# unzip sendMsg.zip[rootcacti software]# mv sendMsg/ var/www/html/[rootcacti software]# vim /var/www/html/cacti/plugins/thold/thold_functions.php添加下面这两行560 exec(echo $subject/var/www/html/cacti/plugins/thold/alert.log);561 exec(sh /var/www/html/cacti/plugins/thold/sendmessage.sh);编写个sendmessage.sh脚本在/var/www/html/cacti/plugins/thold/这个目录下实现自动发送[rootcacti software]# vim /var/www/html/cacti/plugins/thold/sendmessage.sh脚本内容#!/bin/shecho echo -ndate:date %Y-%m-%d-%H:%M /var/www/html/sendMsg/msn.txt.1cat /var/www/html/cacti/plugins/thold/alert.log/var/www/html/sendMsg/msn.txt.1nowdate %Y-%m-%d-%H:%MSA(test)msnaddr(接收信息的帐号)sendMsg(){num0while [ $num -lt 1 ];dowget ?post-datasender发送信息的帐号password密码recipient${1}message${2}http://127.0.0.1/sendMsg/index.php -O /var/www/html/sendMsg/index.php.1/dev/null 21if [ -f /var/www/html/sendMsg/index.php.1]; thenif cat /var/www/html/sendMsg/index.php.1|grep -i successfully /dev/null 21;thennum1elif cat /var/www/html/sendMsg/index.php.1|grep -i The user appears to be offline /dev/null21;thennum1echo The user is offline.exit 0elif cat /var/www/html/sendMsg/index.php.1 |grep-i Something went wrong trying to connect to the server/dev/null 21;thennum1echo MSN server is online.exit 0elsenum0firm -f /var/www/html/sendMsg/index.php.1elsenum0fidone}mv /var/www/html/sendMsg/msn.txt/var/www/html/sendMsg/bak/msn$now.txt -f 1/dev/null 21mv /var/www/html/sendMsg/msn.txt.1/var/www/html/sendMsg/msn.txt -f 1/dev/null 21rm /var/www/html/cacti/plugins/thold/alert.log -f 1/dev/null 21for i in 0doif cat /var/www/html/sendMsg/msn.txt ; thenmessagescat /var/www/html/sendMsg/msn.txtsendMsg ${msnaddr[$i]}$messageselsecontinuefidone配置支持飞信报警[rootcacti software]# tar -jxvf feition.tar.bz2[rootcacti software]# mkdir -pv /var/www/html/sendsms/linuxso[rootcacti software]# cp linuxso_20101113/* /lib/[rootcacti software]# mv linuxso_20101113/* /var/www/html/sendsms/linuxso/[rootcacti software]# vim /var/www/html/cacti/plugins/thold/thold_functions.php添加这两行562 exec(echo $subject/var/www/html/cacti/plugins/thold/alert.log);563 exec(/var/www/html/cacti/plugins/thold/sendsms.sh);[rootcacti software]# vim /var/www/html/cacti/plugins/thold/sendsms.sh#!/bin/sh#send sms by fetion#Write by pingsun2010hotmail.comif [ ! -e/var/www/html/cacti/plugins/thold/alert.log ];thenecho Usage:alert.log does notexistexitfiif [ -n cat/var/www/html/cacti/plugins/thold/alert.log ]; thenadmin接收信息的帐号?echo sms $admin cat /var/www/html/cacti/plugins/thold/alert.log/var/www/html/cacti/plugins/thold/sms.txtecho exit /var/www/html/cacti/plugins/thold/sms.txtelseecho Usage:no alertexitfiif [ -n cat/var/www/html/cacti/plugins/thold/sms.txt ] ;then LD_LIBRARY_PATH/var/www/html/sendsms/linuxso/var/www/html/sendsms/linuxso/fetion --mobile发送信息的账户 --pwd密码 --to$admin --file-utf8/var/www/html/cacti/plugins/thold/sms.txtrm -f /var/www/html/cacti/plugins/thold/sms.txt 1/dev/null 21rm -f /var/www/html/cacti/plugins/thold/alert.log 1/dev/null 21elseecho Usgae:no message to sendexitfi[rootcacti thold]# chmod ax send*给新建的脚本添加可执行权限vim /var/www/html/cacti/plugins/thold/alert.log随便写点儿内容当飞信程序执行的时候会自动删除里面的内容可以新建alert.log以及sms.txt,其中在alert.log中添加一个内容。然后手工运行脚本进行测试需要保证本机能正常接入互联网。目前cacti的环境已经搭建完成cacti的使用还需要好好学习…… 转载于:https://blog.51cto.com/pjp5945/1317410