Smokeping搭建主從
阿新 • • 發佈:2018-10-12
fonts images core apache process 一個 evel type 分享
本文為個人思路,並非官方文檔(其實是找不到文檔自己琢磨出來的),如需轉載註明出處。
Author:aoxs
smokeping主從的作用就不做介紹了,可以百度查一下
下面直接上安裝過程
一、環境部署(準備兩臺Centos虛擬機,兩臺的安裝方法相同)
1.關閉防火墻和SElinux
# systemctl stop firewalld.service # systemctl disable firewalld.service # sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/‘ /etc/selinux/config # grep SELINUX=disabled /etc/selinux/config # setenforce 0
2.安裝EPEL源
# yum -y install epel-release
3.安裝繪圖工具、web服務、及Smokeping擴展包
# yum -y install rrdtool perl-rrdtool fping httpd openssl-devel
# yum -y install perl-core curl gcc gcc-c++ wget
二、安裝Smokeping服務
×××
# wget https://oss.oetiker.ch/smokeping/pub/smokeping-2.6.11.tar.gz
源碼編譯安裝Smokeping
# tar -xzvf smokeping-2.6.11.tar.gz # cd smokeping-2.6.11 # ./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty //用Smokeping自腳本安裝依賴包 # ./configure --prefix=/usr/local/smokeping //指定安裝路徑 # /usr/bin/gmake install
三、配置主從
·master端配置
1.配置web頁面支持中文
安裝一個中文字體
# yum -y install wqy-zenhei-fonts.noarch
2.創建相關文件夾個日誌文件(有部分在配置的時候會用到)
# cd /usr/local/smokeping # mkdir cache data var //建立存放圖像、數據、日誌的目錄 # touch /var/log/smokeping.log //建立日誌文件 # chown apache.apache cache/ data/ var/ /var/log //更改權限 # cd /usr/local/smokeping/htdocs # cp /smokeping.fcgi.dist smokeping.fcgi //將目錄內的fcgi文件重命名 # cd /usr/local/smokeping/etc # cp config.dist config //復制一份配置文件 # echo swbooo:123456 > /usr/local/smokeping/etc/smokeping_secrest.dist //指定slave的用戶名和密碼 # chmod 600 smokeping_secrets.dist //修改密碼文件權限
3.編輯SmokePing文件config
3.1 添加支持中文代碼
# vi /usr/local/smokeping/etc/config
charset = utf-8
3.2 修改配置文件中刷新時間 60秒ping20次
# vi /usr/local/smokeping/etc/config
3.3 添加監控項(此處可以用@include添加)
# vi /usr/local/smokeping/etc/config
eg:
***Slaves***
secrets=/usr/local/smokeping/etc/smokeping_secrets.dist
+swbooo #這裏設置Slave的名字,顏色等
display_name=swbooo
color=0000ff
*** Targets ***
+MasterTest
menu = test本機
++localhost
menu = 本機
title = localhost
host = 127.0.0.1
+slaves #配置Slave監控節點
menu = slave
++swbooo1
menu = 騰訊
title = 騰訊
slaves = swbooo
host = qq.com
++ swbooo2
menu = 百度
title = 百度
slaves = swbooo
host = baidu.com
4.配置apache服務(master端)
4.1修改配置文件
#末尾添加如下內容(此處其實就是做httpd開放訪問,環境不同可能會影響)
# vim /etc/httpd/conf/httpd.conf
·slave端配置(不需要修改配置文件)
1.創建相關文件夾個日誌文件
# cd /usr/local/smokeping
# mkdir cache data var //建立存放圖像、數據、日誌的目錄
# touch slave.log //建立日誌文件
# chown apache.apache cache/ data/ var/ slave.log //更改權限
# cd /usr/local/smokeping/htdocs
# cp smokeping.fcgi.dist smokeping.fcgi //將目錄內的fcgi文件重命名
# cp etc/smokeping_secrets.dist etc/smokeping_slave_secrets
# echo 123456 > etc/smokeping_slave_secrets //slave端只需要寫入密碼
# chmod 600 etc/smokeping_slave_secrets //修改密碼文件權限
·啟動服務(關鍵一步就在啟動服務)
master:
# /usr/local/smokeping/bin/smokeping restart
Note: logging to syslog as local0/info.
Daemonizing /usr/local/smokeping/bin/smokeping ...
slave:
# /usr/local/smokeping/bin/smokeping --master-url=http://masterIP/smokeping --cache-dir=/usr/local/smokeping/cache/ --shared-secret=/usr/local/smokeping/etc/smokeping_slave_secrets --slave-name=swbooo --logfile=/usr/local/smokeping/slave.log
Sent data to Server and got new config in response.
Note: logging to syslog as local0/info.
Daemonizing /usr/local/smokeping/bin/smokeping ...
最後確保master端的slave rrd文件,使apache有寫入權限
四、完成
瀏覽器訪問http://IP/smokeping
最終附上效果圖,會有兩行數據,一個主一個從
Smokeping搭建主從