1. 程式人生 > >分布式服務器監控工具NebulaSolarDash

分布式服務器監控工具NebulaSolarDash

nebula solar dash

分布式服務器監控工具NebulaSolarDash

詳細介紹:https://www.oschina.net/p/nebula-solar-dash

github: https://github.com/toddlerya/NebulaSolarDash#readme

工具分為客戶端和服務端兩部分: 服務端使用了 bottle 來作為 Web 框架,Echarts 來渲染生成圖表;客戶端使用 Python 原生類庫采集服務器資源。

* 以客戶端采集數據間隔時間120s為例,單節點24小時會向數據庫寫入大約4MB數據。
* 單個客戶端每次采集發送到服務端寫入數據庫的信息大概在5~6kb左右,請自行結合服務器個數以及監控時長和服務器存儲自行設定監控間隔。


1、下載安裝包NebulaSolarDash並解壓:

技術分享

[[email protected] ~]# unzip toddlerya-NebulaSolarDash-2.0.1-0-g58fe715.zip

Archive: toddlerya-NebulaSolarDash-2.0.1-0-g58fe715.zip

58fe71551f72441964ebcb7bb30fc0e436c9868c

creating: toddlerya-NebulaSolarDash-58fe715/

inflating: toddlerya-NebulaSolarDash-58fe715/LICENSE

inflating: toddlerya-NebulaSolarDash-58fe715/__init__.py

creating: toddlerya-NebulaSolarDash-58fe715/assets/

creating: toddlerya-NebulaSolarDash-58fe715/assets/css/

inflating: toddlerya-NebulaSolarDash-58fe715/assets/css/bootstrap.min.css

inflating: toddlerya-NebulaSolarDash-58fe715/assets/css/ns_tb.css

creating: toddlerya-NebulaSolarDash-58fe715/assets/js/

inflating: toddlerya-NebulaSolarDash-58fe715/assets/js/bootstrap.min.js

inflating: toddlerya-NebulaSolarDash-58fe715/assets/js/dark.js

inflating: toddlerya-NebulaSolarDash-58fe715/assets/js/echarts.min.js

creating: toddlerya-NebulaSolarDash-58fe715/assets/picture/

inflating: toddlerya-NebulaSolarDash-58fe715/assets/picture/NebulaSolarDash.gif

inflating: toddlerya-NebulaSolarDash-58fe715/assets/picture/NebulaSolarDash2.0.gif

creating: toddlerya-NebulaSolarDash-58fe715/conf/

inflating: toddlerya-NebulaSolarDash-58fe715/conf/__init__.py

inflating: toddlerya-NebulaSolarDash-58fe715/conf/ns.ini

inflating: toddlerya-NebulaSolarDash-58fe715/init_db.py

creating: toddlerya-NebulaSolarDash-58fe715/lib/

inflating: toddlerya-NebulaSolarDash-58fe715/lib/__init__.py

inflating: toddlerya-NebulaSolarDash-58fe715/lib/bottle.py

inflating: toddlerya-NebulaSolarDash-58fe715/lib/common_lib.py

inflating: toddlerya-NebulaSolarDash-58fe715/manager.py

inflating: toddlerya-NebulaSolarDash-58fe715/ns_agent.py

inflating: toddlerya-NebulaSolarDash-58fe715/ns_server.py

inflating: toddlerya-NebulaSolarDash-58fe715/readme.md

inflating: toddlerya-NebulaSolarDash-58fe715/release-note.txt

inflating: toddlerya-NebulaSolarDash-58fe715/run.py

inflating: toddlerya-NebulaSolarDash-58fe715/start_agent.sh

inflating: toddlerya-NebulaSolarDash-58fe715/start_insall_app.sh

inflating: toddlerya-NebulaSolarDash-58fe715/stop.py

inflating: toddlerya-NebulaSolarDash-58fe715/stop_uninstall_app.sh

inflating: toddlerya-NebulaSolarDash-58fe715/uninstall_app.sh

creating: toddlerya-NebulaSolarDash-58fe715/views/

