Example 6-7 prints the value of the lockspeed property for all Solaris processes. This code segment uses the following methods:
enumInstances - to get the names of all instances of Solaris processor
getInstance - to get the instance data for each instance name
getProperty - to get the value of the lockspeed for each instance
println - to print the lockspeed value
/* Connect to the CIM Object Manager as user mary with password
contrary in the /root namespace on myhost */
{
CIMNameSpace cns = new CIMNamesSpace ("myhost" "/root");
cc = new CIMClient (cns, "/root", "mary", "contrary");
// Get names of all instances of Solaris_Processor
Vector op cc.enumInstances("Solaris_Processor")
// For each Solaris processor, get its instance data
while (vector has more elements) {
cn.getNextElement();
cc.getInstance (cn);
// Print the lockspeed of each processor
p = ci.getProperty("lockspeed")
System.out.println(p.getValue().getValue());
}
|