[Zenoss-dev] Java XML RPC Example
chenthor
chenthor at bbn.com
Wed Jan 16 13:13:27 EST 2008
This example uses the the Apache XML-RPC library (http://ws.apache.org/xmlrpc/index.html) and Java 6 to send an event to the zenoss server.
Required jars on the classpath (all available from the Apache download):
xmlrpc-client-3.1.jar
ws-commons-util-1.0.2.jar
xmlrpc-common-3.1.jar
Code:
import java.net.URL;
import java.util.HashMap;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
public class JavaRPCExample {
public static void main(String[] args) throws Exception {
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(new URL("http://MYHOST:8080/zport/dmd/ZenEventManager"));
config.setBasicUserName("admin");
config.setBasicPassword("zenoss");
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
HashMap<String,Object> params = new HashMap<String,Object>();
params.put("device", "mydevice");
params.put("component", "eth0");
params.put("summary", "eth0 is down");
params.put("severity", 4);
params.put("eventClass", "/Net");
client.execute("sendEvent", new Object[]{params});
}
}
Thats it.
-------------------- m2f --------------------
Read this topic online here:
http://community.zenoss.com/forums/viewtopic.php?p=15396#15396
-------------------- m2f --------------------
More information about the zenoss-dev
mailing list