TestRunner.java
6.02 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
package se.lil.om;
import java.util.ArrayList;
public class TestRunner {
public TestRunner() {
// TODO Auto-generated constructor stub
}
/**
* @param args
*/
public static void main(String[] args) throws Throwable {
//runner1();
//test1();
testTns();
//testPDB();
}
public static void testPDB() throws Throwable {
OraMon cdb = new OraMon("jdbc:oracle:thin:@//u03634.kap.rsv.se:1526/DB1K12","dbsnmp","dbsnmp"); // CDB
OraMon pdb = new OraMon("jdbc:oracle:thin:@//u03634.kap.rsv.se:1526/DA1K001","dbsnmp","dbsnmp"); // PDB
int times = 5;
while(times-- > 0) {
cdb.getData(0, "DA1K001");
pdb.getData();
System.out.println("PDB CPU: " + pdb.getCPUPercent());
System.out.println("CDB CPU: " + cdb.getCPUPercent());
System.out.println("DA1K001: " + cdb.getCPUPercent(false, "DA1K001"));
System.out.println("DA1K002: " + cdb.getCPUPercent(false, "DA1K002"));
System.out.println("TOTAL : " + (cdb.getCPUPercent(false, "DA1K001") + cdb.getCPUPercent(false, "DA1K002")));
System.out.println("PDB LIO: " + pdb.getLogicalReadsPerSecond());
System.out.println("CDB LIO: " + cdb.getLogicalReadsPerSecond());
System.out.println("DA1K001: " + cdb.getLogicalReadsPerSecond("DA1K001"));
System.out.println("DA1K002: " + cdb.getLogicalReadsPerSecond("DA1K002"));
System.out.println("TOTAL : " + (cdb.getLogicalReadsPerSecond("DA1K001") + cdb.getLogicalReadsPerSecond("DA1K002")));
System.out.println("Sleeping 15s\n");
Thread.sleep(60000);
}
cdb.close();
pdb.close();
}
public static void test1() throws Throwable {
OraMon mon = new OraMon("jdbc:oracle:thin:@//u02822.kap.rsv.se:1526/DB1K06","dbsnmp","dbsnmp"); // CDB
System.out.println("getData returned: " + mon.getData());
System.out.println("getDatabaseName: " + mon.getDBName());
}
public static void testTns() throws Throwable {
OraMon mon = new OraMon("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(Host=u08435.kap.rsv.se)(Port=1541))(ADDRESS=(PROTOCOL=TCP)(Host=u08436.kap.rsv.se)(Port=1541)))(CONNECT_DATA=(SERVICE_NAME=BI1K010)))","dbsnmp","dbsnmp"); // PDB using TNS
//OraMon mon = new OraMon("jdbc:oracle:thin:@//u00153.kap.rsv.se:1526/DB1K01","dbsnmp","dbsnmp");
System.out.println("getData returned: " + mon.getData());
System.out.println("getDatabaseName: " + mon.getDBName());
System.out.println("getServiceName: " + mon.getServiceName());
System.out.println("getFriendlyName: " + mon.getFriendlyName());
System.out.println("getConString: " + mon.getConString());
System.out.println("getNumberOfCPUs: " + mon.getNumberOfCPUs());
}
public static void runner1() throws Throwable {
// TODO Auto-generated method stub
//ArrayList<OraMon> oraList = new ArrayList<OraMon>();
ArrayList<OraMon> oraList = Registry.getList();
//OraMon mon1 = new OraMon("jdbc:oracle:thin:@uvp3dbkappkg:1550:VP1K03","dbsnmp","dbsnmp"); // SID eller Service Name format
//OraMon mon1 = new OraMon("jdbc:oracle:thin:@//u00154.kap.rsv.se:1526/DB1K01","dbsnmp","dbsnmp");
//OraMon mon1 = new OraMon("jdbc:oracle:thin:@//u03634.kap.rsv.se:1526/DA1K001","dbsnmp","dbsnmp"); // PDB, CDB är DB1K12
//OraMon mon1 = new OraMon("jdbc:oracle:thin:@//u03634.kap.rsv.se:1526/DA1K002","dbsnmp","dbsnmp"); // Andra PDB på CDB DB1K12
OraMon mon1 = new OraMon("jdbc:oracle:thin:@//u03634.kap.rsv.se:1526/DB1K12","dbsnmp","dbsnmp"); // PDB, CDB är DB1K12
//OraMon mon2 = new OraMon("jdbc:oracle:thin:@host:port:sid","user","pass"); // SID format
mon1.open();
//mon2.open();
oraList.add(mon1);
//oraList.add(mon2);
int times = 100;
while(times-- > 0) {
int num = 0;
for(OraMon mon : oraList) {
num++;
Long ts1 = System.currentTimeMillis();
mon.getData();
Long time = System.currentTimeMillis() - ts1;
System.out.println(
// "Logical reads:" + mon.getLogicalReadsPerSecond()
// + " Consistent gets: " + mon.getPerSecondValue("consistent gets")
// + " Block Gets: " + mon.getPerSecondValue("db block gets")
// + " Block Changes: " + mon.getPerSecondValue("db block changes")
// + "\n"
"MON" + num + " CPUs: " + mon.getNumberOfCPUs()
+ " CPU Time: " + String.format("%1$,.2f", mon.getCPUTimePerSecond()/1000) + "ms/s"
+ " CPU Usage: " + String.format("%1$,.2f", mon.getCPUPercent()) + "%"
+ " CPU xNIWT: " + String.format("%1$,.2f", mon.getCPUPercent(true)) + "%"
+ " OS Busy: " + String.format("%1$,.2f", mon.getOsBusyPercent()) + "%"
// + " (Raw: " + mon.getCPURawValue()
// + " Diff: " + mon.getCPURawDiff()
// + " Available: " + String.format("%1$,.2f", mon.getCPUAvailableSeconds()*1000) + ")"
+ " NIWTime: " + String.format("%1$,.2f", mon.niwTime.getPerSecondValue()) + "ms/s"
// + "\n"
// + "Cache Hit Ratio: " + String.format("%1$,.2f", mon.getCacheHitRatioPercent()) + "%"
// + " Buffer Cache Hit Ratio: " + String.format("%1$,.2f", mon.getBufferCacheHitRatioPercent()) + "%"
// + "\n"
// + "Redo size: " + mon.getPerSecondValue("redo size")
// + " Phys Reads: " + mon.getPerSecondValue("physical reads")
// + " Phys Writes: " + mon.getPerSecondValue("physical writes")
// + " Redo Writes: " + mon.getPerSecondValue("redo writes")
// + "\n"
// + "Non Idle Wait: " + mon.getPerSecondValue("non-idle wait time")
// + " File IO Wait: " + mon.getPerSecondValue("file io wait time")
// + "\n"
// + "Executes: " + mon.getPerSecondValue("execute count")
// + " User calls: " + mon.getPerSecondValue("user calls")
// + " Commits: " + mon.getPerSecondValue("user commits")
// + " Rollbacks: " + mon.getPerSecondValue("user rollbacks")
// + " Parse tot: " + mon.getPerSecondValue("parse count (total)")
// + " Parse hard: " + mon.getPerSecondValue("parse count (hard)")
+ "\nTime: " + time + "ms"
);
}
System.out.println("---------------------------------------------------------------------------------------------------------------");
Thread.sleep(15000);
}
// Close all mon objects
for(OraMon mon : oraList) {
mon.close();
}
}
}