spy2servers項(xiàng)目發(fā)布后,得到很多朋友的支持,本人在此表示感謝。本次更新,主要實(shí)現(xiàn)了內(nèi)置了Jetty Web服務(wù)器,提供
基于web方式查看監(jiān)控平臺(tái)的所有組件運(yùn)行狀態(tài)。針對(duì)原來(lái)提供的基于JMX的運(yùn)行狀態(tài)監(jiān)控相比,Web方式要方便很多,無(wú)需運(yùn)行jconsole。
下載地址:
二進(jìn)制程序
第三方類庫(kù)下載,第三方類庫(kù)下載2 Jetty類庫(kù) 放到lib目錄下。
api-docs
源代碼
我來(lái)看一下如何在 spy2servers 配置Jetty并啟動(dòng)web方式的組件監(jiān)控服務(wù)。
配置方法非常簡(jiǎn)單,使用我們簡(jiǎn)單后的Spring配置。下面是配置說(shuō)明,在spy2servers.xml中,加入
<jetty>
<connectors>
<nioConnector port="7758" /> <!-- using nio connector port is 7758 -->
</connectors>
<handlers>
<!-- org.xmatthew.spy2servers.component.web.ComponentsViewServlet is our web spy servlet, /admin is our servlet path -->
<servlet servletClass="org.xmatthew.spy2servers.component.web.ComponentsViewServlet" path="/admin" />
</handlers>
</jetty>
<connectors>
<nioConnector port="7758" /> <!-- using nio connector port is 7758 -->
</connectors>
<handlers>
<!-- org.xmatthew.spy2servers.component.web.ComponentsViewServlet is our web spy servlet, /admin is our servlet path -->
<servlet servletClass="org.xmatthew.spy2servers.component.web.ComponentsViewServlet" path="/admin" />
</handlers>
</jetty>
配置是不是非常的簡(jiǎn)單, 這樣就啟動(dòng)了web服務(wù) 訪問(wèn)址 http://localhost:7758/admin。 使用的是7758端口,servlet path是/admin.
下面看一下,進(jìn)入后頁(yè)面的內(nèi)容:
最上面分別是三個(gè)標(biāo)簽:分別選擇查看 SpyComponents AlertComponents ChannelAwareComponents 三種組件組件。默認(rèn)進(jìn)入的是SpyComponents
上面圖片中,我們可以看到SpyComponents類共配置了三個(gè)監(jiān)控組件。
我們拿其中一個(gè)再說(shuō)明一下:
ActiveMQJmxSpyComponent
message count=0 #監(jiān)控消息個(gè)數(shù)
component status=Active #組件的狀態(tài)
startup date=2008-04-22 22:25:09 #組件啟動(dòng)的時(shí)間
如果有消息監(jiān)控到,則會(huì)顯示如下:
ActiveMQJmxSpyComponent
message count=2
component status=Active
startup date=2008-04-22 22:25:09
|
||||||||||||||
|
接下來(lái),細(xì)心的朋友發(fā)現(xiàn)還有一個(gè)AlertRule鏈接,這個(gè)又不是組件,這個(gè)是做什么的呢?
現(xiàn)在我來(lái)解釋一下,我們?cè)诙xcore-componet標(biāo)簽的時(shí)候,平臺(tái)支持定義消息的流轉(zhuǎn)規(guī)則,下面這是可視化的標(biāo)識(shí)哪些消息從那個(gè)監(jiān)控
組件過(guò)來(lái),將會(huì)發(fā)送到哪個(gè)報(bào)警組件消息上去
下面是一個(gè)演示界面:
Components alert rule:
from | to |
AMQ16Component | PrintScreenAlertComponent |
ActiveMQJmxSpyComponent | PrintScreenAlertComponent EmailAlertComponent |
SunJVMJmxSpyComponent | PrintScreenAlertComponent EmailAlertComponent |
TomcatJmxSpyComponent | PrintScreenAlertComponent EmailAlertComponent |
其中的內(nèi)容很好解理,from就是指監(jiān)控組件, to指的就是報(bào)警組件。
基于web方式的查看監(jiān)控的組件情況,是不是很方便呢 :)。
最后歡迎大家如果有問(wèn)題和意見(jiàn),給我留言。
Good Luck!
Yours Matthew!