use of org.opennms.netmgt.icmp.NullPinger in project opennms by OpenNMS.
the class Main method initializePinger.
public void initializePinger() {
final AbstractPingerFactory pingerFactory = new BestMatchPingerFactory();
if (m_disableIcmp) {
LOG.info("Disabling ICMP by user request.");
System.setProperty("org.opennms.netmgt.icmp.pingerClass", "org.opennms.netmgt.icmp.NullPinger");
pingerFactory.setInstance(0, true, new NullPinger());
return;
}
final String pingerClass = System.getProperty("org.opennms.netmgt.icmp.pingerClass");
if (pingerClass == null) {
LOG.info("System property org.opennms.netmgt.icmp.pingerClass is not set; using JnaPinger by default");
System.setProperty("org.opennms.netmgt.icmp.pingerClass", "org.opennms.netmgt.icmp.jna.JnaPinger");
}
LOG.info("Pinger class: {}", System.getProperty("org.opennms.netmgt.icmp.pingerClass"));
try {
final Pinger pinger = pingerFactory.getInstance();
pinger.ping(InetAddress.getLoopbackAddress());
} catch (final Throwable t) {
LOG.warn("Unable to get pinger instance. Setting pingerClass to NullPinger. For details, see: http://www.opennms.org/wiki/ICMP_could_not_be_initialized");
System.setProperty("org.opennms.netmgt.icmp.pingerClass", "org.opennms.netmgt.icmp.NullPinger");
pingerFactory.setInstance(0, true, new NullPinger());
if (m_gui) {
final String message = "ICMP (ping) could not be initialized: " + t.getMessage() + "\nDisabling ICMP and using the NullPinger instead." + "\nFor details, see: http://www.opennms.org/wiki/ICMP_could_not_be_initialized";
JOptionPane.showMessageDialog(null, message, "ICMP Not Available", JOptionPane.WARNING_MESSAGE);
}
}
}
Aggregations