标签:登录 library server dev root stop create smp 查看
[root@linux-node1 ~]# uname -a Linux linux-node1 2.6.32-431.11.25.el6.ucloud.x86_64 #1 SMP Tue Jul 19 10:06:12 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux [root@linux-node1 ~]# cat /etc/redhat-release CentOS release 6.5 (Final)
通过yum安装所依赖的库以及环境
[root@linux-node1 ~]# yum -y install perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perl perl-RadiusPerl perl-IO-Socket-SSL perl-Socket6 perl-CGI-SpeedyCGI perl-FCGI perl-CGI-SpeedCGI perl-Time-HiRes perl-ExtUtils-MakeMaker perl-RRD-Simple rrdtool rrdtool-perl curl fping echoping httpd httpd-devel gcc make wget libxml2-devel libpng-devel glib pango pango-devel freetype freetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel mod_fastcgi screen
[root@linux-node1 ~]# cd /usr/local/src/ #进入默认源码包存放路径 [root@linux-node1 ~]# wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.9.tar.gz #下载smokeping包 [root@linux-node1 src]# tar xf smokeping-2.6.9.tar.gz #解压smokeping [root@linux-node1 src]# cd smokeping-2.6.9 #进入smokeping目录 [root@linux-node1 smokeping-2.6.9]# ./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty # [root@linux-node1 smokeping-2.6.9]# ./configure --prefix=/usr/local/smokeping #编译smokeping到/usr/local [root@linux-node1 smokeping-2.6.9]# /usr/bin/gmake install [root@linux-node1 smokeping-2.6.9]# cd /usr/local/smokeping/ #进入smokeping目录 [root@linux-node1 smokeping]# mkdir cache data var #创建三个目录 [root@linux-node1 smokeping]# touch /var/log/smokeping.log #创建smokeping日志文件 [root@linux-node1 smokeping]# chown apache.apache cache/ data/ var/ /var/log/smokeping.log #授权属主属组为apache [root@linux-node1 smokeping]# cd /usr/local/smokeping/htdocs/ #进入smokeping下htdocs目录 [root@linux-node1 htdocs]# mv smokeping.fcgi.dist smokeping.fcgi #修改smokeping文件名 [root@linux-node1 smokeping]# mv /usr/local/smokeping/etc/config.dist /usr/local/smokeping/etc/config #修改smokeping下etc目录smokeping
[root@linux-node1 smokeping]# sed -i ‘s#cgiurl = http://some.url/smokeping.cgi#cgiurl = http://当前主机IP/smokeping.cgi#g‘ /usr/local/smokeping/etc/config [root@linux-node1 smokeping]# sed -i ‘s#300#60#g‘ /usr/local/smokeping/etc/config #默认检测时间300秒修改60秒 [root@linux-node1 smokeping]# sed -i ‘s#20#60#g‘ /usr/local/smokeping/etc/config #默认ping20次,修改为60秒ping60次 [root@linux-node1 ~]# vim /usr/local/smokeping/etc/config #在presentation添加utf-8中文字符集 *** Presentation *** charset = utf-8 [root@linux-node1 smokeping]# chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist #修改密码权限为root只读
配置认证账号密码
[root@linux-node1 htdocs]# htpasswd -c /usr/local/smokeping/htdocs/htpasswd darker #设置登录密码认证 通过apache自带验证功能 New password: Re-type new password: Adding password for user darker
[root@linux-node1 ~]# vim /etc/httpd/conf/httpd.conf
#ServerName www.example.com:80 # 在此行下面添加如下一行,不然启动会报错
ServerName localhost:80
DocumentRoot "/var/www/html" #在这行下面添加如下---标红的代表密码验证 Alias /cache "/usr/local/smokeping/cache/" Alias /cropper "/usr/local/smokeping/htdocs/cropper/" Alias /smokeping "/usr/local/smokeping/htdocs/smokeping.fcgi" <Directory "/usr/local/smokeping"> AllowOverride None Options All AddHandler cgi-script .fcgi .cgi Order allow,deny Allow from all AuthName "Smokeping" AuthType Basic AuthUserFile /usr/local/smokeping/htdocs/htpasswd Require valid-user DirectoryIndex smokeping.fcgi </Directory>
[root@linux-node1 ~]# cat /etc/init.d/smokeping #!/bin/bash # # chkconfig: 2345 80 05 # Description: Smokeping init.d script # Write by : linux-Leon_xiedi # Get function from functions library . /etc/init.d/functions # Start the service Smokeping function start() { echo -n "Starting Smokeping: " /usr/local/smokeping/bin/smokeping >/dev/null 2>&1 ### Create the lock file ### touch /var/lock/subsys/smokeping success $"Smokeping startup" echo } # Restart the service Smokeping function stop() { echo -n "Stopping Smokeping: " kill -9 `ps ax |grep "/usr/local/smokeping/bin/smokeping" | grep -v grep | awk ‘{ print $1 }‘` >/dev/null 2>&1 ### Now, delete the lock file ### rm -f /var/lock/subsys/smokeping success $"Smokeping shutdown" echo } #Show status about Smokeping function status() { NUM="`ps -ef|grep smokeping|grep -v grep|wc -l`" if [ "$NUM" == "0" ];then echo "Smokeping is not run" else echo "Smokeping is running" fi } ### main logic ### case "$1" in start) start ;; stop) stop ;; status) status ;; restart|reload) stop start ;; *) echo $"Usage: $0 {start|stop|restart|reload|status}" exit 1 ;; esac exit 0
[root@linux-node1 ~]# chmod 755 /etc/init.d/smokeping #添加脚本755权限 [root@linux-node1 ~]# chkconfig --add smokeping #将smokeping加入开机启动 [root@linux-node1 ~]# chkconfig smokeping on #设置smokeping为开机启动 [root@linux-node1 ~]# chkconfig httpd on #设置apache为开机启动 [root@linux-node1 ~]# /etc/init.d/httpd restart #重启apache服务 [root@linux-node1 ~]# /etc/init.d/smokeping restart #重启smokeping服务
通过浏览器访问smokeping服务
注意事项:
1)在/usr/local/smokeping/etc/config中添加
2)smokeping就这点不好,添加节点不能在前台Web页面添加,一定要在后台的配置文件中添加。
3)修改/usr/local/smokeping/etc/config 后,必须重启smokeping 程序,配置才会生效
4)smokeping 会根据配置文件config
在/usr/local/smokeping/data 之下添加moniter文件夹,其下包含website子文件夹
5)用vmware
workstation的虚拟机测试有一点好处,workstation下的虚拟网卡可以设置出入的丢包率,适合smokeping做丢包测试, 经过测试smokeping检测出的丢包率与vmware worksation虚拟网卡设置的丢包率基本相同,也就是说smokeping 能够反应网络的真实状况。
添加监控节点示例:注意+是第一层,++是第二层,+++ 是第三层
1 + Other 2 3 menu = 三大网络监控 4 title = 监控统计 5 6 ++ dianxin 7 8 menu = 电信网络监控 9 title = 电信网络监控列表 10 host = /Other/dianxin/dianxin-bj /Other/dianxin/dianxin-hlj /Other/dianxin/dianxin-tj /Other/dianxin/dianxin-sc /Other/dianxin/dianxin-sh /Other/dianxin/dianxin-gz 11 12 +++ dianxin-bj 13 14 menu = 北京电信 15 title = 北京电信 16 alerts = someloss 17 host = 202.96.199.133 18 19 20 21 +++ dianxin-hlj 22 23 menu = 黑龙江电信 24 title = 黑龙江电信 25 alerts = someloss 26 host = 219.147.198.242 27 28 29 30 +++ dianxin-tj 31 32 menu = 天津电信 33 title = 天津电信 34 alerts = someloss 35 host = 219.150.32.132 36 37 38 39 +++ dianxin-sc 40 41 menu = 四川电信 42 title = 四川电信 43 alerts = someloss 44 host = 61.139.2.69 45 46 47 48 +++ dianxin-sh 49 50 menu = 上海电信 51 title = 上海电信 52 alerts = someloss 53 host = 116.228.111.118 54 55 56 57 +++ dianxin-gz 58 59 menu = 广东电信 60 title = 广东电信 61 alerts = someloss 62 host = 113.111.211.22 63 64 65 66 ++ liantong 67 68 menu = 联通网络监控 69 title = 联通网络监控列表 70 host = /Other/liantong/liantong-bj /Other/liantong/liantong-hlj /Other/liantong/liantong-tj /Other/liantong/liantong-sc /Other/liantong/liantong-sh /Other/liantong/liantong-gz 71 72 73 74 +++ liantong-bj 75 76 menu = 北京联通 77 title = 北京联通 78 alerts = someloss 79 host = 61.135.169.121 80 81 82 83 +++ liantong-hlj 84 85 menu = 黑龙江联通 86 title = 黑龙江联通 87 alerts = someloss 88 host = 202.97.224.69 89 90 91 92 +++ liantong-tj 93 94 menu = 天津联通 95 title = 天津联通 96 alerts = someloss 97 host = 202.99.96.68 98 99 100 101 +++ liantong-sc 102 103 menu = 四川联通 104 title = 四川联通 105 alerts = someloss 106 host = 119.6.6.6 107 108 109 110 +++ liantong-sh 111 112 menu = 上海联通 113 title = 上海联通 114 alerts = someloss 115 host = 210.22.84.3 116 117 118 119 +++ liantong-gz 120 121 menu = 广东联通 122 title = 广东联通 123 alerts = someloss 124 host = 221.5.88.88 125 126 127 128 ++ yidong 129 130 menu = 移动网络监控 131 title = 移动网络监控列表 132 host = /Other/yidong/yidong-bj /Other/yidong/yidong-hlj /Other/yidong/yidong-tj /Other/yidong/yidong-sc /Other/yidong/yidong-sh /Other/yidong/yidong-gz 133 134 135 136 +++ yidong-bj 137 138 menu = 北京移动 139 title = 北京移动 140 alerts = someloss 141 host = 221.130.33.52 142 143 144 145 +++ yidong-hlj 146 147 menu = 黑龙江移动 148 title = 黑龙江移动 149 alerts = someloss 150 host = 211.137.241.35 151 152 153 154 +++ yidong-tj 155 156 menu = 天津移动 157 title = 天津移动 158 alerts = someloss 159 host = 211.137.160.5 160 161 162 163 +++ yidong-sc 164 165 menu = 四川移动 166 title = 四川移动 167 alerts = someloss 168 host = 218.201.4.3 169 170 171 172 +++ yidong-sh 173 174 menu = 上海移动 175 title = 上海移动 176 alerts = someloss 177 host = 117.131.19.23 178 179 180 181 +++ yidong-gz 182 183 menu = 广东移动 184 title = 广东移动 185 alerts = someloss 186 host = 211.136.192.6
[root@linux-node1 ~]# service smokeping restart
原文:http://www.xuliangwei.com/xubusi/507.html
标签:登录 library server dev root stop create smp 查看
原文地址:http://www.cnblogs.com/chenjinxi/p/7794496.html