天天看點

Deploy smokeping

Deploy smokeping

About SmokePing

SmokePing keeps track of your network latency:

Best of breed latency visualisation.

Interactive graph explorer.

Wide range of latency measurement plugins.

Master/Slave System for distributed measurement.

Highly configurable alerting system.

Live Latency Charts with the most 'interesting' graphs.

Free and OpenSource Software written in Perl written by Tobi Oetiker, the 

creator of MRTG and RRDtool

Official Link

oss.oetiker.ch

部署原因

監控内網環境,即使用ping來檢測是否丢包,或丢失包率等,并可實作郵件式報警

即當丢包率達到所設定的值時自動給某個郵箱發送報警(當然要有mail伺服器)

部署環境

CentOS 7.2

fping 3.10

perl v5.16.3

smokeping 2.6.10

安裝包下載下傳

CentOS (官方下載下傳)

fping (EPEL)

perl (CentOS自帶)

smokeping (官方下載下傳 位址上邊已經附加)

安裝步驟

1.安裝依賴包

# yum install -y rrdtool rrdtool-perl perl-libwww-perl perl-CGI perl-FCGI 

perl-Digest-MD5 perl-Digest-HMAC perl-CPAN perl-ExtUtils-CBuilder 

perl-ExtUtils-MakeMaker perl-Sys-Syslog fping (上邊一行指令)

(注如果出現某些包無法安裝,需要添加EPEL的yum源,這裡不做詳細介紹,可百度)

2.安裝perl插件

# perl -MCPAN -e "install Config::Grammar"  (這裡會進入互動界面)

yes  表示選擇自動配置

回車 這步含義是安裝perl子產品路徑,我使用的root是以直接回車,其它使用者可選其它

no   不讓他自動選擇擷取perl子產品源連接配接

yes  列出CPAN mirror list

2    選擇離你最近的源站點,我是Asia

8 我先的163的源站

回車 不自行手動設定cpan源站點

(此時便開始安裝Config::Grammar 時間可能會長一點) 

快到結束的時候會提示是否添加環境變量到~/.bashrc  我選的yes

3.編譯安裝smokeping

從官方下載下傳smokeping-2.6.10.tar.gz   (個人放置在/root目錄下)

位址: oss.oetiker.ch

# tar -xf /root/smokeping-2.6.10.tar.gz 

# cd /root/smokeping-2.6.10

# ./configure --prefix=/opt/smokeping  

(這裡指的是安裝路徑建議這個如果想改注意配置檔案等也要相應的做更改)

# make install

smokeping(安裝結束)

4.配置smokeping

# cd /opt/smokeping

# mkdir cache data var

# chown apache.apache cache/ data/ var/

# cd /opt/smokeping/etc

# cp config.dist config

# chmod 600 smokeping_secrets.dist

# cd /opt/smokeping/htdocs

# cp smokeping.fcgi.dist smokeping.fcgi

# vi config

 更改下邊的連結,我這個是改過的,前邊的IP改一下就OK了

 cgiurl   = http://10.10.128.128/smokeping.cgi

測試配置是否正常

# cd /opt/smokeping/bin

# ./smokeping --config=/opt/smokeping/etc/config --debug

如提示 Daemonizing ./bin/smokeping ...

表示沒有大問題了呵呵 

注意如果想開機啟動需要制作服務腳本呵呵

此時便可啟動了,把後邊的debug去掉就可以直接啟動了

5.安裝httpd并配置添加smokeping基于網頁式浏覽監控

# yum install httpd

配置通路smokeping目錄時需要輸入使用者密碼

# htpasswd -c /opt/smokeping/htdocs/htpasswd smokeping

# chown apache.apache /opt/smokeping/htdocs/htpasswd

# chmod 600 /opt/smokeping/etc/smokeping_secrets.dist

配置http網頁式通路smokeping監控

# vi /etc/httpd/conf/httpd.conf

在配置檔案最後添加

Alias /cache "/opt/smokeping/cache/"

Alias /cropper "/opt/smokeping/htdocs/cropper/"

Alias /smokeping "/opt/smokeping/htdocs/smokeping.fcgi"

<Directory "/opt/smokeping">

AllowOverride None

Options all

AddHandler cgi-script .fcgi .cgi

AllowOverride AuthConfig

Order allow,deny

Allow from all

AuthName "Smokeping"

AuthType Basic

AuthUserFile /opt/smokeping/htdocs/htpasswd

Require valid-user

DirectoryIndex smokeping.fcgi

</Directory>

此時便可啟動httpd服務

# systemctl start httpd.service

此時使用浏覽器通路http://IP/smokeping 即可檢視smokeping

IP要替換成伺服器的IP

6.添加監控節點

直接在/opt/smokeping/etc/config的後部直接添加即可

如我想監控192.168.1.1 則在其最後添加此幾行,即可實作監控

+IP1.1 (可自己定義,注意有可能特殊字元不支援)

menu = 1-1 (可自己定義,注意有可能特殊字元不支援)

title = 1-1 (可自己定義,注意有可能特殊字元不支援)

host = 192.168.1.1

部署總結

1. http服務裡的Alias 那幾個目錄都是被smokeping所用到的

2. smokeping目錄裡bin smokeping --debug可以檢視到錯誤

3. smokeinfo /path/config-file 可以簡單檢視監控節點的狀态

4. 密鑰檔案不可以讓組和其它有任何的權限

繼續閱讀