inflating: toddlerya-NebulaSolarDash-58fe715/views/agent_info.tpl

inflating: toddlerya-NebulaSolarDash-58fe715/views/each_agent_detail.tpl


2、修改配置文件即設置server與client:

[[email protected] toddlerya-NebulaSolarDash-58fe715]# pwd

/root/toddlerya-NebulaSolarDash-58fe715

[[email protected] toddlerya-NebulaSolarDash-58fe715]# vim conf/ns.ini

[[email protected] toddlerya-NebulaSolarDash-58fe715]# cat conf/ns.ini

[server]

; 服務端IP

ip = 172.25.254.130

; 服務端端口號

port = 8081

debug = True

;報警信息閾值,百分比

;舉例:

;cpu_yellow = 80,代表cpu使用率達到80%即提示使用黃色標示

;cpu_red = 95,代表cpu使用率達到95%即提示使用黃色標示

mem_yellow = 80

mem_red = 95

cpu_yellow = 80

cpu_red = 95


[agent]

; 客戶端采集數據間隔時間, 單位是s

interval = 60

install_path = /home/RunTimeNSDash

;所有需要監控的節點的ip,以英文逗號分隔

[all_agent_ip]

ips = 172.25.254.134,172.25.254.135


3、出現驗證問題,接下來進行無秘鑰操作:

[[email protected] toddlerya-NebulaSolarDash-58fe715]# python manager.py -install

[+] 開始安裝客戶端到各個節點並自動啟動客戶端以及服務端

[+] 設置安裝目錄成功: /home/RunTimeNSDash

[+] 刪除歷史數據成功

[+] 啟動服務端成功

[+] 此次安裝的節點共計 2 個

[09/06/17 18:38:44] : INFO : 校驗服務器連通性: 172.25.254.134

[09/06/17 18:38:44] : INFO : 開始部署

Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).

[09/06/17 18:38:44] : ERROR : can not logon 172.25.254.134 without passwd.

[09/06/17 18:38:44] : INFO : 校驗服務器連通性: 172.25.254.135

[09/06/17 18:38:44] : INFO : 開始部署

Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).

[09/06/17 18:38:44] : ERROR : can not logon 172.25.254.135 without passwd.

[[email protected] toddlerya-NebulaSolarDash-58fe715]# ss

ss ssh ssh-agent sshd ssh-keygen ssltap

sserver ssh-add ssh-copy-id sshd-keygen ssh-keyscan

[[email protected] toddlerya-NebulaSolarDash-58fe715]# ssh-keygen

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):

/root/.ssh/id_rsa already exists.

Overwrite (y/n)? n

[[email protected] toddlerya-NebulaSolarDash-58fe715]# ssh-copy-id [email protected]

/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys

[email protected]‘s password:


Number of key(s) added: 1


Now try logging into the machine, with: "ssh ‘[email protected]‘"

and check to make sure that only the key(s) you wanted were added.


[[email protected] toddlerya-NebulaSolarDash-58fe715]# ssh-copy-id [email protected]

/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys

[email protected]‘s password:


Number of key(s) added: 1


Now try logging into the machine, with: "ssh ‘[email protected]‘"

and check to make sure that only the key(s) you wanted were added.


4、進行安裝部署操作

運行參數:

[[email protected] toddlerya-NebulaSolarDash-58fe715]# python manager.py -h

usage: manager.py [-h] [-install] [-uninstall] [-startall] [-stopall]

[-start START_ONE] [-stop STOP_ONE]

Manager Tool

optional arguments:

-h, --help show this help message and exit

-install 安裝客戶端到各個節點並自動啟動客戶端以

服務端

-uninstall 停止各個節點的客戶端並停止程序清理安裝

件,同時停止服務端

-startall 啟動各個節點的客戶端並設置crond守護

-stopall 停止各個節點的客戶端並去除crond守護

-start START_ONE 啟動一個指定節點的客戶端並設置crond守護

-stop STOP_ONE 停止一個指定節點的客戶端並去除crond守護



[[email protected] toddlerya-NebulaSolarDash-58fe715]# python manager.py -install

