|
<我的原文发表在:http://charlescui.javaeye.com/blog/506623>
大家要是看不到图片,请看我原文.
两个项目的代码都在GemCube上:
http://gemcutter.org/gems/lpm
http://gemcutter.org/gems/lpmp
这两个项目其实是一个大项目--> <<倩女幽魂>>
但分开用完全没问题.
为什么叫倩女幽魂呢?
因为我想发扬中华传统文化.
这个监控跟别的监控系统相比的优势我认为在于:
1.安装和运行非常方便.
2.实时监控!
安装:
Ruby代码
gem i lpm --source http://gemcutter.org/
gem i lpmp --source http://gemcutter.org/
运行:
引用
(sudo )lpmp --memcache=10.2.226.133:11011,10.2.226.133:11012 --log_level=0 --mode=XQPUSH
(sudo )lpm -t 15 --memcache=10.2.226.133:11011,10.2.226.133:11012 -P --pids=28261,28263 --log_level=3
设计思路:
我随便写下啊,
LPM是Rest Server提供主机数据,安装在被监控服务器上.
LPMP也是Rest Server,处理LPM得到的数据.安装在监控服务器上.
LPM和LPMP可以N对1,也就是同时监控多台服务器.
LPMP提供web服务,有动态的图表展示,实时更新数据,这是由前端JS控制的.
但由于我美工没什么功底,目前只会用EXT做页面,所以LPMP体积有点大,大部分是Extjs占用掉了.
目前设计了三种LPM和LPMP的通讯模式:
1.LPMP主动抓LPM数据.实时得到最新数据.
2.LPMP主动抓LPM数据.后台若干进程抓取,然后放到memcache里,请求来了后LPMP主进程直接从cache里面拿做好的数据.
3.LPM直接往Cache里面扔数据,LPMP主进程直接访问cache.
第三个最常用,第一个做演示用或者没有cache时候用.当我想到第三种设计方式的时候,第二种设计就暂停了,没必要.
顺便再说一句,LPM目前只支持Linux系统监控.
下面是LPMP和LPM的使用帮助:
安装好LPMP后,可以在命令行直接敲入命令:lpmp --help =>
引用
ubuntu:~$ lpmp --help
CaiChen [also named => L(inux) P(roc) M(onitor) P(ortal)] :
Mail/Gtalk: zheng.cuizh@gmail.com
Usage: lpmp [options] argv...
(sudo )lpmp --memcache=10.2.226.133:11011,10.2.226.133:11012 --log_level=0 --mode=XQPUSH
LPMP optins useage:
-p, --port=PORT lpmp server requires a port number.
default port=6789
--mode [MODE] PULL : (default) lpmp server will request data from lpm server when a request coming.
This mode require a high performance lpmp server,it's used to be a daemon.
BGPULL : This mode will run some background process at lpmp server.
It needs memcaches.see --memcache=[LIST,LIST]
XQPUSH : This mode will get data from memcache when a request come from client.
This mode is the heighest performance of the three.
It also needs memcaches.see --memcache=[LIST,LIST]
default --mode=PULL.
-m, --memcache=LIST,LIST memcache list,such as : --memcache=10.2.226.38:11211,10.2.226.37:11211
memcache server(s) must be alive.
-l, --log=LogPath default --log=/var/log/lpmp.log
--log_level=LogLevel 1 => DEBUG
2 => INFO
3 => WARN
4 => ERROR
5 => FATAL
default --log_level=3
-t=60 Make sure the LPMP server's datatime is same as LPM server,
or the difference is little than timeout,else the memcache data will not available for LPMP
(sudo )ntpdate 10.2.228.8(your date server ip)
default -t=60
common options:
--help show this message
--version show version
同样,安装好LPM后,直接敲入:lpm --help =>
引用
ubuntu:~$ lpm --help
XiaoQian [also named => L(inux) P(roc) M(onitor)] :
Mail/Gtalk: zheng.cuizh@gmail.com
Usage: lpm [options] argv...
LPM optins useage:
-p, --port=PORT lpm rest server requires a port number.
default port=9876
-P, --[no-]push if push is given, the --memcache must be set,
and a job will push server performance data to memcache server.
default --push=false.
-t, --timer=Second periodic timer to push cache
default --timer=10(second).
-m, --memcache=[LIST,LIST] memcache list,such as : --memcache=10.2.226.38:11211,10.2.226.37:11211
memcache server(s) must be alive.
-l, --log=LogPath default --log=/var/log/lpm.log
--log_level=LogLevel 1 => DEBUG
2 => INFO
3 => WARN
4 => ERROR
5 => FATAL
default --log_level=3
--pids=[PID,PID] pids list,such as : --pids=1234,2134,4321
common options:
--help show this message
--version show version
LPM is short for Linux Proc Monitor.
LPM是一个监控Linux主机性能参数的类库,带有一个web server,提供网页访问接口,前提是你安装过"sinatra".主要监控的是Linux主机性能常用参数,比如主机CPU,Load,Memory等,还可以监控单个进程的参数指标比如单进程消耗的CPU等.
该项目将和另外一个项目合并,当然完全可以单独拿出来使用。
合并后, LPM中文项目名将叫:小倩
另外一个项目--LPMP中文项目名将叫:采臣
采臣将使用小倩提供的数据,提供一个对外的统一监控界面,强大之处在于采臣支持分布式多服务器端监控。
引用
残寒消尽,疏雨过,清明后。 花径款余红,风沼萦新皱。 乳燕穿庭户,飞絮沾襟袖。 正佳时,仍晚昼,著人滋味,真个浓如酒。
频移带眼,空只恁,厌厌瘦。 不见又思量,见了还依旧。为问频相见,何似长相守。 天不老,人未偶,且将此恨,分付庭前柳。
It provides current performance of a linux host,and the command 'lpm' is a web server supported by sinatra,you could type in 'lpm' in command shell,then access the http://localhost:9876/,some information will be show.
If you want get some help,plz check out the test/.rb.
Example:
# below are some test cases for LPM:roc
Ruby代码
require "lpm"
require "Benchmark"
require "pp"
Benchmark.bm do |x|
x.report("CPU"){pp LPM:roc.cpu}
x.report("CPU(5)"){pp LPM:roc.cpu(5)}
x.report("CPU(10)"){pp LPM:roc.cpu(10)}
x.report("CPU(15)"){pp LPM:roc.cpu(15)}
end
# => below test is for LPM:roc
pp "LPM:roc.loadavg => #{LPM:roc.loadavg}"
pp "LPM:roc.uptime => #{LPM:roc.uptime}"
pp "LPM::Proc.meminfo => #{LPM::Proc.meminfo}"
pp "LPM::Proc.cpuinfo => #{LPM::Proc.cpuinfo}"
# below are some test cases for LPM::Process
require "lpm" require "Benchmark" require "pp"
# => below test is for LPM::Utils
pp "LPM::Utils.ulimit => #{LPM::Utils.ulimit}"
pp "LPM::Utils.locale => #{LPM::Utils.locale}"
pp "LPM::Utils.sysctl => #{LPM::Utils.sysctl}"
# => LPM::Utils can also be used as
pp "LPM::Proc.ulimit => #{LPM::Proc.ulimit}"
pp "LPM::Proc.locale => #{LPM::Proc.locale}"
pp "LPM::Proc.sysctl => #{LPM::Proc.sysctl}"
这里是LPMP的截图:
点击一个主机可以打开一个tab
页面还比较简陋 |
|