Spy2Servers

Easy to establish your own system-monitor platform



Project

Download Spy2Servers

User Guide

Developer Guide

Spring-integration support

Document(Chinese)

Api Docs

More information

User Guide

Only serveral steps will help you to eastablish Tomcat and ActiveMQ monitor platform.

The following prerequisites are required for this tutorial:

  • Spy2Servers-1.2.x
  • JDK 1.5 or greater

1. download Spy2Servers-1.2.x and then unzip to a local directory.

2. modify the ${spy2servers.home}/conf/spy2servers.xml file.

  2a. Namespace support for all xml transformers is provided in the Spy2Servers xml namespace.

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.xmatthew.org/spy2servers/schema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.xmatthew.org/spy2servers/schema
http://www.xmatthew.org/spy2servers/schema/spy2servers-1.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">

  2b. Define the core component(must define), and configure the alert rule for each components.

  <core-component>
<simple-alertRule>
<channel>
<from value="ActiveMQJmxSpyComponent"/>
<from value="TomcatJmxSpyComponent"/>
<to value="PrintScreenAlertComponent"/>
<to value="EmailAlertComponent" />
</channel>
<!--
efine more here
<channel>
</channel>
-->
</simple-alertRule>
</core-component>

Here we use <simple-alertRul> to configure alert rule. The monitor messages from "ActiveMQJmxSpyComponent" and "TomcatJmxSpyComponent" will be route to the "PrintScreenAlertComponent" and "EmailAlertComponent" alert component.

  2c. Open Jmx supporting. using port number is 1616. <!--default port is 1099-->

  <jmxService-component name="jmxAwareComponent" port="1616" /> 

  2d. Open web monitor plat supporting. using port number is 7758. you can visit http://localhost:7758/admin by your web browser.

  <jetty>
<connectors>
<nioConnector port="7758" />
</connectors>
<handlers>
<servlet servletClass=
"org.xmatthew.spy2servers.component.web.ComponentsViewServlet" path="/admin" />
</handlers>
</jetty>

  2e. Configure Apache Tomcat server monitor component.

 <tomcatJmxSpy host="xx.xx.xx.xx" port="8060" name="TomcatJmxSpyComponent">
<heapMemorySpy memoryUsedPercentToAlert="90" alertAfterKeepTimeLive="10"/>
<noneHeapMemorySpy memoryUsedPercentToAlert="90" alertAfterKeepTimeLive="10"/>
<fileSpy filesOpenedPercentToAlert="90" alertAfterKeepTimeLive="10"/>
<dataSourcesSpy>
<dataSourceSpy numActivePercentToAlert="90" dataSourceName="jdbc/opendb" />
</dataSourcesSpy>
<webModuleSpy>
<module value="/" />
<module value="/jsp-examples" />
</webModuleSpy>
<llegalIps>
<ip value="127.0.0.1" />
<ip value="192.168.0.1" />
</llegalIps>
</tomcatJmxSpy>

host: tomcat server host ip. port: tomcat jmx service port. name: tomcat monitor bean id.
<heapMemorySpy/><noneHeapMemorySpy/> for memory usage monitor.
  memoryUsedPercentToAlert: event triggers when your operation system's memory usage percent exceed the set value.
  alertAfterKeepTimeLive: unit is second. if duration time of memory usage percent exceed exceed the set value, event will trigger.
  memoryUsedToAlert: unit is mb. if memory usage exceed the set value, event will trigger.Note this value only works when memoryUsedPercentToAlert is not set.
<fileSpy/>monitor for number of files open .
  filesOpenedPercentToAlert: event triggers when number of your operation system's files open percent exceed the set value .
  alertAfterKeepTimeLive: unit is second. if duration time of the number of files open percent exceed the set value, event will trigger.
  filesOpenedToAlert: if the number of files open exceed the set value, event will trigger. Note this value only works when filesOpenedPercentToAlert is not set.
<dataSourceSpy/> data source connection pool monitor
  numActivePercentToAlert: event triggers when number of your data source connection pool usage percent exceed the set value .
  numActiveToAlert: if the number of your data source connection pool usage exceed the set value, event will trigger.Note this value only works when numActivePercentToAlert is not set.
<webModuleSpy/> web module monitor
  module: monitor if the web module is active. event triggers if module become inactive.
<llegalIps/> legal ips list
  ip: to set the allowed remote client ip. if incoming remote client ip not in the list then event will trigger.


 2f. Configure email alert component.

  <emailAlert> 
<emails>
<email value="email_username@xmatthew.com" />
</emails>
<emailAccount server="smtp.server.com" serverPort="25" loginName="xmatthew"
loginPwd="xxxxxx" sender="email_username@xmatthew.com"
sendNick="EmailAlertComponent"/>
</emailAlert>

  Your should configure your email account and email server info correctly.
  All the messages will send mail to <emails> attribute value. This example shows that messages will send email to "email_username@xmatthew.com"

3. parse monitor Message
   Message class

public class Message {

    public static final int LV_ERROR = 1;

public static final int LV_WARN = 2;

public static final int LV_FATAL = 3;

public static final int LV_INFO = 4;

private String id;

private String body;

private int level;

private Map properties;

private Date createDate;

private String description;

private String type; }

body: message detail.
level: message level. LV_ERROR, LV_WARN,LV_FATAL, LV_INFO
Id: message Id. unique key
setDescription: message description
type: message type. eg. WebModuleStatus, DataSourceStatus, MemoryStatus, FilesOpenStatus
properties: message properties. usualy put key-value info.

4. run the spy2servers.
under windows:
   %spy2servers.home%/conf/start.bat
under linux:
   ${spy2servers.home}/conf/start.sh

5. shutdown the spy2servers.
under windows:
  %spy2servers.home%/conf/shutdown.bat
under linux:
  ${spy2servers.home}/conf/shutdown.sh

ActiveMQ monitor component configuration is same to Tomcat monitor component. you can download the spy2server binary package for detail. click here .

 	

Author: Matthew Xie
Blog site: 孤独键盘手
Email: ant_miracle@163.com

News

01/05/2009

Spy2Server v1.2.0 support to spring-integration. user guide and developer guide update

01/03/2009

Spy2Server v.1.1.0 document update. a ms word document file has include in the project.

05/05/2008

Spy2Server v.1.1.0 has been released.

09/04/2008

First ever release of Spy2Server ! More information about Spy2Server v.1.0.0 can be found on web site