CollUnitState.java
4.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*
* select * from tb_ato_kpidetail where kpi_id='CM-00-01-001-02'
*/
package com.sitech.ismp.coll;
import java.util.HashMap;
import java.util.Vector;
import org.apache.log4j.Logger;
public class CollUnitState implements CollUnitStateMBean {
private Logger logger = Logger.getLogger("COLL");
String KBP_ID = "10-12-12";
String PRE_UNITID = "10-10-20"; // aix主机的标识----------新增
String kbp_id = "10-11-12";
String routerip = null;
String ObjectIP = null;
String SHELLPATH = null;
String communication = "public";
String username = null;
String password = null;
String cPort = null;
int port = 5161;
public CollUnitState() {
}
public Vector getState(String IP) {
logger.debug("************************coll unitstat" + IP);
Vector result = null;
try {
this.ObjectIP = IP;
CMDTarget cmdTarget = null;
// cmdTarget.init(ObjectIP,username,shellPath);
result = getState(cmdTarget);
// cmdTarget.release();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
private boolean getParams(java.util.HashMap params) {
logger.debug("test in here");
username = (String) params.get("USERNAME");
password = (String) params.get("PASSWORD");
ObjectIP = (String) params.get("IP_ADDR");
SHELLPATH = (String) params.get("SHELLPATH");
logger.debug("test in here=" + username);
// password = com.sitech.util.DES3.decrypt(password);
if (SHELLPATH == null) {
SHELLPATH = "";
}
return true;
}
public java.util.Vector getState(java.util.HashMap params) throws Exception {
logger.debug("first");
getParams(params);
return getState(ObjectIP);
}
private Vector getState(CMDTarget cmdTarget) {
/**
* 说明: 从历史表tb_ato_kpidetil
* 中取kpi_id='CM-00-01-001-02'的值,经过处理后,再次填入tb_ato_kpidetail,
* unit_id值保持不变,kpi_id的为FM-00-01-001-01,从hsqldb读取
*
* ----------以上为之前的,以下为2006-08-11新修改的 说明:
* 从表tb_asset_host中取ENABLE='1'的值,unit_id值经过一些处理,kpi_id='CM-00-01-001-02',从oracle中读取,
* unit_id规则 '10-10-21:ism1'----->'10-10-21-10:ism1-total'
*
*
*/
String tmp_kpi_id_flag = "FM-00-01-001-01";
String[] unit_id = null; // 2006-08-11
// 有变,unit_id以冒号分割,在首字符串加"-10",末字符串后加+"-total"
// String KBP_ID = this.KBP_ID + "-11" + ":" + ObjectIP + "-total";
CollBase collbase = new CollBase();
Vector atokpiset = getAllUNIT();
for (int i = 0; i < atokpiset.size(); i++) {
Vector atokpi = (Vector) atokpiset.elementAt(i);
String UNIT_ID = (String) atokpi.elementAt(0);
String KPI_VALUE = (String) atokpi.elementAt(1);
try {
if (UNIT_ID != null && UNIT_ID.length() > 0)
unit_id = UNIT_ID.split(":");
UNIT_ID = unit_id[0] + "-10" + ":" + unit_id[1] + "-total";
collbase.addKPI(UNIT_ID, tmp_kpi_id_flag, new NetConnState(
KPI_VALUE).getListenState().getLostRate());
} catch (Exception e) {
e.printStackTrace();
}
}
return collbase.KPISet;
}
// select * from tb_ato_kpidetail where kpi_id='CM-00-01-001-02'
private Vector getAllUNIT() {
java.util.ResourceBundle LogfileInfo = java.util.ResourceBundle
.getBundle("db");
// -----------现改成如下 96是发下Key值
String sClassforName = LogfileInfo.getString("ClassforName");
String sUrl = LogfileInfo.getString("url");
String sUserName = LogfileInfo.getString("sqluser");
String sPassword = LogfileInfo.getString("sqlpassword");
logger.info("****sqlpas***" + sPassword);
// sPassword=
// com.sitech.util.DES3.decrypt(sPassword);//---------98下面需要此句
logger.info("****sqlpas2***" + sPassword);
logger.debug("*****sql*****" + sUserName);
SQLTarget collectiondbbase = new SQLTarget();
collectiondbbase.setDrivers(sClassforName);
collectiondbbase.init(sUrl, sUserName, sPassword);
String sql = "select UNIT_ID,IP_ADDR from tb_asset_host where ENABLE='1'";
logger.info("sqlis--" + sql);
return collectiondbbase.getKPISet(sql);
}
public static void main(String[] argv) throws Exception {
CollUnitState collunitstate = new CollUnitState();
HashMap params = new HashMap();
params.put("IP_ADDR", "172.16.9.96");
params.put("USERNAME", "weblogic");
params.put("PASSWORD", "weblogic");
params.put("SHELLPATH", "c:/");
Vector result = new Vector();
result = collunitstate.getState(params);
System.out.println(result.size());
CollBase collbase = new CollBase();
collbase.displayKPI(result);
}
}