Actions.java.sed
4.8 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
/*
* LoadRunner Java script. (Build: _build_number_)
*
* Script Description:
*
*/
import java.util.ArrayList;
import lrapi.lr;
import se.lil.om.*;
public class Actions
{
ArrayList<OraMon> oraList = new ArrayList<OraMon>();
boolean firstIteration = true;
String empty = "";
public int init() throws Throwable
{
if(lr.get_attrib_string("ConnectionString") == null || lr.get_attrib_string("User") == null || lr.get_attrib_string("Password") == null ||
lr.get_attrib_string("ConnectionString").equals(empty) || lr.get_attrib_string("User").equals(empty) || lr.get_attrib_string("Password").equals(empty))
{
lr.error_message("Attributes are missing for Oracle: ConnectionString, User or Password are null. Nothing to do, aborting vuser.");
lr.exit(lr.EXIT_VUSER, lr.FAIL);
}
String[] conS = lr.get_attrib_string("ConnectionString").split(",");
String[] usrS = lr.get_attrib_string("User").split(",");
String[] pasS = lr.get_attrib_string("Password").split(",");
if(conS.length != usrS.length || conS.length != pasS.length)
{
lr.error_message("Oracle has multiple comma separated connection strings but not the same number of multiple user or password strings. Cannot continue, abort.");
lr.exit(lr.EXIT_VUSER, lr.FAIL);
}
for(int x=0; x<conS.length; x++)
{
OraMon mon = new OraMon();
lr.debug_message (lr.MSG_CLASS_EXTENDED_LOG , " Using " + conS[x].trim() + " User " + usrS[x].trim() + " Pass " + pasS[x].trim());
mon.open(conS[x].trim(), usrS[x].trim(), pasS[x].trim());
oraList.add(mon);
}
return 0;
}////end of init
public int action() throws Throwable
{
for(OraMon oracle : oraList)
{
lr.debug_message (lr.MSG_CLASS_EXTENDED_LOG , "#### ORACLE COUNTERS ####");
lr.debug_message (lr.MSG_CLASS_EXTENDED_LOG, "Using: " + oracle.getConString());
oracle.getData();
lr.debug_message (lr.MSG_CLASS_EXTENDED_LOG, "Returned DB Name: " + oracle.getDBName());
if(firstIteration == false)
{
String instance = oracle.getDBName();
sendDataPoint("ORA Cpus (#) " + instance, oracle.getNumberOfCPUs());
sendDataPoint("ORA Cpu Time (us/s) " + instance, oracle.getCPUTimePerSecond());
sendDataPoint("ORA Cpu Usage (%) " + instance, oracle.getCPUPercent());
sendDataPoint("ORA OS Busy (%) " + instance, oracle.getOsBusyPercent());
sendDataPoint("ORA OS Load (#) " + instance, oracle.getOsLoad());
sendDataPoint("ORA OS Load per Cpu (#) " + instance, oracle.getOsLoadPerCPU());
sendDataPoint("ORA Logical Reads (#/s) " + instance, oracle.getLogicalReadsPerSecond());
sendDataPoint("ORA Consistent Gets (#/s) " + instance, oracle.getPerSecondValue("consistent gets"));
sendDataPoint("ORA DB Block Gets (#/s) " + instance, oracle.getPerSecondValue("db block gets"));
sendDataPoint("ORA Cache Hit Ratio (%) " + instance, oracle.getCacheHitRatioPercent());
sendDataPoint("ORA Buffer Cache Hit Ratio (%) " + instance, oracle.getBufferCacheHitRatioPercent());
sendDataPoint("ORA DB Block Changes (#/s) " + instance, oracle.getPerSecondValue("db block changes"));
sendDataPoint("ORA Redo Size (#/s) " + instance, oracle.getPerSecondValue("redo size"));
sendDataPoint("ORA Physical Reads (#/s) " + instance, oracle.getPerSecondValue("physical reads"));
sendDataPoint("ORA Physical Writes (#/s) " + instance, oracle.getPerSecondValue("physical writes"));
sendDataPoint("ORA Redo Writes (#/s) " + instance, oracle.getPerSecondValue("redo writes"));
sendDataPoint("ORA Non-idle Wait Time (ms/s) " + instance, oracle.getPerSecondValue("non-idle wait time"));
sendDataPoint("ORA File I/O Wait Time (ms/s) " + instance, oracle.getPerSecondValue("file io wait time"));
sendDataPoint("ORA Executes (#/s) " + instance, oracle.getPerSecondValue("execute count"));
sendDataPoint("ORA User Calls (#/s) " + instance, oracle.getPerSecondValue("user calls"));
sendDataPoint("ORA User Commits (#/s) " + instance, oracle.getPerSecondValue("user commits"));
sendDataPoint("ORA User Rollbacks (#/s) " + instance, oracle.getPerSecondValue("user rollbacks"));
sendDataPoint("ORA Parse Count Total (#/s) " + instance, oracle.getPerSecondValue("parse count (total)"));
sendDataPoint("ORA Parse Count Hard (#/s) " + instance, oracle.getPerSecondValue("parse count (hard)"));
} else {
firstIteration = false;
}
}
return 0;
}////end of action
public int end() throws Throwable
{
for(OraMon oracle : oraList)
{
oracle.close();
}
return 0;
}////end of end
// Needed to avoid LR12 VuGen from hanging in a CPU loop (later fixed by a patch but just in case)
public void sendDataPoint(String name, double value)
{
lr.user_data_point(name, value);
}
}