Search in sources :

Example 1 with Service

use of org.opennms.netmgt.config.collectd.Service in project opennms by OpenNMS.

the class CollectdIntegrationTest method createGetPackagesExpectation.

private void createGetPackagesExpectation(OnmsMonitoredService svc) {
    String rule = "ipaddr = '" + str(svc.getIpAddress()) + "'";
    // EasyMock.expect(m_filterDao.getActiveIPAddressList(rule)).andReturn(Collections.singletonList(svc.getIpAddress()));
    final Package pkg = new Package();
    pkg.setName("testPackage");
    Filter filter = new Filter();
    filter.setContent(rule);
    pkg.setFilter(filter);
    final Service collector = new Service();
    collector.setName("SNMP");
    collector.setStatus("on");
    collector.setInterval(3000l);
    Parameter parm = new Parameter();
    parm.setKey(TEST_KEY_PARM_NAME);
    parm.setValue(m_key);
    collector.setParameters(Collections.singletonList(parm));
    pkg.addService(collector);
    EasyMock.expect(m_collectdConfiguration.getPackages()).andReturn(Collections.singletonList(pkg));
    EasyMock.expect(m_collectdConfigFactory.interfaceInPackage(anyObject(OnmsIpInterface.class), eq(pkg))).andReturn(true);
}
Also used : OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) Filter(org.opennms.netmgt.config.collectd.Filter) Service(org.opennms.netmgt.config.collectd.Service) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService) Parameter(org.opennms.netmgt.config.collectd.Parameter) Package(org.opennms.netmgt.config.collectd.Package)

Example 2 with Service

use of org.opennms.netmgt.config.collectd.Service in project opennms by OpenNMS.

the class DuplicatePrimaryAddressIT method createGetPackagesExpectation.

/**
 * Creates the get packages expectation.
 */
private void createGetPackagesExpectation() {
    final Package pkg = new Package();
    pkg.setName("testPackage");
    Filter filter = new Filter();
    filter.setContent("ipaddr != '0.0.0.0'");
    pkg.setFilter(filter);
    final Service collector = new Service();
    collector.setName("SNMP");
    collector.setStatus("on");
    collector.setInterval(1000l);
    collector.addParameter("thresholding-enabled", "false");
    pkg.addService(collector);
    EasyMock.expect(m_collectdConfiguration.getPackages()).andReturn(Collections.singletonList(pkg)).anyTimes();
    EasyMock.expect(m_collectdConfigFactory.interfaceInPackage(anyObject(OnmsIpInterface.class), eq(pkg))).andReturn(true).anyTimes();
}
Also used : Filter(org.opennms.netmgt.config.collectd.Filter) Service(org.opennms.netmgt.config.collectd.Service) Package(org.opennms.netmgt.config.collectd.Package)

Example 3 with Service

use of org.opennms.netmgt.config.collectd.Service in project opennms by OpenNMS.

the class PersistRegexSelectorStrategyTest method setUp.

