合并分支 'master_zmm' 到 'master'
添加getPingStatus方法。 添加getPingStatus方法。 查看合并请求 !4
Showing
9 changed files
with
251 additions
and
52 deletions
config/snmp.properties
deleted
100644 → 0
@@ -60,7 +60,6 @@ | @@ -60,7 +60,6 @@ | ||
60 | <sqlMap resource="com/sitech/topo/db/maps/TbTopoHostProcessMap.xml" /> | 60 | <sqlMap resource="com/sitech/topo/db/maps/TbTopoHostProcessMap.xml" /> |
61 | <sqlMap resource="com/sitech/topo/db/maps/TbTopoHostProcessLinkMap.xml" /> | 61 | <sqlMap resource="com/sitech/topo/db/maps/TbTopoHostProcessLinkMap.xml" /> |
62 | <sqlMap resource="com/sitech/database/maps/TbTopoPhysicalDeviceMap.xml" /> | 62 | <sqlMap resource="com/sitech/database/maps/TbTopoPhysicalDeviceMap.xml" /> |
63 | - <sqlMap resource="com/sitech/database/maps/DowntimeMap.xml" /> | ||
64 | - <sqlMap resource="com/sitech/database/maps/DowntimeMapHistory.xml" /> | 63 | + <sqlMap resource="com/sitech/database/maps/CheckConnectionMap.xml" /> |
65 | 64 | ||
66 | </sqlMapConfig> | 65 | </sqlMapConfig> |
1 | package com.sitech.ismp.coll.middleware.weblogic; | 1 | package com.sitech.ismp.coll.middleware.weblogic; |
2 | 2 | ||
3 | -import java.util.HashMap; | ||
4 | -import java.util.Scanner; | ||
5 | -import java.util.Vector; | ||
6 | - | 3 | +import com.adventnet.snmp.beans.SnmpTarget; |
4 | +import com.adventnet.snmp.snmp2.SnmpOID; | ||
5 | +import com.sitech.ismp.check.downtime.CheckConnectionState; | ||
6 | +import com.sitech.ismp.check.downtime.ParamterBean; | ||
7 | import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL; | 7 | import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL; |
8 | import com.sitech.ismp.coll.middleware.weblogic.impl.ICollWebLogic; | 8 | import com.sitech.ismp.coll.middleware.weblogic.impl.ICollWebLogic; |
9 | import com.sitech.ismp.coll.middleware.weblogic.impl.WebLogicCollFactory; | 9 | import com.sitech.ismp.coll.middleware.weblogic.impl.WebLogicCollFactory; |
10 | +import com.sitech.util.Formater; | ||
11 | + | ||
12 | +import java.text.ParseException; | ||
13 | +import java.util.Date; | ||
14 | +import java.util.HashMap; | ||
15 | +import java.util.Scanner; | ||
16 | +import java.util.Vector; | ||
10 | 17 | ||
11 | public class CollWebLogic implements CollWebLogicMBean{ | 18 | public class CollWebLogic implements CollWebLogicMBean{ |
12 | 19 | ||
20 | + SnmpTarget target = null; | ||
21 | + | ||
13 | public Vector<TblATO_KPIDETAIL> getExecuteQueue(HashMap<String, String> params) { | 22 | public Vector<TblATO_KPIDETAIL> getExecuteQueue(HashMap<String, String> params) { |
14 | WebLogicCollFactory factory = new WebLogicCollFactory(); | 23 | WebLogicCollFactory factory = new WebLogicCollFactory(); |
15 | ICollWebLogic coll = factory.getCollInstance(params); | 24 | ICollWebLogic coll = factory.getCollInstance(params); |
@@ -125,6 +134,86 @@ public class CollWebLogic implements CollWebLogicMBean{ | @@ -125,6 +134,86 @@ public class CollWebLogic implements CollWebLogicMBean{ | ||
125 | return null; | 134 | return null; |
126 | } | 135 | } |
127 | 136 | ||
137 | + @Override | ||
138 | + public Vector<TblATO_KPIDETAIL> getPingStatus(HashMap<String, String> params) { | ||
139 | + /** | ||
140 | + * 该 kbp_class kpiId 如果不存在,需要在页面添加。 | ||
141 | + */ | ||
142 | + String kbp_class="10-12-11-20"; | ||
143 | + String kpiId="FM-00-12-001-999"; | ||
144 | + Vector<TblATO_KPIDETAIL> vector=new Vector<TblATO_KPIDETAIL>(); | ||
145 | + String serverip=params.get("SERVERIP"); | ||
146 | + | ||
147 | + /** | ||
148 | + * SERVERNAME 实际就是 资源标识。 | ||
149 | + */ | ||
150 | + String servername = params.get("SERVERNAME"); | ||
151 | + String unitId = kbp_class +":"+ Formater.neatenunitid(servername) + "-CONFIG"; | ||
152 | + CheckConnectionState server=new CheckConnectionState(); | ||
153 | + TblATO_KPIDETAIL kpidetail=new TblATO_KPIDETAIL(); | ||
154 | + try { | ||
155 | + kpidetail.setUNIT_ID(unitId); | ||
156 | + kpidetail.setKPI_ID(kpiId); | ||
157 | + kpidetail.setKPI_VALUE(server.getPingState(new ParamterBean(serverip))); | ||
158 | + kpidetail.setCLL_TIME(new Date()); | ||
159 | + vector.add(kpidetail); | ||
160 | + } catch (ParseException e){ | ||
161 | + e.printStackTrace(); | ||
162 | + } | ||
163 | + return vector; | ||
164 | + } | ||
165 | + | ||
166 | + | ||
167 | + /** | ||
168 | + * @author pc103 | ||
169 | + * @date 2006-07-21 | ||
170 | + * @param oid | ||
171 | + * @param bool | ||
172 | + * @return vector 参数说明书: oid-----对应weblogic控制台监控的性能指标id(关键) bool----无多大用处 | ||
173 | + * 功能:储存各采集结果 返回类型:vector | ||
174 | + * | ||
175 | + */ | ||
176 | + private Vector<String> walkKPIInfo(String oid, boolean bool) { | ||
177 | + Vector<String> tmp_result = new Vector<String>(); | ||
178 | + try { | ||
179 | + Vector<String> tmp_oid = new Vector<String>(); | ||
180 | + target.setObjectID(oid); | ||
181 | + target.oidList[0] = new SnmpOID(oid); | ||
182 | + int maxtry = 0; | ||
183 | + SnmpOID[] oidList = target.getSnmpOIDList(); | ||
184 | + if (oidList == null) { | ||
185 | + System.out.println("oidList is null"); | ||
186 | + return null; | ||
187 | + } else { | ||
188 | + SnmpOID rootoid = oidList[0]; | ||
189 | + SnmpOID curroid = null; | ||
190 | + while (maxtry++ < 3000) { | ||
191 | + String result1[] = target.snmpGetNextList(); | ||
192 | + if (result1 == null) { | ||
193 | + target.oidList[0] = curroid; | ||
194 | + continue; | ||
195 | + } | ||
196 | + if (!SnmpTarget.isInSubTree(rootoid, target.getSnmpOID())) | ||
197 | + break; | ||
198 | + for (int i = 0; i < result1.length; i++) { | ||
199 | + tmp_result.add(result1[i]); | ||
200 | + tmp_oid.add(target.getObjectID(i)); | ||
201 | + } | ||
202 | + if (result1[0].compareTo("NULL") == 0) | ||
203 | + break; | ||
204 | + } | ||
205 | + if (maxtry == 1) { | ||
206 | + System.err | ||
207 | + .println("Request failed, timed out or no available data(" | ||
208 | + + oid + "). \n " + target.getErrorString()); | ||
209 | + } | ||
210 | + } | ||
211 | + } catch (Exception e) { | ||
212 | + e.printStackTrace(); | ||
213 | + } | ||
214 | + return tmp_result; | ||
215 | + } | ||
216 | + | ||
128 | private static String read(String prompt) { | 217 | private static String read(String prompt) { |
129 | Scanner scanner = new Scanner(System.in); | 218 | Scanner scanner = new Scanner(System.in); |
130 | System.out.print(prompt); | 219 | System.out.print(prompt); |
1 | package com.sitech.ismp.coll.middleware.weblogic; | 1 | package com.sitech.ismp.coll.middleware.weblogic; |
2 | 2 | ||
3 | +import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL; | ||
4 | + | ||
3 | import java.util.HashMap; | 5 | import java.util.HashMap; |
4 | import java.util.Vector; | 6 | import java.util.Vector; |
5 | 7 | ||
6 | -import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL; | ||
7 | - | ||
8 | public interface CollWebLogicMBean { | 8 | public interface CollWebLogicMBean { |
9 | 9 | ||
10 | public Vector<TblATO_KPIDETAIL> getExecuteQueue(HashMap<String, String> map); | 10 | public Vector<TblATO_KPIDETAIL> getExecuteQueue(HashMap<String, String> map); |
@@ -31,4 +31,11 @@ public interface CollWebLogicMBean { | @@ -31,4 +31,11 @@ public interface CollWebLogicMBean { | ||
31 | 31 | ||
32 | public Vector<TblATO_KPIDETAIL> getStatus(HashMap<String, String> params); | 32 | public Vector<TblATO_KPIDETAIL> getStatus(HashMap<String, String> params); |
33 | 33 | ||
34 | + /** | ||
35 | + * 获取数据库所在主机的ping状态,add by frank 2017-05-04 | ||
36 | + * @param params | ||
37 | + * @return | ||
38 | + */ | ||
39 | + public Vector<TblATO_KPIDETAIL> getPingStatus(HashMap<String, String> params); | ||
40 | + | ||
34 | } | 41 | } |
1 | package com.sitech.jmx; | 1 | package com.sitech.jmx; |
2 | 2 | ||
3 | -import javax.management.MBeanServer; | ||
4 | -import javax.management.MBeanServerFactory; | ||
5 | - | ||
6 | -import com.sitech.jmx.adaptor.RmiAdaptor; | ||
7 | -import com.sitech.jmx.manage.*; | ||
8 | -import com.sitech.util.mq.TunnelFactory; | ||
9 | -import org.apache.log4j.Logger; | ||
10 | - | ||
11 | import com.sitech.base.ACommonThread; | 3 | import com.sitech.base.ACommonThread; |
12 | import com.sitech.base.AgentProperties; | 4 | import com.sitech.base.AgentProperties; |
13 | import com.sitech.base.Config; | 5 | import com.sitech.base.Config; |
14 | import com.sitech.database.dao.TbCfgEventDao; | 6 | import com.sitech.database.dao.TbCfgEventDao; |
15 | import com.sitech.ismp.messageObject.AgentSyncRequest; | 7 | import com.sitech.ismp.messageObject.AgentSyncRequest; |
16 | import com.sitech.jmx.adaptor.JmsAdaptor; | 8 | import com.sitech.jmx.adaptor.JmsAdaptor; |
9 | +import com.sitech.jmx.adaptor.RmiAdaptor; | ||
10 | +import com.sitech.jmx.manage.CollScheduleManager; | ||
11 | +import com.sitech.jmx.manage.CronLogScan; | ||
12 | +import com.sitech.jmx.manage.MBeanManager; | ||
13 | +import com.sitech.jmx.manage.MessageSenderManager; | ||
14 | +import com.sitech.jmx.manage.SwapMonitorThread; | ||
17 | import com.sitech.util.mq.MQConstants; | 15 | import com.sitech.util.mq.MQConstants; |
18 | -import com.sitech.util.mq.MQSender; | ||
19 | -import com.sitech.util.mq.MQSenderFactory; | 16 | +import com.sitech.util.mq.TunnelFactory; |
17 | +import org.apache.log4j.Logger; | ||
18 | + | ||
19 | +import javax.management.MBeanServer; | ||
20 | +import javax.management.MBeanServerFactory; | ||
20 | 21 | ||
21 | public class MasterAgent extends ACommonThread { | 22 | public class MasterAgent extends ACommonThread { |
22 | private static Logger logger = Logger.getLogger("LOGER"); | 23 | private static Logger logger = Logger.getLogger("LOGER"); |
23 | private static Logger error = Logger.getLogger("ERROR"); | 24 | private static Logger error = Logger.getLogger("ERROR"); |
25 | + private static Logger log = Logger.getLogger(MasterAgent.class); | ||
24 | private MBeanServer server; | 26 | private MBeanServer server; |
25 | 27 | ||
26 | public MasterAgent() { | 28 | public MasterAgent() { |
@@ -41,13 +43,14 @@ public class MasterAgent extends ACommonThread { | @@ -41,13 +43,14 @@ public class MasterAgent extends ACommonThread { | ||
41 | * 启动MBeanServer | 43 | * 启动MBeanServer |
42 | */ | 44 | */ |
43 | private void createMBS() { | 45 | private void createMBS() { |
46 | + log.info("MBeanServer create ....."); | ||
44 | try { | 47 | try { |
45 | server = MBeanServerFactory.createMBeanServer(AgentProperties.MBEAN_SERVER_DOMAIN); | 48 | server = MBeanServerFactory.createMBeanServer(AgentProperties.MBEAN_SERVER_DOMAIN); |
46 | MBeanManager manager = MBeanManager.getInstance(); | 49 | MBeanManager manager = MBeanManager.getInstance(); |
47 | manager.setMBeanServer(server); | 50 | manager.setMBeanServer(server); |
48 | - logger.info("MBeanServer create successful."); | 51 | + log.info("MBeanServer create successful."); |
49 | } catch (Exception e) { | 52 | } catch (Exception e) { |
50 | - logger.error("MBeanServer instance creation failed.", e); | 53 | + log.error("MBeanServer instance creation failed.", e); |
51 | } | 54 | } |
52 | } | 55 | } |
53 | 56 | ||
@@ -59,9 +62,9 @@ public class MasterAgent extends ACommonThread { | @@ -59,9 +62,9 @@ public class MasterAgent extends ACommonThread { | ||
59 | CollScheduleManager collschedule = CollScheduleManager.getInstance(); | 62 | CollScheduleManager collschedule = CollScheduleManager.getInstance(); |
60 | collschedule.setMBeanServer(server); | 63 | collschedule.setMBeanServer(server); |
61 | collschedule.startSchedule(); | 64 | collschedule.startSchedule(); |
62 | - logger.info("Start quartz scheduler successful."); | 65 | + log.info("Start quartz scheduler successful."); |
63 | } catch (Exception e) { | 66 | } catch (Exception e) { |
64 | - error.error("Exception while start quartz scheduler.", e); | 67 | + log.error("Exception while start quartz scheduler.", e); |
65 | } | 68 | } |
66 | } | 69 | } |
67 | 70 | ||
@@ -70,22 +73,22 @@ public class MasterAgent extends ACommonThread { | @@ -70,22 +73,22 @@ public class MasterAgent extends ACommonThread { | ||
70 | * 2012-12-20 改为MQ | 73 | * 2012-12-20 改为MQ |
71 | */ | 74 | */ |
72 | private void registAdapter() { | 75 | private void registAdapter() { |
73 | - logger.info("Start MQ adapter..."); | 76 | + log.info("Start MQ adapter..."); |
74 | String url = Config.WORKSTAITON_CONN_URL; | 77 | String url = Config.WORKSTAITON_CONN_URL; |
75 | String queue = "Q_AGENT_" + AgentProperties.AGENT_ID; | 78 | String queue = "Q_AGENT_" + AgentProperties.AGENT_ID; |
76 | JmsAdaptor jmsAdaptor = new JmsAdaptor(url, queue); | 79 | JmsAdaptor jmsAdaptor = new JmsAdaptor(url, queue); |
77 | jmsAdaptor.start(); | 80 | jmsAdaptor.start(); |
78 | RmiAdaptor.getInstance().regist(server); | 81 | RmiAdaptor.getInstance().regist(server); |
79 | - logger.info("Start MQ adapter ok..."); | 82 | + log.info("Start MQ adapter ok..."); |
80 | } | 83 | } |
81 | 84 | ||
82 | /**s | 85 | /**s |
83 | * 启动指标数据和告警数据发送服务 | 86 | * 启动指标数据和告警数据发送服务 |
84 | */ | 87 | */ |
85 | private void startJmsSender() { | 88 | private void startJmsSender() { |
86 | - logger.info("Start all jms sender."); | 89 | + log.info("Start all jms sender."); |
87 | new MessageSenderManager().startAllMessageSender(); | 90 | new MessageSenderManager().startAllMessageSender(); |
88 | - logger.info("Start all jms sender ok."); | 91 | + log.info("Start all jms sender ok."); |
89 | } | 92 | } |
90 | 93 | ||
91 | /** | 94 | /** |
@@ -94,7 +97,7 @@ public class MasterAgent extends ACommonThread { | @@ -94,7 +97,7 @@ public class MasterAgent extends ACommonThread { | ||
94 | private void startSwapMonitorThread() { | 97 | private void startSwapMonitorThread() { |
95 | SwapMonitorThread swapMonitorThread = new SwapMonitorThread(); | 98 | SwapMonitorThread swapMonitorThread = new SwapMonitorThread(); |
96 | swapMonitorThread.start(); | 99 | swapMonitorThread.start(); |
97 | - logger.info("Start swap path monitor thread successful."); | 100 | + log.info("Start swap path monitor thread successful."); |
98 | } | 101 | } |
99 | 102 | ||
100 | /** | 103 | /** |
@@ -118,7 +121,7 @@ public class MasterAgent extends ACommonThread { | @@ -118,7 +121,7 @@ public class MasterAgent extends ACommonThread { | ||
118 | // Config.WORKSTAITON_CONN_URL, MQConstants.Q_ROPORT_FROM_AGENT); | 121 | // Config.WORKSTAITON_CONN_URL, MQConstants.Q_ROPORT_FROM_AGENT); |
119 | // mqSender.writeData(request); | 122 | // mqSender.writeData(request); |
120 | // mqSender.start(); | 123 | // mqSender.start(); |
121 | - logger.info("Send sync request."); | 124 | + log.info("Send sync request."); |
122 | } | 125 | } |
123 | 126 | ||
124 | public static void main(String[] args) { | 127 | public static void main(String[] args) { |
1 | package com.sitech.jmx.manage; | 1 | package com.sitech.jmx.manage; |
2 | 2 | ||
3 | -import javax.management.MBeanServer; | ||
4 | -import javax.management.ObjectName; | ||
5 | - | ||
6 | -import org.apache.log4j.Logger; | ||
7 | - | ||
8 | import com.sitech.ismp.messageObject.AgentSyncObject; | 3 | import com.sitech.ismp.messageObject.AgentSyncObject; |
9 | import com.sitech.schedule.Scheduler; | 4 | import com.sitech.schedule.Scheduler; |
5 | +import org.apache.log4j.Logger; | ||
6 | + | ||
7 | +import javax.management.MBeanServer; | ||
8 | +import javax.management.ObjectName; | ||
10 | 9 | ||
11 | /** | 10 | /** |
12 | * ClassName:MBeanRegister Description: 注册采集MBean | 11 | * ClassName:MBeanRegister Description: 注册采集MBean |
@@ -73,9 +72,24 @@ public class MBeanManager { | @@ -73,9 +72,24 @@ public class MBeanManager { | ||
73 | public void registCollMBean(Scheduler schedule) { | 72 | public void registCollMBean(Scheduler schedule) { |
74 | String objectName = schedule.getObjectName(); | 73 | String objectName = schedule.getObjectName(); |
75 | String className = schedule.getClassName(); | 74 | String className = schedule.getClassName(); |
76 | - | 75 | +// String className ="com.sitech.ismp.coll.CollMySQL"; |
76 | + Class mbeanclasses = null; | ||
77 | try { | 77 | try { |
78 | - Object mbeanclass = Class.forName(className).newInstance(); | 78 | + mbeanclasses = Class.forName(className); |
79 | + } catch (ClassNotFoundException e) { | ||
80 | + e.printStackTrace(); | ||
81 | + } | ||
82 | + Object mbeanclass = null; | ||
83 | + try { | ||
84 | + mbeanclass = mbeanclasses.newInstance(); | ||
85 | + } catch (InstantiationException e) { | ||
86 | + e.printStackTrace(); | ||
87 | + } catch (IllegalAccessException e) { | ||
88 | + e.printStackTrace(); | ||
89 | + } | ||
90 | + try { | ||
91 | + | ||
92 | + | ||
79 | 93 | ||
80 | ObjectName name = new ObjectName(objectName); | 94 | ObjectName name = new ObjectName(objectName); |
81 | 95 | ||
@@ -93,6 +107,7 @@ public class MBeanManager { | @@ -93,6 +107,7 @@ public class MBeanManager { | ||
93 | + "},CLASS_NAME={" + className + "}"); | 107 | + "},CLASS_NAME={" + className + "}"); |
94 | 108 | ||
95 | } catch (Exception e) { | 109 | } catch (Exception e) { |
110 | + e.printStackTrace(); | ||
96 | error.error("Exception while regist mbean. NAME={" + objectName | 111 | error.error("Exception while regist mbean. NAME={" + objectName |
97 | + "},CLASS_NAME={" + className + "}", e); | 112 | + "},CLASS_NAME={" + className + "}", e); |
98 | } | 113 | } |
@@ -6,7 +6,6 @@ import com.sitech.database.dao.TbCfgEventDao; | @@ -6,7 +6,6 @@ import com.sitech.database.dao.TbCfgEventDao; | ||
6 | import com.sitech.database.dao.TbCfgOidMibDao; | 6 | import com.sitech.database.dao.TbCfgOidMibDao; |
7 | import com.sitech.database.domain.TbCfgEvent; | 7 | import com.sitech.database.domain.TbCfgEvent; |
8 | import com.sitech.database.domain.TbCfgOidMib; | 8 | import com.sitech.database.domain.TbCfgOidMib; |
9 | -import com.sitech.ismp.check.downtime.DowntimeDao; | ||
10 | import com.sitech.ismp.coll.cron.CronConstants; | 9 | import com.sitech.ismp.coll.cron.CronConstants; |
11 | import com.sitech.ismp.messageObject.*; | 10 | import com.sitech.ismp.messageObject.*; |
12 | import com.sitech.jmx.manage.CollScheduleManager; | 11 | import com.sitech.jmx.manage.CollScheduleManager; |
@@ -69,7 +68,6 @@ public class ConfigSync implements ConfigSyncMBean { | @@ -69,7 +68,6 @@ public class ConfigSync implements ConfigSyncMBean { | ||
69 | extInfo.put("SCHEDULE_OPERATE",scheduleOperate); | 68 | extInfo.put("SCHEDULE_OPERATE",scheduleOperate); |
70 | removeCollSchedule(obj); | 69 | removeCollSchedule(obj); |
71 | // removeMemDbCfgData(obj); | 70 | // removeMemDbCfgData(obj); |
72 | - removeDowntimeMBean(obj); | ||
73 | // 删除内存数据库中相关的配置数据 | 71 | // 删除内存数据库中相关的配置数据 |
74 | scheStatus = "0"; | 72 | scheStatus = "0"; |
75 | if("1".equals(scheduleOperate)){ | 73 | if("1".equals(scheduleOperate)){ |
@@ -165,16 +163,6 @@ public class ConfigSync implements ConfigSyncMBean { | @@ -165,16 +163,6 @@ public class ConfigSync implements ConfigSyncMBean { | ||
165 | } | 163 | } |
166 | } | 164 | } |
167 | 165 | ||
168 | - /** | ||
169 | - * 删除需要监控宕机的主机。 | ||
170 | - * @param obj | ||
171 | - */ | ||
172 | - private void removeDowntimeMBean(AgentSyncObject obj){ | ||
173 | - if(obj.getClassName().equals("com.sitech.ismp.check.downtime.Downtime")){ | ||
174 | - DowntimeDao dao = new DowntimeDao(); | ||
175 | - dao.deleteDowntimeHostByIp(obj.getParams().get("DEVICE_IP")); | ||
176 | - } | ||
177 | - } | ||
178 | 166 | ||
179 | 167 | ||
180 | /** | 168 | /** |
1 | +package com.sitech.snmptrap; | ||
2 | + | ||
3 | +import com.sitech.database.dao.BaseDao; | ||
4 | + | ||
5 | +import java.sql.SQLException; | ||
6 | +import java.util.ArrayList; | ||
7 | +import java.util.HashMap; | ||
8 | +import java.util.List; | ||
9 | + | ||
10 | +/** | ||
11 | + * @author frank zmm@honggroup.com.cn | ||
12 | + * @Description: 物理设备类对应dao。 | ||
13 | + * @Package com.sitech.snmptrap | ||
14 | + * @ClassName: com.sitech.snmptrap.TbTopoPhysicalDeviceDao | ||
15 | + * @date 2017年03月03日 10:20 | ||
16 | + */ | ||
17 | +public class TbTopoPhysicalDeviceDao extends BaseDao { | ||
18 | + | ||
19 | + | ||
20 | + /** | ||
21 | + * 添加物理设备,如果该设备已经存在,则修改。 | ||
22 | + * @param physicalDevice | ||
23 | + */ | ||
24 | + public void addTbTopoPhysicalDevice(TbTopoPhysicalDeviceBean physicalDevice){ | ||
25 | + try { | ||
26 | + int updateSum = sqlmapClient.update("updateTbTopoPhysicalDevice",physicalDevice); | ||
27 | + if(updateSum == 0){ | ||
28 | + sqlmapClient.insert("addTbTopoPhysicalDevice", physicalDevice); | ||
29 | + } | ||
30 | + } catch (Exception e) { | ||
31 | + error.error("Exception while addTbTopoPhysicalDevice.", e); | ||
32 | + } | ||
33 | + } | ||
34 | + | ||
35 | + /** | ||
36 | + * 按照设备ID删除设备。 | ||
37 | + * @param deviceId | ||
38 | + */ | ||
39 | + public int deleteTbTopoPhysicalDevice(String deviceId){ | ||
40 | + int result=0; | ||
41 | + try { | ||
42 | + result=sqlmapClient.delete("deleteTbTopoPhysicalDevice", deviceId); | ||
43 | + } catch (Exception e) { | ||
44 | + error.error("Exception while deleteTbTopoPhysicalDevice.", e); | ||
45 | + } | ||
46 | + return result; | ||
47 | + } | ||
48 | + | ||
49 | + public int deletePhysicalDeviceByIp(String ip){ | ||
50 | + try { | ||
51 | + return sqlmapClient.delete("deletePhysicalDeviceByIp", ip); | ||
52 | + } catch (Exception e) { | ||
53 | + error.error("Exception while deletePhysicalDeviceByIp.", e); | ||
54 | + } | ||
55 | + return -1; | ||
56 | + } | ||
57 | + | ||
58 | + public List<TbTopoPhysicalDeviceBean> getPhysicalDeviceByIp(String deviceIp){ | ||
59 | + HashMap<String,String> param=new HashMap<String, String>(); | ||
60 | + param.put("DEVICE_IP",deviceIp); | ||
61 | + List<TbTopoPhysicalDeviceBean> beanList=new ArrayList<TbTopoPhysicalDeviceBean>(); | ||
62 | + try { | ||
63 | + beanList=sqlmapClient.queryForList("queryTbTopoPhysicalDevice", param); | ||
64 | + } catch (SQLException e) { | ||
65 | + e.printStackTrace(); | ||
66 | + } | ||
67 | + return beanList; | ||
68 | + } | ||
69 | + | ||
70 | + | ||
71 | +} |
1 | +package com.sitech.snmptrap; | ||
2 | + | ||
3 | +import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL; | ||
4 | + | ||
5 | +import java.util.HashMap; | ||
6 | +import java.util.Vector; | ||
7 | + | ||
8 | +/** | ||
9 | + * @author frank zmm@honggroup.com.cn | ||
10 | + * @Description: 物理设备操作MBean。 | ||
11 | + * @Package com.sitech.snmptrap | ||
12 | + * @ClassName: com.sitech.snmptrap.TbTopoPhysicalDeviceMBean | ||
13 | + * @date 2017年03月03日 11:42 | ||
14 | + */ | ||
15 | +public interface TbTopoPhysicalDeviceMBean { | ||
16 | + | ||
17 | + /** | ||
18 | + * 添加(修改)物理设备 | ||
19 | + * @param params | ||
20 | + * @return | ||
21 | + */ | ||
22 | + Vector<TblATO_KPIDETAIL> addDevice(HashMap params); | ||
23 | + | ||
24 | + /** | ||
25 | + * 删除物理设备 | ||
26 | + * @param deviceId 设备ID。 | ||
27 | + * @return | ||
28 | + */ | ||
29 | + String deleteDevice(String deviceId); | ||
30 | + | ||
31 | + | ||
32 | +} |
-
Please register or login to post a comment