功能
我們經(jīng)常使用vmstat是不是就下面這個樣子的:
$ vmstat 1
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
3 0 43652 2742600 453820 2829164 0 0 1 10 0 0 6 1 93 0
1 0 43652 2742784 453820 2829164 0 0 0 0 3106 5701 11 1 87 0
0 0 43652 2742908 453820 2829164 0 0 0 0 3898 6703 11 2 87 0
1 0 43652 2743672 453820 2829164 0 0 0 32 3844 6708 11 2 87 0
2 0 43652 2743980 453820 2829164 0 0 0 80 4130 7164 11 2 87 0
web wmstat可以把上面的數(shù)據(jù)在網(wǎng)頁上動態(tài)圖形顯示出來慨默,效果如下:
screenshot.png
項目
這個項目的地址如下:
https://github.com/joewalnes/web-vmstats
原理
這個小程序使用websocket協(xié)議,使用的websocket Server是websocketd曙强,通過websocket接收vmstat程序員的輸出诈嘿,然后使用SmoothieCharts來畫圖述呐。
如果不了解websocketed篮迎,可以參考項目地址或是我之前寫的"WebSocket和websocketd"
使用
下載程序甫菠,然后運行
./run
前提已經(jīng)說過了仔粥,你需要先安裝websocketd婴谱。
查看run文件蟹但,內(nèi)容如下:
#!/bin/sh
# Download websocketd for your platform from
# https://github.com/joewalnes/websocketd/wiki/Download-and-install
./websocketd --port=9231 --staticdir=web /usr/bin/vmstat -n 1