Hi,
When I am looking for a quick example I usually go to the old codewizard for very basic examples:
http://support.nimsoft.com/Files%5CArchive%5C00057%5Ccode_wizard-1_70.zip
I know this has not been updated in a LONG time but the basic are the same.
I used to do quickly generate the java code below.
hope this helps
//#################################################################
//# CodeWizard: Java
//# This code was generated with the Nimsoft CodeWizard version 1.70
//# Date: Wednesday, May 18, 2016
//
package example;
import java.io.IOException;
import com.nimsoft.nimbus.*;
import com.nimsoft.nimbus.ci.ConfigurationItem;
public class example_probe {
static NimLog logger = NimLog.getLogger(example_probe.class);
public static void main(String[] args) {
try {
example_probe exampleprobe = new example_probe();
exampleprobe.doit(args);
}catch(Exception e) {
e.printStackTrace();
}
}
public void doit(String[] args) throws Exception {
NimProbe probe = null;
// Loop to handle restart (_restart) command
// Stop (_stop) command terminates the loop
do {
// Construct the probe
probe = new NimProbe("example_probe","1.00","My company",args);
logger.log(0," - ---STARTING - ----");
logger.setLogLevel(NimLog.WARN);
// Subscribe to message from the hub, register the "hubpost" callback method
probe.setSubscribeSubject("alarm");
probe.registerHubpostCallback(this,"hubpostCallback");
// Define and send a warning alarm
try {
ConfigurationItem ConfItem = new ConfigurationItem("citype", "ciname","Hostname");
NimAlarm alarm = new NimAlarm(NimAlarm.NIML_WARNING, "Alarm generated from Java","2","JAVA","JAVA",ConfItem,"ciMetricId");
alarm.send();
alarm.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
// Run until a stop signal is received from the manager.
// Restart initiates re-creation of the probe.
// The doForever() method returns true or false
// true - a restart command (_restart) is received
// false - a stop command (_stop) is received
} while (probe.doForever());
logger.log(NimLog.WARN," - ---STOPPING - ----");
}
/**
* The "hubpost" callback that receives a PDS with some userdata
* @param session The callback session
* @param pdsuserdata The PDS user data
*/
public static void hubpostCallback(NimSession session, PDS pdsuserdata) throws NimException {
session.sendReply(NimException.OK,null); // OK return
}
}