设为首页 收藏本站
查看: 1309|回复: 0

[经验分享] cacti0.8.7g监控速配+msn,2010版飞信报警

[复制链接]
发表于 2019-1-12 08:15:26 | 显示全部楼层 |阅读模式
  Cacti安装,MSN,飞信报警测试系统:RHEL 5.4         cacti版本:cacti-0.8.7g本次实验在关闭防火墙,selinux的情况下实验的。本次需要的所有软件下载地址:http://u.115.com/file/f180e8f0d61.安装cacti主程序首先安装以下程序包:[root@localhost] # yum -y install httpd php php-mysql php-snmp mysql mysql-server perl-DBD-MySQL php-pdo net-snmp net-snmp-libs net-snmp-utils net-snmp-devel ruby ruby-devel使以下服务开机自启动。[root@localhost] # chkconfig mysqld on[root@localhost] # chkconfig httpd on[root@localhost] # chkconfig snmpd on修改 apache 配置文件[root@localhost] # vi /etc/httpd/conf/httpd.conf# 找到 AddType 添加如下二行AddType application/x-httpd-php  .phpAddType application/x-httpd-php-source  .phps#找到 DirectoryIndex index.html修改为:DirectoryIndex  index.php  index.html启动 mysql 与 http 服务[root@localhost] #  service mysqld start[root@localhost] #  service httpd start安装 rrdtool到rrdtool 网站:http://www.express.org/~wrl/rrdtool/ (找到最新版本即可)下载三个文件rrdtool-1.4.4-1.el5.wrl.i386.rpm   rrdtool-ruby-1.4.4-1.el5.wrl.i386.rpm   rrdtool-perl-1.4.4-1.el5.wrl.i386.rpm[root@localhost]# rpm -ivh /usr/local/src/rrdtool-*    安装三个包修改系统中的 snmp 设置[root@localhost] #  vi /etc/snmp/snmp.conf将com2secnotConfigUser default public改为:com2secnotConfigUser 127.0.0.1 public    (这是监控本地,被监控主机设置,后续介绍)将access  notConfigGroup “”  any   noauth    exact  systemview  none none改为:accessnotConfigGroup”&quot;  any noauth   exact   all none  none#view all    included  .1         80将前面的 # 注释去掉。重新启动 snmp 服务[root@localhost] #  service snmpd restart安装 cacti[root@localhost] # tar xzvf  cacti-0.8.7g.tar.gz[root@localhost] # mv cacti-0.8.7g/ var/www/html/cacti[root@localhost] # chmod 777 -R /var/www/html/cacti在Mysql中创建一个用于存储Cacti信息的数据库,数据库名称为cacti,新建一个数据库用户cacti ,设置密码为 cacti ,并赋予该用户对数据库cacti完全控制权限。导入/var/www/html/cacti目录中cacti.sql生成cacti数据库结构,然后编辑cacti的数据库配置文件。进入数据库[root@localhost] # mysqlMysql > CREATE DATABASE cacti;Mysql>insert into mysql.user(Host,User,Password) values(“localhost”,”cacti”,password(“cacti”));Mysql > flush privileges;Mysql > grant all privileges on cacti.* to cacti@localhost>Mysql > grant all privileges on cacti.* to cacti@127.0.0.1 identified by ‘cacti’;Mysql >flush privileges;Mysql > quit导数据进数据库[root@localhost] # mysql -ucacti -pcacti cacti < /var/www/html/cacti/cacti.sql修改 cacti 数据库配置文件[root@localhost] # vi /var/www/html/cacti/include/config.php修改成:$database_type= “ mysql ” ;$database_default = “cacti” ;$database_hostname = “ localhost ” ;$database_username = “cacti” ;$database_password = “cacti” ;加入一个计划任务,使得 cacti 每五分钟生成一个监控图表。[root@localhost] # crontab -e*/5 * * * * php /var/www/html/cacti/poller.php > /dev/null 2>&1打开浏览器,在浏览器地址栏中输入 http://IP/cacti,在第一次使用 cacti 时会显示cacti的安装指南,设置好一次后,以后就不会出现了。点击 “Next”由于是第一次安装,所以选择“New Install”,如果是升级安装,请选择升级安装,点击“Next”指定 rrdtool、 php、 snmp 工具的 Binary 文件路径,确保所有的路径都是显示 FOUND,而不是 NOT FOUND,点击 Finish 完成安装。Cacti 默认的用户名与密码是 admin,输入用户名与密码,点击 login为了安全的原因,第一次登录成功后,cacti 会强制要求你更改一个新的 password ,输入新密码并确认密码,点击 save ,进入 cacti 控制台界面.2.安装插件管理器Cacti版本:cacti 0.8.7g对应的PA 版本:PA 2.8要安装别的插件前,先要安装cacti的一个patch--Plugin Architecture,才能支持插件PA 2.8 = cacti 0.8.7g[root@station1~]# wget http://mirror.cactiusers.org/downloads/plugins/cacti-plugin-0.8.7g-PA-v2.8.zip[root@station1~]# unzip cacti-plugin-0.8.7g-PA-v2.8.zip[root@station1~]# cp -R cacti-plugin-arch/* /var/www/html/cacti/[root@station1~]# cd /var/www/html/cacti/[root@station1 cacti]# mysql -ucacti -pcacti cacti /var/www/html/cacti/plugins/thold/alert.log&quot;);exec(&quot;sh /var/www/html/cacti/plugins/thold/sendmessage.sh&quot;);保存退出3.然后编写个sendmessage.sh脚本,在/var/www/html/cacti/plugins/thold/这个目录下脚本内容===============================================================================#!/bin/shecho `echo -n &quot;date:&quot;&&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.1now=`date +%Y-%m-%d-%H:%M`SA=(test)msnaddr=(pingsun2010@hotmail.com)sendMsg(){num=0while [ $num -lt 1 ];dowget —post-data &quot;sender=pingsun2012@hotmail.com&password=123456&recipient=${1}&message=${2}&quot; http://127.0.0.1/sendMsg/index.php -O /var/www/html/sendMsg/index.php.1 >/dev/null 2>&1if [ -f /var/www/html/sendMsg/index.php.1 ]; thenif cat /var/www/html/sendMsg/index.php.1 |grep -i successfully >/dev/null 2>&1;thennum=1elif cat /var/www/html/sendMsg/index.php.1 |grep -i &quot;The user appears to be offline&quot; >/dev/null 2>&1;thennum=1echo &quot;The user is offline.&quot;exit 0elif cat /var/www/html/sendMsg/index.php.1 |grep -i &quot;Something went wrong trying to connect to the server&quot; >/dev/null 2>&1;thennum=1echo &quot;MSN server is online.&quot;exit 0elsenum=0firm -f /var/www/html/sendMsg/index.php.1elsenum=0fidone}mv /var/www/html/sendMsg/msn.txt /var/www/html/sendMsg/bak/msn$now.txt -f 1>/dev/null 2>&1mv /var/www/html/sendMsg/msn.txt.1 /var/www/html/sendMsg/msn.txt -f 1>/dev/null 2>&1rm /var/www/html/cacti/plugins/thold/alert.log -f 1>/dev/null 2>&1for i in 0doif cat /var/www/html/sendMsg/msn.txt ; thenmessages=`cat /var/www/html/sendMsg/msn.txt `sendMsg &quot;${msnaddr[$i]}&quot; &quot;$messages&quot;elsecontinuefidone===========================================================然后保存退出。(发送和接受者必须互为好友)4.手动运行sendmessage.sh这个脚本,如果没有问题,应该可以收到消息。4.飞信报警功能实现1.下载最新版飞信机器人。http://bbs.it-adv.net/viewthread.php?tid=1081&extra=page%3D1根据情况下载,因为会经常更新。 下载两个一个是fetion程序,一个是Linux下的库包linuxso-20101113.tar.gz2.飞信机器人放置位置Cd /var/www/htmlMkdir sendsmsCp linuxso_20101113 /var/www/html/sendsms/linuxsoCp fetion /var/www/html/sendsms/linuxso/fetionChmod 777 -R  /var/www/html/sendsms/linuxso搜thold_mail找到文件中的第一个这一句 : if (trim($alert_emails) != &quot;&quot;)                                thold_mail($alert_emails, '', $subject, $msg, $file_array);然后下面添加exec(&quot;echo $subject >>/var/www/html/cacti/plugins/thold/alert.log&quot;);exec(&quot;/var/www/html/cacti/plugins/thold/sendsms.sh&quot;);编写sendsms.sh脚本,内容如下:=========================================================#!/bin/sh#send sms by fetion#Write by pingsun2010@hotmail.comif [ ! -e &quot;/var/www/html/cacti/plugins/thold/alert.log&quot; ];thenecho &quot;Usage:alert.log does not exist&quot;exitfiif [ -n &quot;`cat /var/www/html/cacti/plugins/thold/alert.log`&quot; ]; thenadmin=&quot;150382XXXX&quot;echo &quot;sms $admin &quot;`cat /var/www/html/cacti/plugins/thold/alert.log` >>/var/www/html/cacti/plugins/thold/sms.txtecho &quot;exit&quot; >> /var/www/html/cacti/plugins/thold/sms.txtelseecho &quot;Usage:no alert&quot;exitfiif [ -n &quot;`cat /var/www/html/cacti/plugins/thold/sms.txt`&quot; ] ; thenLD_LIBRARY_PATH=/var/www/html/sendsms/linuxso /var/www/html/sendsms/linuxso/fetion --mobile=15803826990 --pwd=xxx --to=$admin --file-utf8=/var/www/html/cacti/plugins/thold/sms.txtrm -f /var/www/html/cacti/plugins/thold/sms.txt 1>/dev/null 2>&1rm -f /var/www/html/cacti/plugins/thold/alert.log 1>/dev/null 2>&1elseecho &quot;Usgae:no message to send&quot;exitfi============================================================保存,退出。测试一下。可以新建alert.log以及sms.txt,其中在alert.log中添加一个内容。然后运行脚本./sendsms.sh会返回以下结果,表示成功。 同时对方收到短信。[root@station1 thold]# ./sendsms.sh图形验证码已经生成,文件名为:15803826990.jpg请识别后输入图形验证码:Nm8p     #一般第一次会让你输入验证码。这个图片,在你的fetion的目录下。您输入的识别码是:nm8pSIP-C/4.0 280 Send SMS OKT: sip:759885962@fetion.com.cn;p=9283I: 3Q: 1 ML: 115D: Mon, 22 Nov 2010 15:28:45 GMTXI: 516723D0200B5C60F8747A8E9B4CFF55[root@station1 thold]#

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-662207-1-1.html 上篇帖子: 你还在用mrtg吗?--使用cacti监测系统性能 下篇帖子: CentOS4.8安装ntop4.01,集成到cacti
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表