CheckAllNet.java
4.35 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
package com.sitech.ismp.coll.tivoli;
import java.io.File;
import java.util.Enumeration;
import java.util.ResourceBundle;
import java.util.Vector;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL;
public class CheckAllNet {
static ResourceBundle NET_DEVICE_IPADDR=null;
static {
try{
NET_DEVICE_IPADDR = ResourceBundle.getBundle("net_device_ipaddr");
}
catch(Exception e){
System.out.println("Bundle net_device_ipaddr.properties error.");
e.printStackTrace();
}
}
public static void printKPIs(Vector KPISet ){
for(int i=0;i<KPISet.size();i++){
TblATO_KPIDETAIL tblato_kpidetail = (TblATO_KPIDETAIL)KPISet.elementAt(i);
if(tblato_kpidetail==null)
continue;
System.out.println(tblato_kpidetail.UNIT_ID + " : " +
tblato_kpidetail.KPI_ID + " : " +
tblato_kpidetail.KPI_VALUE + " : " +
tblato_kpidetail.CLL_TIME );
}
}
public static void printNetKPIStatus(String filename)throws Exception
{
Enumeration en = NET_DEVICE_IPADDR.getKeys();
WritableWorkbook workbook = Workbook.createWorkbook(new File(filename));
WritableSheet sheet = workbook.createSheet("First Sheet", 0);
//写KPI头
Vector vector = new Vector();
String empty[][]=CheckKPIHelper.Check_Net_KPI(vector);
for(int i=0;i<empty.length;i++)
{
Label label1 = new Label(i+1,0,empty[i][0]);
sheet.addCell(label1);
}
int rownum = 0;
while(en.hasMoreElements())
{
rownum++;
String ip_address = (String)en.nextElement();
//写hostname
Label label = new Label(0,rownum,ip_address);
sheet.addCell(label);
CollNetConfig netconfig = new CollNetConfig();
java.util.HashMap params = new java.util.HashMap();
params.put("IP_ADDR",ip_address);
params.put("DRIVERID","DRIVERID-" + ip_address);
Vector v = new Vector();
v.addAll(netconfig.getFailure(params));
v.addAll(netconfig.getConfiguration(params));
v.addAll(netconfig.getPerformance(params));
//printKPIs(v);
String temp[][]=CheckKPIHelper.Check_Net_KPI(v);
for(int i=0;i<temp.length;i++)
{
Label label2 = new Label(i+1,rownum,temp[i][1]);
sheet.addCell(label2);
}
}
workbook.write();
workbook.close();
System.out.println(filename + " write finish!");
}
/**
* 如果bool=ture表示打印出所有网络设备的所有KPI的状态(exist/inexistence)
* 如果bool=false表示打印出所有网络设备的所有未采集到KPI状态(exist)
* @param bool
* @throws Exception
*/
public static void getAll_KPI_Status(boolean bool)throws Exception
{
Enumeration en = NET_DEVICE_IPADDR.getKeys();
/*int num = 0;
while(en.hasMoreElements())
{
num++;
}
System.out.println("====================Test Oracle Host Number Is : " + num + "====================");
System.out.println();
System.out.println();
*/
while(en.hasMoreElements())
{
String ip_address = (String)en.nextElement();
System.out.println("Test Net Device Ipaddress Is : " + ip_address);
System.out.println("========================================");
Vector KPISet= new Vector();
CollNetConfigMBean netconfig = new CollNetConfig();
java.util.HashMap params = new java.util.HashMap();
params.put("IP_ADDR",ip_address);
params.put("DRIVERID","DRIVERID-" + ip_address);
KPISet.addAll(netconfig.getFailure(params));
KPISet.addAll(netconfig.getConfiguration(params));
KPISet.addAll(netconfig.getPerformance(params));
String temp[][] = CheckKPIHelper.Check_Net_KPI(KPISet);
for(int i=0;i<temp.length;i++)
{
if(bool==false&&temp[i][1].equalsIgnoreCase("inexistence"))
{
System.out.println("KPI_ID : " + temp[i][0] + "---" + temp[i][1]);
}
if(bool==true)
{
System.out.println("KPI_ID : " + temp[i][0] + "---" + temp[i][1]);
}
}
System.out.println("========================================");
System.out.println();
}
System.out.println("====================FINISH====================");
}
/**
* @param args
*/
public static void main(String[] args) throws Exception{
//getAll_KPI_Status(true);
//getAll_KPI_Status(false);
//printKPIs(KPISet);
String filename = "AllNetKPIStatus.xls";
printNetKPIStatus(filename);
}
}