1. hyperic JMX插件
作为java为服务端语言的web项目,JMX MBean是监控管理很好的选择。Hyperic可以很容易地mbean集成进来。Hyperic可以自动发现定义好的Mbean服务类型的服务。
JMX监控插件开发步骤
(1) 设计好自己所要监控的业务逻辑,开发Mbean
我们可以借助Spring JMX来开发Mbean。Spring可以将spring bean暴露成model mbean。Spring Jmx可以定制assembler来过滤需要开放的属性和服务,支持annotation的方式。Connector可以更改服务的协议。具体可以参考spring 文档关于JMX一节。
package com.nali.monitor;
import org.apache.log4j.Logger;
public class TestMbean {
private static Logger logger = Logger.getLogger(TestMbean.class);
private int avalibility;
private int number;
private int throughput;
public int getAvalibility() {
return avalibility;
}
public int getNumber() {
return number;
}
public int getThroughput() {
return throughput;
}
public boolean start() {
logger.info("start");
return true;
}
public boolean end() {
logger.info("end");
return true;
}
}
|
我们可以通过Mbean观察availability,throughput,number三个属性值的变化,start,end为两个管理(control)操作。
Spring 配置
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd
"
default-lazy-init="false">
<context:annotation-config />
<context:component-scan base-package="com.nali.monitor" />
<bean id="testMBean" class="com.nali.monitor.TestMbean"></bean>
<bean class="org.springframework.jmx.export.MBeanExporter">
<property name="beans">
<map>
<entry key="com.nali.monitor:name=testMbean" value-ref="testMBean" />
</map>
</property>
</bean>
</beans>
|
这里直接用了tomcat的mbean server,就不需要在配置一个了。
Tomcat启动配置
-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8849 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false
|
(2) 用Jconsole 测试,
- 大小: 32 KB
分享到:
相关推荐
java 获取服务器内存使用情况、cpu运行情况、使用效率等等硬件指标,所需的jar包、dll文件工具
VMWare开发的一个收集系统各项底层信息的工具集
hyperic-sigar jar 系统各种信息
hyperic-sigar-1.6.4包 sigar-1.6.4.jar sigar-1.6.4-sources.jar sigar在Linux和Windows下使用java语言获得各种系统信息所需要的包;使用方法
sigar所有jar包,还包括sigar-amd64-winnt.dll文件!
该中文手册是了解Hyperic HQ安装,配置,以及内部结构的必备资料,本手册还包括了常见问题解答,并在网上开设论坛解答用户在安装配置HQ时所遇到的问题。 由Hyperic HQ 国内独家代理商北京铸锐数码科技有限公司提供。...
Hyperic指南,希望对大家有用,开源软件
hyperic-sigar实现操作系统CPU、内存等系统资源监控
本资源为hyperic-sigar-1.6.4相关文件,包括jar包,相关配置文件,api文档,样例等
Hyperic HQ是一个开源(GPL授权)IT资源管理平台。 Hyperic HQ 可以监控和管理: •操作系统:AIX,HP/UX,Linux,Solaris,Windows,Mac OSX,FreeBSD •Web服务器:Apache,Microsoft IIS,Sun ONE Web Server •...
windows和Linux下所需的全部依赖包,sigar,libsigar-amd64-linux.so,sigar-amd64-winnt.dll等等
java 获取服务器内存使用情况、cpu运行情况、使用效率等等硬件指标,所需的jar包、dll文件工具
Hyperic 使用手册,有兴趣的朋友可以下载学习
sigar全名是System Information Gatherer And Reporter,中文名是系统信息收集和报表工具。
mvn install:install-file -DgroupId=org.hyperic -DartifactId=sigar-dist -Dversion=1.6.3.82 -Dpackaging=jar -Dfile=C:\Users\XXXXX\Desktop\sigar-dist-1.6.3.82.zip mvn install:install-file -DgroupId=org....
Sigar 监控系统中的 Windows 下的 dll 和 Linux 下的 so 文件.
hyperic-sigar-1.6.4代码