Search in sources :

Example 1 with PassiveStatusKeeper

use of org.opennms.netmgt.passive.PassiveStatusKeeper in project opennms by OpenNMS.

the class PassiveStatusd method onInit.

/**
     * <p>onInit</p>
     */
@Override
protected void onInit() {
    EventIpcManagerFactory.init();
    EventIpcManager mgr = EventIpcManagerFactory.getIpcManager();
    PassiveStatusKeeper keeper = getPassiveStatusKeeper();
    keeper.setEventManager(mgr);
    keeper.setDataSource(DataSourceFactory.getInstance());
    keeper.init();
}
Also used : EventIpcManager(org.opennms.netmgt.events.api.EventIpcManager) PassiveStatusKeeper(org.opennms.netmgt.passive.PassiveStatusKeeper)

Example 2 with PassiveStatusKeeper

use of org.opennms.netmgt.passive.PassiveStatusKeeper in project opennms by OpenNMS.

the class PassiveServiceMonitorIT method testPoll.

// inherit from PassiveStatusKeeperTest so we can inherit all the proper initialization
public void testPoll() throws UnknownHostException {
    PassiveStatusKeeper psk = PassiveStatusKeeper.getInstance();
    psk.setStatus("localhost", "127.0.0.1", "my-passive-service", PollStatus.get(PollStatus.SERVICE_UNAVAILABLE, "testing failure"));
    ServiceMonitor sm = new PassiveServiceMonitor();
    MonitoredService ms = createMonitoredService(1, "localhost", null, "127.0.0.1", "my-passive-service");
    PollStatus ps = sm.poll(ms, new HashMap<String, Object>());
    assertEquals(PollStatus.down("fail."), ps);
    psk.setStatus("localhost", "127.0.0.1", "my-passive-service", PollStatus.get(PollStatus.SERVICE_AVAILABLE, "testing failure"));
    ps = sm.poll(ms, new HashMap<String, Object>());
    assertEquals(PollStatus.up(), ps);
}
Also used : ServiceMonitor(org.opennms.netmgt.poller.ServiceMonitor) PollStatus(org.opennms.netmgt.poller.PollStatus) HashMap(java.util.HashMap) MonitoredService(org.opennms.netmgt.poller.MonitoredService) PassiveStatusKeeper(org.opennms.netmgt.passive.PassiveStatusKeeper)

Aggregations

PassiveStatusKeeper (org.opennms.netmgt.passive.PassiveStatusKeeper)2 HashMap (java.util.HashMap)1 EventIpcManager (org.opennms.netmgt.events.api.EventIpcManager)1 MonitoredService (org.opennms.netmgt.poller.MonitoredService)1 PollStatus (org.opennms.netmgt.poller.PollStatus)1 ServiceMonitor (org.opennms.netmgt.poller.ServiceMonitor)1