博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
smokeping安装部署最佳实践
阅读量:6112 次
发布时间:2019-06-21

本文共 7175 字,大约阅读时间需要 23 分钟。

1.1安装smokeping

[root@linux-node2 ~]# cat /etc/redhat-release              #查看服务器信息

CentOS release 6.7 (Final)

[root@linux-node2 ~]# uname -r

2.6.32-573.el6.x86_64

 

[root@linux-node2 ~]# 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 #通过yum安装所依赖的库以及环境

[root@linux-node2 ~]# cd /usr/local/src/               #进入默认源码包存放路径

[root@linux-node2 ~]# wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.9.tar.gz #下载smokeping包

[root@linux-node2 src]# tar xf smokeping-2.6.9.tar.gz          #解压smokeping

[root@linux-node2 src]# cd smokeping-2.6.9        #进入smokeping目录

[root@linux-node2 smokeping-2.6.9]# ./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty            #

[root@linux-node2 smokeping-2.6.9]# ./configure --prefix=/usr/local/smokeping       #编译smokeping到/usr/local

[root@linux-node2 smokeping-2.6.9]# cd /usr/local/smokeping/         #进入smokeping目录

[root@linux-node2 smokeping]# mkdir cache data var         #创建三个目录

[root@linux-node2 smokeping]# touch /var/log/smokeping.log           #创建smokeping日志文件

[root@linux-node2 smokeping]# chown apache.apache cache/ data/ var/ /var/log/smokeping.log          #授权属主属组为apache

[root@linux-node2 smokeping]# cd /usr/local/smokeping/htdocs/     #进入smokeping下htdocs目录

[root@linux-node2 htdocs]# mv smokeping.fcgi.dist smokeping.fcgi   #修改smokeping文件名

[root@linux-node2 smokeping]# mv /usr/local/smokeping/etc/config.dist /usr/local/smokeping/etc/config   #修改smokeping下etc目录smokeping

1.2修改smokeping配置文件

[root@linux-node2 smokeping]# sed -i 's#cgiurl   = http://some.url/smokeping.cgi#cgiurl   =

http://10.0.0.8/smokeping.cgi#g' /usr/local/smokeping/etc/config

[root@linux-node2 smokeping]# sed -i 's#300#60#g' /usr/local/smokeping/etc/config        #默认检测时间300秒修改60秒

[root@linux-node2 smokeping]# sed -i 's#20#60#g' /usr/local/smokeping/etc/config

#默认ping20次,修改为60秒ping60次

[root@linux-node2 ~]# vim /usr/local/smokeping/etc/config               #在presentation添加utf-8中文字符集

*** Presentation ***

charset = utf-8

[root@linux-node2 smokeping]# chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist        #修改密码权限为root只读

1.3修改apache配置文件 

[root@linux-node2 htdocs]# htpasswd -c /usr/local/smokeping/htdocs/htpasswd darker      #设置登录密码认证  通过apache自带验证功能

New password:

Re-type new password:

Adding password for user darker

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>

1.4设置smokeping启动脚本

[root@linux-node2 ~]# cat /etc/init.d/smokeping                 #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

 

1.5启动服务以及访问smokeping

[root@linux-node2 ~]# chmod 755 /etc/init.d/smokeping   #添加脚本755权限

[root@linux-node2 ~]# chkconfig --add smokeping       #将smokeping加入开机启动

[root@linux-node2 ~]# chkconfig smokeping on   #设置smokeping为开机启动

[root@linux-node2 ~]# chkconfig httpd on    #设置apache为开机启动

[root@linux-node2 ~]# /etc/init.d/httpd restart    #重启apache服务

[root@linux-node2 ~]# /etc/init.d/smokeping restart   #重启smokeping服务

1.通过浏览器访问smokeping,如图1-1

 

图1-1

1.6添加需要监控的网站和节点

注意事项:

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 能够反应网络的真实状况。

     添加监控节点示例:注意+是第一层,++是第二层,+++ 是第三层

 

