File: //opt/OV/OpC/examples/jopcagtapi/JOpcMonValueTest.java
import java.io.*;
import java.util.*;
import com.hp.openview.ib.api.jopc.*;
class JOpcMonValueTest
{
private static BufferedReader stdin = null;
private static String lastID = null;
private static JOpcMonValue msg = null;
public static void main(String args[]) throws JOpcException, IOException,
ClassNotFoundException
{
stdin = new BufferedReader(new InputStreamReader(System.in));
try {
System.out.println("JOpcMonValueTest startup");
msg = new JOpcMonValue();
System.out.print("Enter monitor name (i.E. swap_util): ");
System.out.flush();
String var = stdin.readLine();
msg.setMonVar(var);
System.out.print("Enter monitor value (a double): ");
System.out.flush();
String valStr = stdin.readLine();
if((valStr != null) && (valStr.length() > 0))
{
try
{
Double v = new Double(valStr);
msg.setMonValue(v.doubleValue());
System.out.print("Enter optional parameters (format <var>=<value>): ");
System.out.flush();
String option_var = stdin.readLine();
msg.setOptionVar(option_var);
System.out.print("Enter message object (a string): ");
System.out.flush();
String msg_obj = stdin.readLine();
msg.setObject(msg_obj);
// Send the value if the user has entered something numberish
msg.send();
System.out.println("Sent monitor value " + var + " = " + valStr);
}
catch(NumberFormatException e){
System.out.println("ERROR> Bad numeric value: " + valStr);
}
}
}
catch(JOpcException jopce){
System.out.println("Exception occured!");
System.out.println("Message: " + jopce.getMessage());
System.out.println("Stack Trace: " + jopce.getStack());
}
} // END main METHOD
} // END CLASS