Authored by zhouxiang

多数据源

... ... @@ -17,7 +17,7 @@
<aop:config>
<aop:pointcut id="monitorDaoPoint"
expression="execution(* com.monitor.*.mapper.*.*(..))"/>
expression="execution(* com.monitor.mysql.mapper.*.*(..)) or execution(* com.monitor.zabbix.mapper.*.*(..))"/>
<aop:advisor pointcut-ref="monitorDaoPoint" advice-ref="dataSourceMethodInterceptor"/>
</aop:config>
... ...
... ... @@ -6,6 +6,17 @@ datasources:
username: ops
password: t5/oMgwUCmO/GeMHBAQ2Cg==
zabbix:
servers:
- 10.66.0.191:3306
- 10.66.0.191:3306
username: zabbix_ops
password: YQ7VlkwN1Mum/fjaZARkKg==
daos:
- com.monitor.zabbix.mapper.ZabbixHistoryMapper
- com.monitor.zabbix.mapper.ZabbixHostMapper
- com.monitor.zabbix.mapper.ZabbixItemMapper
yohobuy_logs:
servers:
- 192.168.102.219:3306
... ...
... ... @@ -6,6 +6,17 @@ datasources:
username: root
password: t5/oMgwUCmO/GeMHBAQ2Cg==
zabbix:
servers:
- 192.168.102.76:3306
- 192.168.102.76:3306
username: root
password: t5/oMgwUCmO/GeMHBAQ2Cg==
daos:
- com.monitor.zabbix.mapper.ZabbixHistoryMapper
- com.monitor.zabbix.mapper.ZabbixHostMapper
- com.monitor.zabbix.mapper.ZabbixItemMapper
yohobuy_logs:
servers:
- 192.168.102.219:3306
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.monitor.zabbix.mapper.ZabbixHistoryMapper">
<resultMap id="dHistoryInfoMapper" type="com.monitor.zabbix.model.ZabbixDHistoryInfo">
<result column="itemid" property="itemId" jdbcType="INTEGER"/>
<result column="value" property="value" jdbcType="DOUBLE"/>
</resultMap>
<resultMap id="uHistoryInfoMapper" type="com.monitor.zabbix.model.ZabbixUHistoryInfo">
<result column="itemid" property="itemId" jdbcType="INTEGER"/>
<result column="value" property="value" jdbcType="BIGINT"/>
</resultMap>
<select id="queryDHistoryInfo" resultMap="dHistoryInfoMapper">
select
itemid,`value`
from history
where itemid = #{itemId,jdbcType=INTEGER}
order by clock desc limit 1;
</select>
<select id="queryUHistoryInfo" resultMap="uHistoryInfoMapper">
select itemid,`value`
from history_uint
where itemid = #{itemId,jdbcType=INTEGER}
order by clock desc limit 1;
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.monitor.zabbix.mapper.ZabbixHostMapper">
<resultMap id="hostInfoMapper" type="com.monitor.zabbix.model.ZabbixHostInfo" >
<id column="interfaceid" property="interfaceId" jdbcType="INTEGER" />
<result column="hostid" property="hostId" jdbcType="INTEGER" />
<result column="ip" property="ip" jdbcType="VARCHAR" />
</resultMap>
<select id="queryHostInfo" resultMap="hostInfoMapper">
select
interfaceid,hostid,ip
from interface
where ip IN
<foreach collection="list" index="index" item="item" close=")" open="(" separator=",">
#{item}
</foreach>
</select>
<select id="queryAllHostInfo" resultMap="hostInfoMapper">
SELECT interfaceid,hostid,ip FROM `interface` ;
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.monitor.zabbix.mapper.ZabbixItemMapper">
<resultMap id="itemResultMapper" type="com.monitor.zabbix.model.ZabbixItemInfo">
<id column="itemid" property="itemId" jdbcType="INTEGER"/>
<result column="hostid" property="hostId" jdbcType="INTEGER"/>
<result column="value_type" property="valueType" jdbcType="VARCHAR"/>
<result column="key_" property="keyName" jdbcType="VARCHAR"/>
</resultMap>
<select id="queryItemInfo" resultMap="itemResultMapper">
select
itemid,hostid,key_,value_type
from items
where hostid IN
<foreach collection="list" index="index" item="item" close=")" open="(" separator=",">
#{item}
</foreach>
AND
(key_ LIKE 'system.cpu.util%' OR key_ LIKE 'vm.memory%' OR key_ like 'net.if%')
</select>
</mapper>
\ No newline at end of file