@Before
public void setUp() throws Exception {
    ipInterfaceDao = EasyMock.createMock(IpInterfaceDao.class);
    String localhost = InetAddress.getLocalHost().getHostAddress();
    NetworkBuilder builder = new NetworkBuilder();
    builder.addNode("myNode");
    builder.addInterface(localhost).setIsManaged("M").setIsSnmpPrimary("P");
    OnmsNode node = builder.getCurrentNode();
    node.setId(1);
    OnmsIpInterface ipInterface = node.getIpInterfaces().iterator().next();
    EasyMock.expect(ipInterfaceDao.load(1)).andReturn(ipInterface).anyTimes();
    EasyMock.replay(ipInterfaceDao);
    Package pkg = new Package();
    pkg.setName("junitTestPackage");
    Filter filter = new Filter();
    filter.setContent("IPADDR != '0.0.0.0'");
    pkg.setFilter(filter);
    Service service = new Service();
    service.setName("SNMP");
    pkg.addService(service);
    Map<String, Object> map = new TreeMap<String, Object>();
    List<org.opennms.netmgt.config.collectd.Parameter> params = pkg.getService("SNMP").getParameters();
    for (org.opennms.netmgt.config.collectd.Parameter p : params) {
        map.put(p.getKey(), p.getValue());
    }
    map.put("collection", "default");
    serviceParams = new ServiceParameters(map);
    LocationAwareSnmpClient locationAwareSnmpClient = new LocationAwareSnmpClientRpcImpl(new MockRpcClientFactory());
    PlatformTransactionManager ptm = new MockPlatformTransactionManager();
    SnmpCollectionAgent agent = DefaultSnmpCollectionAgent.create(1, ipInterfaceDao, ptm);
    OnmsSnmpCollection snmpCollection = new OnmsSnmpCollection(agent, serviceParams, new MockDataCollectionConfigDao(), locationAwareSnmpClient);
    org.opennms.netmgt.config.datacollection.ResourceType rt = new org.opennms.netmgt.config.datacollection.ResourceType();
    rt.setName("myResourceType");
    StorageStrategy storageStrategy = new StorageStrategy();
    storageStrategy.setClazz("org.opennms.netmgt.collection.support.IndexStorageStrategy");
    rt.setStorageStrategy(storageStrategy);
    PersistenceSelectorStrategy persistenceSelectorStrategy = new PersistenceSelectorStrategy();
    persistenceSelectorStrategy.setClazz("org.opennms.netmgt.collectd.PersistRegexSelectorStrategy");
    Parameter param = new Parameter();
    param.setKey(PersistRegexSelectorStrategy.MATCH_EXPRESSION);
    param.setValue("#name matches '^agalue.*$'");
    persistenceSelectorStrategy.addParameter(param);
    rt.setPersistenceSelectorStrategy(persistenceSelectorStrategy);
    GenericIndexResourceType resourceType = new GenericIndexResourceType(agent, snmpCollection, rt);
    resourceA = new GenericIndexResource(resourceType, rt.getName(), new SnmpInstId("1.2.3.4.5.6.7.8.9.1.1"));
    AttributeGroupType groupType = new AttributeGroupType("mib2-interfaces", AttributeGroupType.IF_TYPE_ALL);
    MibObject mibObject = new MibObject();
    mibObject.setOid(".1.2.3.4.5.6.7.8.9.2.1");
    mibObject.setInstance("1");
    mibObject.setAlias("name");
    mibObject.setType("string");
    StringAttributeType attributeType = new StringAttributeType(resourceType, snmpCollection.getName(), mibObject, groupType);
    SnmpValue snmpValue = new Snmp4JValueFactory().getOctetString("agalue rules!".getBytes());
    resourceA.setAttributeValue(attributeType, snmpValue);
    resourceB = new GenericIndexResource(resourceType, rt.getName(), new SnmpInstId("1.2.3.4.5.6.7.8.9.1.2"));
}
Also used : StorageStrategy(org.opennms.netmgt.config.datacollection.StorageStrategy) Snmp4JValueFactory(org.opennms.netmgt.snmp.snmp4j.Snmp4JValueFactory) NetworkBuilder(org.opennms.netmgt.model.NetworkBuilder) LocationAwareSnmpClientRpcImpl(org.opennms.netmgt.snmp.proxy.common.LocationAwareSnmpClientRpcImpl) SnmpInstId(org.opennms.netmgt.snmp.SnmpInstId) MockPlatformTransactionManager(org.opennms.core.test.MockPlatformTransactionManager) MockDataCollectionConfigDao(org.opennms.netmgt.dao.mock.MockDataCollectionConfigDao) OnmsNode(org.opennms.netmgt.model.OnmsNode) Service(org.opennms.netmgt.config.collectd.Service) TreeMap(java.util.TreeMap) MockPlatformTransactionManager(org.opennms.core.test.MockPlatformTransactionManager) PlatformTransactionManager(org.springframework.transaction.PlatformTransactionManager) IpInterfaceDao(org.opennms.netmgt.dao.api.IpInterfaceDao) MockRpcClientFactory(org.opennms.core.rpc.mock.MockRpcClientFactory) LocationAwareSnmpClient(org.opennms.netmgt.snmp.proxy.LocationAwareSnmpClient) SnmpValue(org.opennms.netmgt.snmp.SnmpValue) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) Filter(org.opennms.netmgt.config.collectd.Filter) AttributeGroupType(org.opennms.netmgt.collection.api.AttributeGroupType) Parameter(org.opennms.netmgt.config.datacollection.Parameter) MibObject(org.opennms.netmgt.config.datacollection.MibObject) Package(org.opennms.netmgt.config.collectd.Package) ServiceParameters(org.opennms.netmgt.collection.api.ServiceParameters) MibObject(org.opennms.netmgt.config.datacollection.MibObject) PersistenceSelectorStrategy(org.opennms.netmgt.config.datacollection.PersistenceSelectorStrategy) Before(org.junit.Before)

