Tagit bort Actions.java.sed
Showing
1 changed file
with
0 additions
and
113 deletions
JavaMON/Actions.java.sed
deleted
100644 → 0
| 1 | /* | ||
| 2 | * LoadRunner Java script. (Build: _build_number_) | ||
| 3 | * | ||
| 4 | * Script Description: | ||
| 5 | * | ||
| 6 | */ | ||
| 7 | |||
| 8 | import java.util.ArrayList; | ||
| 9 | import lrapi.lr; | ||
| 10 | import se.lil.om.*; | ||
| 11 | |||
| 12 | public class Actions | ||
| 13 | { | ||
| 14 | |||
| 15 | ArrayList<OraMon> oraList = new ArrayList<OraMon>(); | ||
| 16 | |||
| 17 | boolean firstIteration = true; | ||
| 18 | String empty = ""; | ||
| 19 | |||
| 20 | public int init() throws Throwable | ||
| 21 | { | ||
| 22 | if(lr.get_attrib_string("ConnectionString") == null || lr.get_attrib_string("User") == null || lr.get_attrib_string("Password") == null || | ||
| 23 | lr.get_attrib_string("ConnectionString").equals(empty) || lr.get_attrib_string("User").equals(empty) || lr.get_attrib_string("Password").equals(empty)) | ||
| 24 | { | ||
| 25 | lr.error_message("Attributes are missing for Oracle: ConnectionString, User or Password are null. Nothing to do, aborting vuser."); | ||
| 26 | lr.exit(lr.EXIT_VUSER, lr.FAIL); | ||
| 27 | } | ||
| 28 | |||
| 29 | String[] conS = lr.get_attrib_string("ConnectionString").split(","); | ||
| 30 | String[] usrS = lr.get_attrib_string("User").split(","); | ||
| 31 | String[] pasS = lr.get_attrib_string("Password").split(","); | ||
| 32 | |||
| 33 | if(conS.length != usrS.length || conS.length != pasS.length) | ||
| 34 | { | ||
| 35 | lr.error_message("Oracle has multiple comma separated connection strings but not the same number of multiple user or password strings. Cannot continue, abort."); | ||
| 36 | lr.exit(lr.EXIT_VUSER, lr.FAIL); | ||
| 37 | } | ||
| 38 | |||
| 39 | for(int x=0; x<conS.length; x++) | ||
| 40 | { | ||
| 41 | OraMon mon = new OraMon(); | ||
| 42 | lr.debug_message (lr.MSG_CLASS_EXTENDED_LOG , " Using " + conS[x].trim() + " User " + usrS[x].trim() + " Pass " + pasS[x].trim()); | ||
| 43 | mon.open(conS[x].trim(), usrS[x].trim(), pasS[x].trim()); | ||
| 44 | oraList.add(mon); | ||
| 45 | } | ||
| 46 | return 0; | ||
| 47 | }////end of init | ||
| 48 | |||
| 49 | |||
| 50 | public int action() throws Throwable | ||
| 51 | { | ||
| 52 | |||
| 53 | for(OraMon oracle : oraList) | ||
| 54 | { | ||
| 55 | lr.debug_message (lr.MSG_CLASS_EXTENDED_LOG , "#### ORACLE COUNTERS ####"); | ||
| 56 | lr.debug_message (lr.MSG_CLASS_EXTENDED_LOG, "Using: " + oracle.getConString()); | ||
| 57 | oracle.getData(); | ||
| 58 | lr.debug_message (lr.MSG_CLASS_EXTENDED_LOG, "Returned DB Name: " + oracle.getDBName()); | ||
| 59 | |||
| 60 | if(firstIteration == false) | ||
| 61 | { | ||
| 62 | String instance = oracle.getDBName(); | ||
| 63 | sendDataPoint("ORA Cpus (#) " + instance, oracle.getNumberOfCPUs()); | ||
| 64 | sendDataPoint("ORA Cpu Time (us/s) " + instance, oracle.getCPUTimePerSecond()); | ||
| 65 | sendDataPoint("ORA Cpu Usage (%) " + instance, oracle.getCPUPercent()); | ||
| 66 | sendDataPoint("ORA OS Busy (%) " + instance, oracle.getOsBusyPercent()); | ||
| 67 | sendDataPoint("ORA OS Load (#) " + instance, oracle.getOsLoad()); | ||
| 68 | sendDataPoint("ORA OS Load per Cpu (#) " + instance, oracle.getOsLoadPerCPU()); | ||
| 69 | sendDataPoint("ORA Logical Reads (#/s) " + instance, oracle.getLogicalReadsPerSecond()); | ||
| 70 | sendDataPoint("ORA Consistent Gets (#/s) " + instance, oracle.getPerSecondValue("consistent gets")); | ||
| 71 | sendDataPoint("ORA DB Block Gets (#/s) " + instance, oracle.getPerSecondValue("db block gets")); | ||
| 72 | sendDataPoint("ORA Cache Hit Ratio (%) " + instance, oracle.getCacheHitRatioPercent()); | ||
| 73 | sendDataPoint("ORA Buffer Cache Hit Ratio (%) " + instance, oracle.getBufferCacheHitRatioPercent()); | ||
| 74 | sendDataPoint("ORA DB Block Changes (#/s) " + instance, oracle.getPerSecondValue("db block changes")); | ||
| 75 | sendDataPoint("ORA Redo Size (#/s) " + instance, oracle.getPerSecondValue("redo size")); | ||
| 76 | sendDataPoint("ORA Physical Reads (#/s) " + instance, oracle.getPerSecondValue("physical reads")); | ||
| 77 | sendDataPoint("ORA Physical Writes (#/s) " + instance, oracle.getPerSecondValue("physical writes")); | ||
| 78 | sendDataPoint("ORA Redo Writes (#/s) " + instance, oracle.getPerSecondValue("redo writes")); | ||
| 79 | sendDataPoint("ORA Non-idle Wait Time (ms/s) " + instance, oracle.getPerSecondValue("non-idle wait time")); | ||
| 80 | sendDataPoint("ORA File I/O Wait Time (ms/s) " + instance, oracle.getPerSecondValue("file io wait time")); | ||
| 81 | sendDataPoint("ORA Executes (#/s) " + instance, oracle.getPerSecondValue("execute count")); | ||
| 82 | sendDataPoint("ORA User Calls (#/s) " + instance, oracle.getPerSecondValue("user calls")); | ||
| 83 | sendDataPoint("ORA User Commits (#/s) " + instance, oracle.getPerSecondValue("user commits")); | ||
| 84 | sendDataPoint("ORA User Rollbacks (#/s) " + instance, oracle.getPerSecondValue("user rollbacks")); | ||
| 85 | sendDataPoint("ORA Parse Count Total (#/s) " + instance, oracle.getPerSecondValue("parse count (total)")); | ||
| 86 | sendDataPoint("ORA Parse Count Hard (#/s) " + instance, oracle.getPerSecondValue("parse count (hard)")); | ||
| 87 | } else { | ||
| 88 | firstIteration = false; | ||
| 89 | } | ||
| 90 | } | ||
| 91 | |||
| 92 | return 0; | ||
| 93 | }////end of action | ||
| 94 | |||
| 95 | |||
| 96 | public int end() throws Throwable | ||
| 97 | { | ||
| 98 | for(OraMon oracle : oraList) | ||
| 99 | { | ||
| 100 | oracle.close(); | ||
| 101 | } | ||
| 102 | |||
| 103 | return 0; | ||
| 104 | }////end of end | ||
| 105 | |||
| 106 | // Needed to avoid LR12 VuGen from hanging in a CPU loop (later fixed by a patch but just in case) | ||
| 107 | public void sendDataPoint(String name, double value) | ||
| 108 | { | ||
| 109 | lr.user_data_point(name, value); | ||
| 110 | } | ||
| 111 | } | ||
| 112 | |||
| 113 |
-
Please register or sign in to post a comment