This sample program shows how to remotely view the ORB runtime properties.
package monitor;
import org.omg.CORBA.ORB;
import com.sssw.jbroker.api.admin.Manageable;
import com.sssw.jbroker.api.admin.ManageableCollection;
public class Client
{
public static void main(String[] args) throws Exception
{
| // create the ORB
| ORB orb = ORB.init(args, null);
|
| // lookup the manageable
| String lookup = "corbaloc::"+args[0]+":"+args[1]+"/jBrokerAdmin";
| Manageable mgble = (Manageable) orb.string_to_object(lookup);
|
| // list the manageable
| listManageable(mgble, 0);
}
static void listManageable(Manageable mgble, int depth) throws Exception
{
| System.out.println(tab(depth) + mgble.getName() + ":");
|
| depth++;
|
| // print the properties
| String[] props = mgble.propertyNames();
| Object[] values = mgble.getProperties(props);
| for (int i=0; i < props.length; i++) {
| | if (values[i] instanceof Manageable) {
| | | System.out.println(tab(depth) + props[i] + ":");
| | | listManageable((Manageable) values[i], depth);
| | } else System.out.println(tab(depth) + props[i] + "=" + values[i]);
| }
|
| // print the manageable collection
| if (mgble instanceof ManageableCollection) {
| | ManageableCollection mgblColl = (ManageableCollection) mgble;
| | String[] names = mgblColl.list();
| | for (int i=0; i < names.length; i++) {
| | | listManageable(mgblColl.getManageable(names[i]), depth);
| | }
| }
}
private static String tab(int num)
{
| String result="";
| for (int i=0; i < num; i++) result += " ";
| return result;
}
}
The sample output shows runtime properties like connections, threads, memory, requests, objects, etc.
jBrokerAdmin:
FreeMemory=6364960
UpTime=8176
TotalMemory=8388608
OSVersion=SunOS sparc 5.8
FreeMemoryPercent=75.876236
JavaVersion=1.2.2
ORBAdmin:
RequestsSent=0
RequestsReceived=8
OutGoingConnections=0
InComingConnections=0
GatewayMode=false
MulticastRequestsReceived=0
InComingSSLConnections=0
Threads=0
LocatesReceived=1
HttpTunnelMode=false
LocatesSent=0
OutGoingSSLConnections=0
MulticastRequestsSent=0
PlainIDLObjects=1
PlainRMIObjects=2
Copyright © 2003, 2004 Novell, Inc. All rights reserved. Copyright © 2001, 2002, 2003 SilverStream Software, LLC. All rights reserved.