美文网首页
使用Web VMStat在网页上动态图形显示vmstat数据

使用Web VMStat在网页上动态图形显示vmstat数据

作者: 欧悦服务 | 来源:发表于2014-07-30 16:20 被阅读301次

功能

我们经常使用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可以把上面的数据在网页上动态图形显示出来,效果如下:

screenshot.png

项目

这个项目的地址如下:
https://github.com/joewalnes/web-vmstats

原理

这个小程序使用websocket协议,使用的websocket Server是websocketd,通过websocket接收vmstat程序员的输出,然后使用SmoothieCharts来画图。

如果不了解websocketed,可以参考项目地址或是我之前写的"WebSocket和websocketd"

使用

下载程序,然后运行

./run

前提已经说过了,你需要先安装websocketd

查看run文件,内容如下:

#!/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   

相关文章

网友评论

      本文标题:使用Web VMStat在网页上动态图形显示vmstat数据

      本文链接:https://www.haomeiwen.com/subject/xdastttx.html