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