+ Other

menu = 三大网络监控

title = 监控统计

++ dianxin

menu = 电信网络监控

title = 电信网络监控列表

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

+++ dianxin-bj

menu = 北京电信

title = 北京电信

alerts = someloss

host = 202.96.199.133

 

+++ dianxin-hlj

menu = 黑龙江电信

title = 黑龙江电信

alerts = someloss

host = 219.147.198.242

 

+++ dianxin-tj

menu = 天津电信

title = 天津电信

alerts = someloss

host = 219.150.32.132

 

+++ dianxin-sc

menu = 四川电信

title = 四川电信

alerts = someloss

host = 61.139.2.69

 

+++ dianxin-sh

menu = 上海电信

title = 上海电信

alerts = someloss

host = 116.228.111.118

 

+++ dianxin-gz

menu = 广东电信

title = 广东电信

alerts = someloss

host = 113.111.211.22

 

++ liantong

menu = 联通网络监控

title = 联通网络监控列表

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

 

+++ liantong-bj

menu = 北京联通

title = 北京联通

alerts = someloss

host = 61.135.169.121

 

+++ liantong-hlj

menu = 黑龙江联通

title = 黑龙江联通

alerts = someloss

host = 202.97.224.69

 

+++ liantong-tj

menu = 天津联通

title = 天津联通

alerts = someloss

host = 202.99.96.68

 

+++ liantong-sc

menu = 四川联通

title = 四川联通

alerts = someloss

host = 119.6.6.6

 

+++ liantong-sh

menu = 上海联通

title = 上海联通

alerts = someloss

host = 210.22.84.3

 

+++ liantong-gz

menu = 广东联通

title = 广东联通

alerts = someloss

host = 221.5.88.88

 

++ yidong

menu = 移动网络监控

title = 移动网络监控列表

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

 

+++ yidong-bj

menu = 北京移动

title = 北京移动

alerts = someloss

host = 221.130.33.52

 

+++ yidong-hlj

menu = 黑龙江移动

title = 黑龙江移动

alerts = someloss

host = 211.137.241.35

 

+++ yidong-tj

menu = 天津移动

title = 天津移动

alerts = someloss

host = 211.137.160.5

 

+++ yidong-sc

menu = 四川移动

title = 四川移动

alerts = someloss

host = 218.201.4.3

 

+++ yidong-sh

menu = 上海移动

title = 上海移动

alerts = someloss

host = 117.131.19.23

 

+++ yidong-gz

menu = 广东移动

title = 广东移动

alerts = someloss

host = 211.136.192.6

 

 

转载于:https://www.cnblogs.com/wajika/p/6395320.html

你可能感兴趣的文章
类型、元类型、泛型
查看>>
读写锁 ReentrantReadWriteLock
查看>>
dpkg:错误:正在解析文件 '/var/lib/dpkg/updates/0014' 第 0 行附近:在字段名 #padding 中有换行符问题的解决方法...
查看>>
【Linux】Ctentos下载
查看>>
vue中config/index.js:配置的详细理解
查看>>
springboot将项目源代码打包
查看>>
微信小程序之if操作
查看>>
【全网最全的博客美化系列教程】06.推荐和反对炫酷样式的实现
查看>>
Oracle 11g服务器安装详细步骤——图文教程(系统 windows server 2012 R2)
查看>>
SQL Server如何用SQL实现一批字符串的全部组合
查看>>
054 kafka内部机制
查看>>
Java反射机制
查看>>
php 7 新特性整理小结
查看>>
学会了这项技能,你就能获得任何想要的信息!
查看>>
IOS开发--解析复杂json数据
查看>>
linux之 修改磁盘调度算法
查看>>
tp5 数据库Db查询操作
查看>>
java web 中 filter 与 servlet的关系
查看>>
WPF 自定义IconButton
查看>>
MQTT压力测试之Tsung的使用
查看>>