[+] 開始安裝客戶端到各個節點並自動啟動客戶端以及服務端

[+] 設置安裝目錄成功: /home/RunTimeNSDash

[+] 刪除歷史數據成功

[+] 啟動服務端成功

[+] 此次安裝的節點共計 2 個

[09/06/17 18:39:25] : INFO : 校驗服務器連通性: 172.25.254.134

[09/06/17 18:39:25] : INFO : 開始部署

[09/06/17 18:39:27] : INFO : 校驗服務器連通性: 172.25.254.135

[09/06/17 18:39:27] : INFO : 開始部署

[[email protected] toddlerya-NebulaSolarDash-58fe715]# python manager.py -startall

[+] 啟動各個節點的客戶端並設置crond守護

[+] 此次安裝的節點共計 2 個

[09/06/17 18:40:18] : INFO : 校驗服務器連通性: 172.25.254.134

[09/06/17 18:40:18] : INFO : 開始部署

[09/06/17 18:40:20] : INFO : 校驗服務器連通性: 172.25.254.135

[09/06/17 18:40:20] : INFO : 開始部署

[[email protected] toddlerya-NebulaSolarDash-58fe715]# lsof -i:8081

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

python 7588 root 4u IPv4 42008 0t0 TCP *:tproxy (LISTEN)



5、實驗的驗證

技術分享


技術分享

技術分享

Nebua-Solar服務器資源監控節點列表

序號主機名IP地址內存CPU
1host3172.25.254.134-109%0.08%
2web172.25.254.1351%0.45%

節點基礎信息 -- 各個圖表都可以使用鼠標拖動和滾輪縮放

主機名IP地址CPU內存(MB)SWAP(MB)操作系統內核版本運行時長當前時間
host3172.25.254.1342 x AMD Athlon(tm) X4 730 Quad Core Processor9770CentOS Linux 7.2.1511 Core3.10.0-327.el7.x86_6427 days, 4:51:3720170901-18:35:42

節點磁盤存儲信息統計

序號文件系統總大小已用剩余使用率掛載點
1/dev/mapper/centos-root18G2.2G16G13%/
2devtmpfs479M0479M0%/dev
3tmpfs489M0489M0%/dev/shm
4tmpfs489M50M440M11%/run
5tmpfs489M0489M0%/sys/fs/cgroup
6/dev/sda1497M126M372M26%/boot
7tmpfs98M098M0%/run/user/0



20170901-18:24:26
USAGE(%) : 0.08
NICE(%) : 0
USER(%) : 0.01
SYSTEM(%) : 0.06
IOWAIT(%) : 0.01

0.0668


20170901-18:31:27
平均負載值 : 0



節點基礎信息 -- 各個圖表都可以使用鼠標拖動和滾輪縮放

主機名IP地址CPU內存(MB)SWAP(MB)操作系統內核版本運行時長當前時間
web172.25.254.1352 x AMD Athlon(tm) X4 730 Quad Core Processor18230CentOS Linux 7.2.1511 Core3.10.0-514.26.2.el7.x86_6441 days, 4:19:1020170906-19:02:46

節點磁盤存儲信息統計

序號文件系統總大小已用剩余使用率掛載點
1/dev/mapper/centos-root18G12G6.1G66%/
2devtmpfs897M0897M0%/dev
3tmpfs912M144K912M1%/dev/shm
4tmpfs912M99M814M11%/run
5tmpfs912M0912M0%/sys/fs/cgroup
6/dev/sda1497M190M307M39%/boot
7tmpfs183M32K183M1%/run/user/0
8/dev/sr04.1G4.1G0100%/run/media/root/CentOS



20170906-18:57:32
USAGE(%) : 0.45
NICE(%) : 0.01
USER(%) : 0.12
SYSTEM(%) : 0.31
IOWAIT(%) : 0

20170906-18:57:32


20170906-18:55:31
平均負載值 : 0


本文出自 “跛鱉千裏,貴在分享” 博客,請務必保留此出處http://chenxiaotao.blog.51cto.com/11430805/1963211

分布式服務器監控工具NebulaSolarDash