Get statistics(this howto is deprecated)Tag(s): DEPRECATED
The component Jaguar/Monitoring is used to extract the statistics related to particular activities hosted by Jaguar.
First here a class containing useful constants.
package com.rgagnon.servlet;
import com.sybase.jaguar.system.*;
public class StatsConstants {
// generic keys
static short[] keys = {
(short)(MONITOR_COMPONENT_INVOKE.value),
(short)(MONITOR_COMPONENT_ACTIVE.value),
(short)(MONITOR_COMPONENT_POOLED.value),
(short)(MONITOR_COMPONENT_COMPLETE.value),
(short)(MONITOR_COMPONENT_ROLLBACK.value),
(short)(MONITOR_SESSION_IIOP.value),
(short)(MONITOR_REQUEST_IIOP.value),
(short)(MONITOR_NETWORK_IIOP_READ_BYTES.value),
(short)(MONITOR_NETWORK_IIOP_WRITE_BYTES.value),
(short)(MONITOR_COMPONENT_INVOKE.value + MONITOR_LAST_MAXIMUM.value),
(short)(MONITOR_COMPONENT_ACTIVE.value + MONITOR_LAST_MAXIMUM.value),
(short)(MONITOR_COMPONENT_POOLED.value + MONITOR_LAST_MAXIMUM.value),
(short)(MONITOR_COMPONENT_COMPLETE.value + MONITOR_LAST_MAXIMUM.value),
(short)(MONITOR_COMPONENT_ROLLBACK.value + MONITOR_LAST_MAXIMUM.value),
(short)(MONITOR_SESSION_IIOP.value + MONITOR_LAST_MAXIMUM.value),
(short)(MONITOR_REQUEST_IIOP.value + MONITOR_LAST_MAXIMUM.value),
(short)(MONITOR_NETWORK_IIOP_READ_BYTES.value+MONITOR_LAST_MAXIMUM.value),
(short)(MONITOR_NETWORK_IIOP_WRITE_BYTES.value+MONITOR_LAST_MAXIMUM.value),
(short)(MONITOR_COMPONENT_INVOKE.value + MONITOR_PEAK_MAXIMUM.value),
(short)(MONITOR_COMPONENT_ACTIVE.value + MONITOR_PEAK_MAXIMUM.value),
(short)(MONITOR_COMPONENT_POOLED.value + MONITOR_PEAK_MAXIMUM.value),
(short)(MONITOR_COMPONENT_COMPLETE.value + MONITOR_PEAK_MAXIMUM.value),
(short)(MONITOR_COMPONENT_ROLLBACK.value + MONITOR_PEAK_MAXIMUM.value),
(short)(MONITOR_SESSION_IIOP.value + MONITOR_PEAK_MAXIMUM.value),
(short)(MONITOR_REQUEST_IIOP.value + MONITOR_PEAK_MAXIMUM.value),
(short)(MONITOR_NETWORK_IIOP_READ_BYTES.value+MONITOR_PEAK_MAXIMUM.value),
(short)(MONITOR_NETWORK_IIOP_WRITE_BYTES.value+MONITOR_PEAK_MAXIMUM.value)
};
// connection cache keys
static short[] connkeys = {
(short)(MONITOR_CONNCACHE_ACTIVE.value),
(short)(MONITOR_CONNCACHE_CLOSED.value),
(short)(MONITOR_CONNCACHE_INVOKE.value),
(short)(MONITOR_CONNCACHE_FORCED.value),
(short)(MONITOR_CONNCACHE_OPENED.value),
(short)(MONITOR_CONNCACHE_NOWAIT.value),
(short)(MONITOR_CONNCACHE_REOPENED.value),
(short)(MONITOR_CONNCACHE_WAITED.value),
(short)(MONITOR_CONNCACHE_ACTIVE.value + MONITOR_LAST_MAXIMUM.value),
(short)(MONITOR_CONNCACHE_CLOSED.value + MONITOR_LAST_MAXIMUM.value),
(short)(MONITOR_CONNCACHE_INVOKE.value + MONITOR_LAST_MAXIMUM.value),
(short)(MONITOR_CONNCACHE_FORCED.value + MONITOR_LAST_MAXIMUM.value),
(short)(MONITOR_CONNCACHE_OPENED.value + MONITOR_LAST_MAXIMUM.value),
(short)(MONITOR_CONNCACHE_NOWAIT.value + MONITOR_LAST_MAXIMUM.value),
(short)(MONITOR_CONNCACHE_REOPENED.value + MONITOR_LAST_MAXIMUM.value),
(short)(MONITOR_CONNCACHE_WAITED.value + MONITOR_LAST_MAXIMUM.value),
(short)(MONITOR_CONNCACHE_ACTIVE.value + MONITOR_PEAK_MAXIMUM.value),
(short)(MONITOR_CONNCACHE_CLOSED.value + MONITOR_PEAK_MAXIMUM.value),
(short)(MONITOR_CONNCACHE_INVOKE.value + MONITOR_PEAK_MAXIMUM.value),
(short)(MONITOR_CONNCACHE_FORCED.value + MONITOR_PEAK_MAXIMUM.value),
(short)(MONITOR_CONNCACHE_OPENED.value + MONITOR_PEAK_MAXIMUM.value),
(short)(MONITOR_CONNCACHE_NOWAIT.value + MONITOR_PEAK_MAXIMUM.value),
(short)(MONITOR_CONNCACHE_REOPENED.value + MONITOR_PEAK_MAXIMUM.value),
(short)(MONITOR_CONNCACHE_WAITED.value + MONITOR_PEAK_MAXIMUM.value)
};
// component keys
static short[] compkeys = {
(short)(MONITOR_COMPONENT_INVOKE.value),
(short)(MONITOR_COMPONENT_ACTIVE.value),
(short)(MONITOR_COMPONENT_POOLED.value),
(short)(MONITOR_COMPONENT_COMPLETE.value),
(short)(MONITOR_COMPONENT_ROLLBACK.value),
(short)(MONITOR_COMPONENT_INVOKE.value + MONITOR_LAST_MAXIMUM.value),
(short)(MONITOR_COMPONENT_ACTIVE.value + MONITOR_LAST_MAXIMUM.value),
(short)(MONITOR_COMPONENT_POOLED.value + MONITOR_LAST_MAXIMUM.value),
(short)(MONITOR_COMPONENT_COMPLETE.value + MONITOR_LAST_MAXIMUM.value),
(short)(MONITOR_COMPONENT_ROLLBACK.value + MONITOR_LAST_MAXIMUM.value),
(short)(MONITOR_COMPONENT_INVOKE.value + MONITOR_PEAK_MAXIMUM.value),
(short)(MONITOR_COMPONENT_ACTIVE.value + MONITOR_PEAK_MAXIMUM.value),
(short)(MONITOR_COMPONENT_POOLED.value + MONITOR_PEAK_MAXIMUM.value),
(short)(MONITOR_COMPONENT_COMPLETE.value + MONITOR_PEAK_MAXIMUM.value),
(short)(MONITOR_COMPONENT_ROLLBACK.value + MONITOR_PEAK_MAXIMUM.value)
};
}
static String pad10(double[] data, int item, short[] keys) {
String s = "" + data[item];
if (s.endsWith(".0")) {
s = s.substring(0, s.length() - 2);
}
if (item < keys.length - 1) {
s = s + ",";
}
while (s.length() < 10) {
s = s + " ";
}
return s;
}protected void doServer(java.io.PrintWriter out) {
java.util.Properties props = new java.util.Properties();
props.put("org.omg.CORBA.ORBClass", "com.sybase.CORBA.ORB");
ORB orb = ORB.init((String[])null, props);
Monitoring jm =
MonitoringHelper.narrow(orb.string_to_object
("Jaguar/Monitoring"));
out.println("<h1>Server Stats</h1><pre>");
out.println("");
out.println
("Jaguar Component Transaction Server");
out.print
("-------- ---------------------------- ------------------");
out.println(" --------------------------------------");
out.print
("counter: invoke active pooled complete rollback");
out.println(" sessions requests rd bytes wr bytes");
double[] data = jm.monitor("Server", "", StatsConstants.keys);
int item = 0;
out.print("\ncurrent, ");
for (int j = 0; j < StatsConstants.keys.length / 3; j++, item++) {
out.print(pad10(data, item, StatsConstants.keys));
}
out.print("\nlastMax, ");
for (int j = 0; j < StatsConstants.keys.length / 3; j++, item++) {
out.print(pad10(data, item, StatsConstants.keys));
}
out.print("\npeakMax, ");
for (int j = 0; j < StatsConstants.keys.length / 3; j++, item++) {
out.print(pad10(data, item, StatsConstants.keys));
}
out.println("</pre>");
}
protected void doConnCache(java.io.PrintWriter out) {
java.util.Properties props = new java.util.Properties();
props.put("org.omg.CORBA.ORBClass", "com.sybase.CORBA.ORB");
ORB orb = ORB.init((String[])null, props);
Monitoring jm =
MonitoringHelper.narrow(orb.string_to_object
("Jaguar/Monitoring"));
out.println("<h1>Connection caches stats</h1><pre>");
out.println("");
out.println("Cache ");
out.print
("-------- ---------------------------- ------------------");
out.println(" --------------------------------------");
out.print
("counter: active closed invoked forced opened ");
out.println("nowaited reopened waited");
double[] data = jm.monitor
("Connection Cache", "", StatsConstants.connkeys);
int item = 0;
out.print("\ncurrent, ");
for (int j=0;j<StatsConstants.connkeys.length / 3;j++,item++) {
out.print(pad10(data, item,StatsConstants.connkeys));
}
out.print("\nlastMax, ");
for (int j=0;j<StatsConstants.connkeys.length / 3;j++,item++) {
out.print(pad10(data, item, StatsConstants.connkeys));
}
out.print("\npeakMax, ");
for (int j=0;j<StatsConstants.connkeys.length / 3;j++,item++) {
out.print(pad10(data, item, StatsConstants.connkeys));
}
out.println("</pre>");
}
protected void doCache(java.io.PrintWriter out, String name) {
java.util.Properties props = new java.util.Properties();
props.put("org.omg.CORBA.ORBClass", "com.sybase.CORBA.ORB");
ORB orb = ORB.init((String[])null, props);
Monitoring jm =
MonitoringHelper.narrow(orb.string_to_object
("Jaguar/Monitoring"));
out.println("<h1>Connection Cache Stats [" + name + "]</h1><pre>");
out.println("");
out.println("Cache ");
out.print
("-------- ---------------------------- ------------------");
out.println(" --------------------------------------");
out.print
("counter: active closed invoked forced opened ");
out.println("nowaited reopened waited");
double[] data = jm.monitor
("Connection Cache", name, StatsConstants.connkeys);
int item = 0;
out.print("\ncurrent, ");
for (int j=0;j<StatsConstants.connkeys.length / 3; j++, item++) {
out.print(pad10(data, item,StatsConstants.connkeys));
}
out.print("\nlastMax, ");
for (int j=0;j<StatsConstants.connkeys.length / 3; j++, item++) {
out.print(pad10(data, item, StatsConstants.connkeys));
}
out.print("\npeakMax, ");
for (int j=0;j<StatsConstants.connkeys.length / 3; j++, item++) {
out.print(pad10(data, item, StatsConstants.connkeys));
}
out.println("</pre>");
}
protected void doComponent
(java.io.PrintWriter out, String type, String name) {
java.util.Properties props = new java.util.Properties();
props.put("org.omg.CORBA.ORBClass", "com.sybase.CORBA.ORB");
ORB orb = ORB.init((String[])null, props);
Monitoring jm =
MonitoringHelper.narrow
(orb.string_to_object("Jaguar/Monitoring"));
out.println("<h1>Stats for " + type + " [" + name + "]</h1><pre>");
out.println("");
out.println("Component ");
out.println
("-------- ---------------------------- ------------------");
out.println
("counter: invoke active pooled complete rollback");
double[] data = jm.monitor(type, name, StatsConstants.compkeys);
int item = 0;
out.print("\ncurrent, ");
for (int j=0;j<StatsConstants.compkeys.length / 3; j++, item++) {
out.print(pad10(data, item,StatsConstants.compkeys));
}
out.print("\nlastMax, ");
for (int j=0;j<StatsConstants.compkeys.length / 3; j++, item++) {
out.print(pad10(data, item, StatsConstants.compkeys));
}
out.print("\npeakMax, ");
for (int j=0;j<StatsConstants.compkeys.length / 3; j++, item++) {
out.print(pad10(data, item, StatsConstants.compkeys));
}
out.println("</pre>");
}package: doComponent(out, 'Package', 'MyPackage') component: doComponent(out, 'Component', 'MyPackage/MyComponent')
mail_outline
Send comment, question or suggestion to howto@rgagnon.com
Send comment, question or suggestion to howto@rgagnon.com