TestRunner.java 2.4 KB
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{
		// TODO Auto-generated method stub
		
		ArrayList<OraMon> oraList = new ArrayList<OraMon>();
		
		OraMon mon1 = new OraMon("jdbc:oracle:thin:@//hostname:1521/SID1","system","passw0rd");
		OraMon mon2 = new OraMon("jdbc:oracle:thin:@//hostname:1521/SID1","system","passw0rd");
		mon1.open();
		mon2.open();
		oraList.add(mon1);
		oraList.add(mon2);
				
		int times = 10;
		while(times-- > 0) {
			for(OraMon mon : oraList) {
				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"
						+ "CPUs: " + mon.getNumberOfCPUs() 
						+ " CPU Time: " + mon.getCPUTimePerSecond() + "ms"
						+ " CPU Usage: " + String.format("%1$,.2f", mon.getCPUPercent()) + "%"
						+ "\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"
						);
				
			}
			Thread.sleep(15000);
		}
		
		// Close all mon objects
		for(OraMon mon : oraList) {
			mon.close();
		}
	}

}