CollIBMHost.java
5.21 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
package com.sitech.ismp.coll.host;
import java.util.HashMap;
import java.util.Scanner;
import java.util.Vector;
import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL;
public class CollIBMHost implements CollIBMHostMBean {
/**
* 采集CPU指标
* @throws
* @since Ver 1.1
*/
public Vector<TblATO_KPIDETAIL> getCpu(HashMap<String, String> params) {
CollIBMWithCMD cmd = new CollIBMWithCMD();
return cmd.getCpu(params);
}
/**
* 采集内存指标
* @throws
* @since Ver 1.1
*/
public Vector<TblATO_KPIDETAIL> getMemory(HashMap<String, String> params) {
CollIBMWithCMD cmd = new CollIBMWithCMD();
return cmd.getMemory(params);
}
/**
* 采集配置指标
* @throws
* @since Ver 1.1
*/
public Vector<TblATO_KPIDETAIL> getConfig(HashMap<String, String> params) {
CollIBMWithCMD cmd = new CollIBMWithCMD();
return cmd.getConfig(params);
}
/**
* 采集硬盘指标
* PM-00-01-003-01 磁盘物理IO操作速率 磁盘物理IO操作速率(秒)
* PM-00-01-003-02 平均磁盘请求数量 单位时间内平均磁盘请求数量
* PM-00-01-003-03 磁盘忙的百分比 磁盘读写的时间占用总时间的百分比
* PM-00-01-003-04 每秒磁盘读请求 每秒磁盘读请求字节数
* PM-00-01-003-05 每秒磁盘写请求 每秒磁盘写请求字节数
* PM-00-01-003-06 磁盘访问平均等待时间 磁盘访问平均等待时间(毫秒)
* PM-00-01-003-07 等待I/O进程线程数 等待系统I/O(disk、inode、cache、CDFS等)的进程和线程数
*/
public Vector<TblATO_KPIDETAIL> getDisk(HashMap<String, String> params) {
CollIBMWithCMD cmd = new CollIBMWithCMD();
return cmd.getDisk(params);
}
/**
* 采集文件系统
* PM-00-01-004-01 文件系统使用比率 文件系统已使用的空间与总空间的比值
* PM-00-01-004-02 交换区使用百分比 交换区使用百分比
* PM-00-01-004-03 逻辑卷(裸设备)文件系统使用率 各逻辑卷上文件系统的使用率
*/
public Vector<TblATO_KPIDETAIL> getFileSystem(HashMap<String, String> params) {
CollIBMWithCMD cmd = new CollIBMWithCMD();
return cmd.getFileSystem(params);
}
public Vector<TblATO_KPIDETAIL> getProcessTop10(HashMap<String, String> params) {
CollIBMWithCMD cmd = new CollIBMWithCMD();
return cmd.getProcessTop10(params);
}
public Vector<TblATO_KPIDETAIL> getProcessByKey(HashMap<String, String> params) {
CollIBMWithCMD cmd = new CollIBMWithCMD();
return cmd.getProcessByKey(params);
}
public Vector<TblATO_KPIDETAIL> getHardware(HashMap<String, String> params) {
CollIBMWithCMD cmd = new CollIBMWithCMD();
return cmd.getHardware(params);
}
@Override
public Vector<TblATO_KPIDETAIL> getNet(HashMap<String, String> params) {
CollIBMWithCMD cmd = new CollIBMWithCMD();
return cmd.getNet(params);
}
/**
* 采集文件变更指标
*/
@Override
public Vector<TblATO_KPIDETAIL> getFileChange(HashMap<String, String> params) {
CollIBMWithCMD cmd = new CollIBMWithCMD();
return cmd.getFileChange(params);
}
private static String read(String prompt) {
Scanner scanner = new Scanner(System.in);
System.out.print(prompt);
return scanner.nextLine();
}
public static void main(String[] args) {
System.out.println("***************IBM Collect Test Begin*********************");
String deviceId = read("HOST_NAME(p780dw1):");
String methodStr = read("METHOD(0:getAll, 1:getConfig, 2:getCpu, 3:getMemory, 4:getFileSystem, 5:getDisk):");
// String deviceId = "";
// String methodStr = "4";
System.out.println("HOST_NAME=" + deviceId);
HashMap<String, String> params = new HashMap<String, String>();
params.put("DEVICEID", deviceId);
int method = Integer.parseInt(methodStr);
Vector<TblATO_KPIDETAIL> result = new Vector<TblATO_KPIDETAIL>();
CollIBMHost collector = new CollIBMHost();
switch (method) {
case 0:
result.addAll(collector.getConfig(params));
result.addAll(collector.getCpu(params));
result.addAll(collector.getMemory(params));
result.addAll(collector.getFileSystem(params));
result.addAll(collector.getDisk(params));
break;
case 1:
result.addAll(collector.getConfig(params));
break;
case 2:
result.addAll(collector.getCpu(params));
break;
case 3:
result.addAll(collector.getMemory(params));
break;
case 4:
result.addAll(collector.getFileSystem(params));
break;
case 5:
result.addAll(collector.getDisk(params));
break;
default:
break;
}
System.out.println("***************IBM Collect Test End*********************");
for (int i = 0; i < result.size(); i++) {
TblATO_KPIDETAIL record = (TblATO_KPIDETAIL) result.get(i);
System.out.println(record.UNIT_ID + "\t" + record.KPI_ID + "\t" + record.KPI_VALUE + "\t" + record.CLL_TIME);
}
}
}