码迷,mamicode.com
首页 > 系统相关 > 详细

linux6下网络环境监控工具smokeping部署

时间:2018-03-19 23:32:51      阅读:387      评论:0      收藏:0      [点我收藏+]

标签:bar   col   图片   天津   bsp   ase   cairo   smo   rip   

smokeping简介

smokeping是一款监控网络状态和稳定性的开源软件(它是rrdtool的作者开发的),通过它可以监控到公司IDC的网络状况,如延时,丢包率,是否BGP多线等;

smokeping会向目标设备和系统发送各种类型的测试数据包,测量、记录,并通过rrdtool制图方式,图形化地展示网络的时延情况,进而能够清楚的判断出网络的即时通信情况;

通过smokeping来监控IDC机房网络质量情况,可以从监控图上的延时与丢包情况分辨出机房的网络是否稳定,是否为多线,是否为BGP机房以及到各城市的三个运行商网络各是什么情况。如果出现问题,可以有针对性的去处理;如果选择新机房的时候,还可以根据smokeping的监控结果来判断这个机房是否适合。

需要注意的是:smokeping监控的是网络稳定性,而cacti或zabbix监控的是带宽使用情况(即进出口流量)、

smokeping部署过程

 安装smokeping的依赖包

[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

 部署smokeping

[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 

[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配置文件名称

 修改smokeping配置文件如下:

[root@goser1 smokeping]# vim  /usr/local/smokeping/etc/config 

cgiurl   = http://192.168.1.120/smokeping.cgi  #配置smokeping主机地址
*** Database ***

step     = 60      #默认检测时间300秒修改60秒
pings    = 60      #默认ping20次,修改为60秒ping60次
*** Presentation ***

charset = utf-8    #在presentation添加utf-8中文字符集

 修改smokeping密码文件的权限为root

[root@linux-node1 smokeping]# chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist

 设置smokeping登录密码认证

[root@linux-node1 htdocs]# htpasswd -c /usr/local/smokeping/htdocs/htpasswd darker
New password:
Re-type new password:
Adding password for user darker

 修改apache的配置文件,配置smokeping的站点

[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>

 创建smokeping的启动脚本,让smokeping可以启动、停止、重启、开机自启动等

[root@linux-node1 ~]# cat /etc/init.d/smokeping 
#!/bin/bash
#
# chkconfig: 2345 80 05
# Description: Smokeping init.d script
# Write by : goser
# 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

 启动httpd、smokeping服务并设置其开机自启动

[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 start    #启动apache服务

[root@linux-node1 ~]# /etc/init.d/smokeping start   #启动smokeping服务

 添加需要监控网络状态的站点或服务主机

  要添加站点或主机ip地址的话,只能再smokeping的配置文件中添加,无法通过smokeping的web界面添加,在添加完站点后重启smokeping,会在在/usr/local/smokeping/data 之下添加moniter文件夹,其下包含website子文件夹

  注意添加监控节点方式为:+是第一层,++是第二层,+++ 是第三层

技术分享图片
+ 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
添加三大运营商的站点

 要是添加的站点生效,必须重启smokeping服务(因为修改了smokeping的配置文件)

[root@goser1 smokeping]# /etc/init.d/smokeping restart  

 最后通过浏览器访问smokeping监控页面:http://192.168.1.120/smokeping  这时候页面可能会显示乱码,这是因为没有加载中文字体,接下来为smokeping添加一个字体

  安装字体:yum -y install wqy-zenhei-fonts.noarch

  编辑Graphs.pm:

vim /usr/local/smokeping/lib/Smokeping/Graphs.pm
#第147行下边插入下边一行

‘--font TITLE:20:"WenQuanYi Zen Hei Mono"‘,

  这样再刷新页面后,中文便显示正常,显示的smokeping页面如下:

技术分享图片 

linux6下网络环境监控工具smokeping部署

标签:bar   col   图片   天津   bsp   ase   cairo   smo   rip   

原文地址:https://www.cnblogs.com/goser/p/8605632.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!