stats.java revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* ident "%Z%%M% %I% %E% SMI"
*
* Copyright (c) 2001 by Sun Microsystems, Inc.
* All rights reserved.
*
*/
public class stats {
/*
* -u username
* -p project
* -h host
* -I id to auth
* -P passwd
*/
boolean showproject = false;
boolean listprops = false;
boolean checkonly = false;
int intervalms = 5000;
"\t" + "-u userid -p projectname\n" +
"\t" + "-r{aw} [property name] -d{elta} [property name]\n" +
"\t" + "-L{ist all property names}\n" +
"\t" + "-C{heck for existence}\n" +
"\t" + "-i [update interval (sec)]\n" +
"\t" + "-h host -I auth_user_id -P auth_user_passwd\n" +
"\n" +
"-I and -P are always required.\n" +
"At least one of -r or -d is required unless -L or -C are used.\n" +
"If -L is specifed, -r, -d, and -i are ignored.\n" +
"If -C is specified, one of -u or -p must be used.\n" +
"Default value for -i is " +
"Default value for -h is \"localhost\".");
}
int i, l;
for (i = 0; i < argc; i++) {
// specific user to monitor
else
// specific project to monitor
else
// hostname
else
// update interval
s = args[++i];
else
// user authentication identity
}
else
// user authentication password
else
// raw property to be monitored
else {
continue;
}
// delta property to be monitored
else {
continue;
}
// list property names only
listprops = true;
// check for existence only
checkonly = true;
} else {
// unknown arg
return;
}
}
}
Enumeration e = v.elements();
while (e.hasMoreElements())
}
// compute val1 - val2
return new String("null");
else if (a instanceof UnsignedInt64 && b instanceof UnsignedInt64) {
long x = ((UnsignedInt64) a).longValue();
long y = ((UnsignedInt64) b).longValue();
long z = x - y;
} else if (a instanceof UnsignedInt32 && b instanceof UnsignedInt32) {
int x = ((UnsignedInt32) a).intValue();
int y = ((UnsignedInt32) b).intValue();
int z = x - y;
float x = ((Float) a).floatValue();
float y = ((Float) b).floatValue();
float z = x - y;
} else
return rv;
}
if (showproject) {
new CIMValue("Solaris_ActiveProject"));
} else {
new CIMValue("Solaris_ActiveUser"));
}
new CIMValue("Solaris_ComputerSystem"));
new CIMValue("Solaris_OperatingSystem"));
new CIMValue("SunOS"));
try {
} catch (CIMException x) {
}
}
void validateProps() {
// assume User and ProcessAggregate are the same...
"Solaris_UserProcessAggregateStatisticalInformation");
try {
} catch (CIMException x) {
}
while (e.hasMoreElements()) {
}
}
}
void listProps() {
// assume User and ProcessAggregate are the same...
"Solaris_UserProcessAggregateStatisticalInformation");
try {
Vector v = c.getAllProperties();
Enumeration e = v.elements();
while (e.hasMoreElements()) {
}
} catch (Exception x) {
}
}
// handle comd-line args
// default to localhost
try {
} catch (Exception x) {
}
}
// always need auth id
}
// initialize client connection to CIMOM
try {
// System.err.println("CLIENT: " + client);
} catch (CIMException x) {
}
// just list available properties?
if (listprops) {
listProps();
}
// always need a user id or project name
"User (-u) or project (-p) must be specified.");
} else {
showproject = true;
}
} else
// just check for entity existence?
if (checkonly) {
}
// examine specified process aggregate
className += "ProcessAggregateStatisticalInformation";
// check that all specified props exist
long timestamp = 0;
long lastTimestamp = 0;
String p;
try {
// System.err.println("OP: " + op);
while (true) {
// System.err.println("CI: " + ci);
if (timestamp > lastTimestamp) {
while (e.hasMoreElements()) {
p = (String) e.nextElement();
}
while (e.hasMoreElements()) {
p = (String) e.nextElement();
{
String a = "x";
String b = "x";
if (o != null)
a = o.toString();
if (n != null)
b = n.toString();
// System.out.print(p + ": " + a + "/" + b + "\t");
}
if (deltaprops.contains(p)) {
s = delta(n, o);
} else {
s = n.toString();
}
}
}
}
} catch (Exception x) {
x.printStackTrace();
}
}
}
}