Example 4 with Service

use of org.opennms.netmgt.config.collectd.Service in project opennms by OpenNMS.

the class CollectdTest method getCollectionPackageThatMatchesSNMP.

private static Package getCollectionPackageThatMatchesSNMP() {
    Package pkg = new Package();
    pkg.setName("pkg");
    Filter filter = new Filter();
    filter.setContent("IPADDR IPLIKE *.*.*.*");
    pkg.setFilter(filter);
    Service svc = new Service();
    pkg.addService(svc);
    svc.setName("SNMP");
    svc.setStatus("on");
    Parameter parm = new Parameter();
    parm.setKey("collection");
    parm.setValue("default");
    svc.addParameter(parm);
    parm = new Parameter();
    parm.setKey("thresholding-enabled");
    parm.setValue("true");
    svc.addParameter(parm);
    svc.setStatus("on");
    return pkg;
}
Also used : Filter(org.opennms.netmgt.config.collectd.Filter) Service(org.opennms.netmgt.config.collectd.Service) Parameter(org.opennms.netmgt.config.collectd.Parameter) Package(org.opennms.netmgt.config.collectd.Package)

Example 5 with Service

use of org.opennms.netmgt.config.collectd.Service in project opennms by OpenNMS.

the class CollectorTestUtils method createCollectionSpec.

static CollectionSpecification createCollectionSpec(String svcName, ServiceCollector svcCollector, String collectionName) {
    Package pkg = new Package();
    Filter filter = new Filter();
    filter.setContent("IPADDR IPLIKE *.*.*.*");
    pkg.setFilter(filter);
    Service service = new Service();
    service.setName(svcName);
    Parameter collectionParm = new Parameter();
    collectionParm.setKey("collection");
    collectionParm.setValue(collectionName);
    service.addParameter(collectionParm);
    pkg.addService(service);
    CollectionSpecification spec = new CollectionSpecification(pkg, svcName, svcCollector, new DefaultCollectdInstrumentation(), createLocationAwareCollectorClient());
    return spec;
}
Also used : Filter(org.opennms.netmgt.config.collectd.Filter) Service(org.opennms.netmgt.config.collectd.Service) Parameter(org.opennms.netmgt.config.collectd.Parameter) Package(org.opennms.netmgt.config.collectd.Package)

Aggregations

Service (org.opennms.netmgt.config.collectd.Service)10 Filter (org.opennms.netmgt.config.collectd.Filter)8 Package (org.opennms.netmgt.config.collectd.Package)8 Parameter (org.opennms.netmgt.config.collectd.Parameter)6 CollectdConfiguration (org.opennms.netmgt.config.collectd.CollectdConfiguration)3 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)3 ArrayList (java.util.ArrayList)2 TreeMap (java.util.TreeMap)2 CollectionSpecification (org.opennms.netmgt.collection.core.CollectionSpecification)2 DefaultCollectdInstrumentation (org.opennms.netmgt.collection.core.DefaultCollectdInstrumentation)2 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)2 OnmsNode (org.opennms.netmgt.model.OnmsNode)2 File (java.io.File)1 IOException (java.io.IOException)1 InetAddress (java.net.InetAddress)1 HashMap (java.util.HashMap)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Before (org.junit.Before)1 CriteriaBuilder (org.opennms.core.criteria.CriteriaBuilder)1 MockRpcClientFactory (org.opennms.core.rpc.mock.MockRpcClientFactory)1