linux

网络监控smokeping

发布时间:7年前热度: 4172 ℃评论数:

1、依赖包安装
yum groupinstall “Compatibility libraries” “Base” “Development tools” -y
yum -y install cpan perl perl-FCGI perl-CGI perl-Digest-HMAC perl-Net-Telnet perl-Net-OpenSSH perl-Net-SNMP perl-LDAP perl-Net-DNS perl-IO-Pty-Easy perl-Test-Simple perl-Sys-Syslog perl-libwww-perl perl-IO-Socket-SSL perl-Socket6 perl-CGI-SpeedyCGI perl-FCGI perl-Time-HiRes perl-ExtUtils-MakeMaker rrdtool rrdtool-perl curl fping 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_fcgid screen openssl openssl-devel popt-devel
yum -y install wqy-zenhei-fonts fping

2、安装echoping
tar xvf echoping-6.0.2.tar.gz
cd echoping-6.0.2
./configure –prefix=/usr/local/echoping –with-ssl –without-libidn
make -j 2 && make install

3、安装smokeping
下载地址:http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.11.tar.gz
tar -xvf smokeping-2.6.11.tar.gz
cd smokeping-2.6.11

export PERL5LIB=/usr/local/smokeping/thirdparty/lib/perl5/
./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty
./configure –prefix=/usr/local/smokeping
gmake install

4 创建相关目录和日志文件(因为这里的web服务器使用的是httpd,所以相关文件的属主属组均为apache)

cd /usr/local/smokeping
mkdir cache data var
touch /var/log/smokeping.log
chown apache.apache cache/ data/ var/ /var/log
chown daemon.daemon cache/ data/ var/ /var/log

5 创建相关配置文件

#fcgi文件
cp /usr/local/smokeping/htdocs/smokeping.fcgi.dist /usr/local/smokeping/htdocs/smokeping.fcgi
#主配置文件
cp /usr/local/smokeping/etc/config.dist /usr/local/smokeping/etc/config

6 修改配置文件

#指定cgi的url地址为本机
sed -i ‘s#cgiurl = http://some.url/smokeping.cgi#cgiurl = http://10.80.6.12/smokeping/smokeping.cgi#g’ /usr/local/smokeping/etc/config
#指定检测的时间为60秒
sed -i ‘s#step = 300#step = 60#g’ /usr/local/smokeping/etc/config
#指定ping的次数为60
sed -i ‘s#pings = 20#pings = 60#g’ /usr/local/smokeping/etc/config

将step和pings都设置为60表示每60秒ping60次。

7 修改字符集和字体支持中文

vim /usr/local/smokeping/etc/config
***Presentation *** # 加在 ***Presentation *** 后面
charset = utf-8

vim /usr/local/smokeping/lib/Smokeping/Graphs.pm +147

my$val = 0;

formy $host (@hosts){

my ($graphret,$xs,$ys) = RRDs::graph

(“dummy”,

‘–start’, $tasks[0][1],

‘–end’, $tasks[0][2],

‘–font TITLE:20″WenQuanYiZen Hei Mono”‘, #添加这一行

“DEF:maxping=$cfg->{General}{datadir}${host}.rrd:median:AVERAGE”,

‘PRINT:maxping:MAX:%le’);

my $ERROR = RRDs::error();

8 修改apache配置文件增加登录验证

htpasswd -c /usr/local/smokeping/htdocs/htpasswd smokeping
chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist

9 修改httpd.conf增加smokeping的web界面

在httpd.conf末尾添加如下内容

vim /etc/httpd/conf/httpd.conf

#########changed by lance 2018/03/23##############
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
AllowOverride AuthConfig
Order allow,deny
Allow from all
AuthName “Smokeping”
AuthType Basic
AuthUserFile /usr/local/smokeping/htdocs/htpasswd
Require valid-user
DirectoryIndex smokeping.fcgi
</Directory>

10 添加监控对象

vim /usr/local/smokeping/etc/config

*** Targets ***
++ Localhost
menu = Localhost
title = Localhost
alerts = someloss
#slaves = boomer slave2
host = 192.168.3.13

11、添加启动脚本

vim /usr/lib/systemd/system/smokeping.service

[Unit]
Description=Latency Logging and Graphing System
After=syslog.target network.target

[Service]
ExecStart=/usr/local/smokeping/bin/smokeping –nodaemon
ExecReload=/bin/kill -HUP $MAINPID
StandardError=syslog

[Install]
WantedBy=multi-user.target

touch /usr/local/smokeping/var/smokeping.pid

/usr/local/smokeping/bin/smokeping –master-url=http://10.80.6.12:1000/smokeping/sm.cgi –logfile=/var/log/smokeping.log –cache-dir=/usr/local/smokeping/cache –shared-secret=/usr/local/smokeping/etc/secret.txt –slave-name=test

smokeping,网络监控

手机扫码访问