当前位置: 首页>>代码示例>>Java>>正文


Java ISnmpSession类代码示例

本文整理汇总了Java中com.btisystems.pronx.ems.core.snmp.ISnmpSession的典型用法代码示例。如果您正苦于以下问题:Java ISnmpSession类的具体用法?Java ISnmpSession怎么用?Java ISnmpSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ISnmpSession类属于com.btisystems.pronx.ems.core.snmp包,在下文中一共展示了ISnmpSession类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: populateDescription

import com.btisystems.pronx.ems.core.snmp.ISnmpSession; //导入依赖的package包/类
private DeviceDescription populateDescription(ISnmpSession session, Device device) {
    NetworkDevice networkDevice = new NetworkDevice(CLASS_REGISTRY,
                                                    session.getAddress().getHostAddress());
    try {
        session.walkDevice(networkDevice, Collections.singletonList(CLASS_REGISTRY.getClassToOidMap().get(
                System.class)));

        com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System systemTree =
                (com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System)
                        networkDevice.getRootObject().getEntity(CLASS_REGISTRY.getClassToOidMap().get(
                                com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System.class));
        if (systemTree != null) {
            // TODO SNMP sys-contacts may be verbose; ONOS-GUI doesn't abbreviate fields neatly;
            // so cut it here until supported in prop displayer
            String manufacturer = StringUtils.abbreviate(systemTree.getSysContact(), 20);
            return new DefaultDeviceDescription(device.id().uri(), device.type(),
                                                manufacturer, UNKNOWN, UNKNOWN, UNKNOWN,
                                                device.chassisId(), (SparseAnnotations) device.annotations());
        }
    } catch (IOException ex) {
        throw new IllegalArgumentException("Error reading details for device." + session.getAddress(), ex);
    }
    return null;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:NetSnmpDeviceDescriptor.java

示例2: discoverDeviceDetails

import com.btisystems.pronx.ems.core.snmp.ISnmpSession; //导入依赖的package包/类
@Override
public DeviceDescription discoverDeviceDetails() {
    SnmpController controller = checkNotNull(handler().get(SnmpController.class));
    DeviceId deviceId = handler().data().deviceId();
    SnmpDevice snmpDevice = controller.getDevice(deviceId);
    DeviceService deviceService = checkNotNull(handler().get(DeviceService.class));
    Device device = deviceService.getDevice(deviceId);
    DeviceDescription desc = null;
    String ipAddress = snmpDevice.getSnmpHost();
    int port = snmpDevice.getSnmpPort();

    ISnmpConfiguration config = new V2cSnmpConfiguration();
    config.setPort(port);

    try (ISnmpSession session = controller.getSession(deviceId)) {
        // Each session will be auto-closed.
        String deviceOid = session.identifyDevice();
        desc = populateDescription(session, device);

    } catch (IOException | RuntimeException ex) {
        log.error("Failed to walk device.", ex.getMessage());
        log.debug("Detailed problem was ", ex);
    }
    return desc;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:Bti7000DeviceDescriptor.java

示例3: populateDescription

import com.btisystems.pronx.ems.core.snmp.ISnmpSession; //导入依赖的package包/类
private DeviceDescription populateDescription(ISnmpSession session, Device device) {
    NetworkDevice networkDevice = new NetworkDevice(CLASS_REGISTRY,
                                                    session.getAddress().getHostAddress());
    try {
        session.walkDevice(networkDevice, Collections.singletonList(CLASS_REGISTRY.getClassToOidMap().get(
                System.class)));

        com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System systemTree =
                (com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System)
                        networkDevice.getRootObject().getEntity(CLASS_REGISTRY.getClassToOidMap().get(
                                com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System.class));
        if (systemTree != null) {
            String[] systemComponents = systemTree.getSysDescr().split(";");
            return new DefaultDeviceDescription(device.id().uri(), device.type(),
                                                systemComponents[0], systemComponents[2],
                                                systemComponents[3], UNKNOWN, device.chassisId(),
                                                (SparseAnnotations) device.annotations());
        }
    } catch (IOException ex) {
        throw new IllegalArgumentException("Error reading details for device." + session.getAddress(), ex);
    }
    return null;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:Bti7000DeviceDescriptor.java

示例4: consumeAlarms

import com.btisystems.pronx.ems.core.snmp.ISnmpSession; //导入依赖的package包/类
@Override
public List<Alarm> consumeAlarms() {
    SnmpController controller = checkNotNull(handler().get(SnmpController.class));
    ISnmpSession session;
    List<Alarm> alarms = new ArrayList<>();
    DeviceId deviceId = handler().data().deviceId();
    try {
        session = controller.getSession(deviceId);
        log.debug("Getting alarms for BTI 7000 device at {}", deviceId);
        NetworkDevice networkDevice = new NetworkDevice(CLASS_REGISTRY,
                                                        session.getAddress().getHostAddress());
        session.walkDevice(networkDevice, Collections.singletonList(
                CLASS_REGISTRY.getClassToOidMap().get(ActAlarmTable.class)));

        IActAlarmTable deviceAlarms = (IActAlarmTable) networkDevice.getRootObject()
                .getEntity(CLASS_REGISTRY.getClassToOidMap().get(ActAlarmTable.class));
        if ((deviceAlarms != null) && (deviceAlarms.getActAlarmEntry() != null)
                && (!deviceAlarms.getActAlarmEntry().isEmpty())) {

            deviceAlarms.getActAlarmEntry().values().stream().forEach((alarm) -> {
                DefaultAlarm.Builder alarmBuilder = new DefaultAlarm.Builder(
                        deviceId, alarm.getActAlarmDescription(),
                        mapAlarmSeverity(alarm.getActAlarmSeverity()),
                        getLocalDateAndTime(alarm.getActAlarmDateAndTime(), null, null).getTime())
                        .forSource(AlarmEntityId.alarmEntityId("other:" + alarm.getActAlarmInstanceIdx()));
                alarms.add(alarmBuilder.build());
            });

        }
        log.debug("Conditions retrieved: {}", deviceAlarms);

    } catch (IOException ex) {
        log.error("Error reading alarms for device {}.", deviceId, ex);
        alarms.add(controller.buildWalkFailedAlarm(deviceId));

    }

    return ImmutableList.copyOf(alarms);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:40,代码来源:Bti7000SnmpAlarmConsumer.java

示例5: consumeAlarms

import com.btisystems.pronx.ems.core.snmp.ISnmpSession; //导入依赖的package包/类
@Override
public List<Alarm> consumeAlarms() {
    SnmpController controller = checkNotNull(handler().get(SnmpController.class));
    List<Alarm> alarms = new ArrayList<>();
    ISnmpSession session;
    DeviceId deviceId = handler().data().deviceId();
    try {
        session = controller.getSession(deviceId);

        NetworkDevice networkDevice = new NetworkDevice(CLASS_REGISTRY,
                                                        session.getAddress()
                                                                .getHostAddress());
        session.walkDevice(networkDevice, Collections.singletonList(
                CLASS_REGISTRY.getClassToOidMap().get(IfTable.class)));

        IfTable interfaceTable = (IfTable) networkDevice.getRootObject()
                .getEntity(CLASS_REGISTRY.getClassToOidMap().get(IfTable.class));
        if (interfaceTable != null) {
            interfaceTable.getEntries().values().stream().forEach((ifEntry) -> {
                if (ifEntry.getIfAdminStatus() == 1 && ifEntry.getIfOperStatus() == 2) {
                    alarms.add(new DefaultAlarm.Builder(deviceId, "Link Down.",
                                                        Alarm.SeverityLevel.CRITICAL,
                                                        System.currentTimeMillis())
                                       .forSource(AlarmEntityId
                                                          .alarmEntityId("port:" + ifEntry.
                                                                  getIfDescr())).build());
                }
                log.debug("Interface: " + ifEntry);
            });
        }
    } catch (IOException ex) {
        log.error("Error reading alarms for device {}.", deviceId, ex);
        alarms.add(controller.buildWalkFailedAlarm(deviceId));
    }
    return ImmutableList.copyOf(alarms);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:37,代码来源:NetSnmpAlarmConsumer.java

示例6: discoverDeviceDetails

import com.btisystems.pronx.ems.core.snmp.ISnmpSession; //导入依赖的package包/类
@Override
public DeviceDescription discoverDeviceDetails() {
    SnmpController controller = checkNotNull(handler().get(SnmpController.class));
    DeviceId deviceId = handler().data().deviceId();
    SnmpDevice snmpDevice = controller.getDevice(deviceId);
    DeviceService deviceService = checkNotNull(handler().get(DeviceService.class));
    Device device = deviceService.getDevice(deviceId);
    DeviceDescription desc = null;
    String ipAddress = snmpDevice.getSnmpHost();
    int port = snmpDevice.getSnmpPort();

    ISnmpConfiguration config = new V2cSnmpConfiguration();
    config.setPort(port);

    try (ISnmpSession session = controller.getSession(deviceId)) {
        // Each session will be auto-closed.
        String deviceOid = session.identifyDevice();
        //TODO obtain desctiption
        desc = populateDescription(session, device);

    } catch (IOException | RuntimeException ex) {
        log.error("Failed to walk device.", ex.getMessage());
        log.debug("Detailed problem was ", ex);
    }

    return desc;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:NetSnmpDeviceDescriptor.java

示例7: getSession

import com.btisystems.pronx.ems.core.snmp.ISnmpSession; //导入依赖的package包/类
@Override
public ISnmpSession getSession(DeviceId deviceId) throws IOException {
    if (!sessionMap.containsKey(deviceId)) {
        SnmpDevice device = snmpDeviceMap.get(deviceId);
        String ipAddress = null;
        int port = -1;
        if (device != null) {
            ipAddress = device.getSnmpHost();
            port = device.getSnmpPort();
        } else {
            String[] deviceComponents = deviceId.toString().split(":");
            if (deviceComponents.length > 1) {
                ipAddress = deviceComponents[1];
                port = Integer.parseInt(deviceComponents[2]);

            } else {
                log.error("Cannot obtain correct information from device id", deviceId);
            }
        }
        Preconditions.checkNotNull(ipAddress, "ip address is empty, cannot start session");
        Preconditions.checkArgument(port != -1, "port is incorrect, cannot start session");

        ISnmpConfiguration config = new V2cSnmpConfiguration();
        config.setPort(port);
        sessionMap.put(deviceId, sessionFactory.createSession(config, ipAddress));
    }
    return sessionMap.get(deviceId);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:29,代码来源:DefaultSnmpController.java

示例8: createSession

import com.btisystems.pronx.ems.core.snmp.ISnmpSession; //导入依赖的package包/类
@Override
public ISnmpSession createSession(String ipAddress, String community,
                                  String factoryName,
                                  ISnmpConfigurationFactory.AccessType accessType)
        throws IOException {
    return snmpSession;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:8,代码来源:DefaultSnmpControllerTest.java

示例9: consumeAlarms

import com.btisystems.pronx.ems.core.snmp.ISnmpSession; //导入依赖的package包/类
@Override
public List<Alarm> consumeAlarms() {
    SnmpController controller = checkNotNull(handler().get(SnmpController.class));
    ISnmpSession session;
    List<Alarm> alarms = new ArrayList<>();
    DeviceId deviceId = handler().data().deviceId();
    try {
        session = controller.getSession(deviceId);
        log.debug("Getting alarms for BTI 7000 device at {}", deviceId);
        NetworkDevice networkDevice = new NetworkDevice(CLASS_REGISTRY,
                                                        session.getAddress().getHostAddress());
        session.walkDevice(networkDevice, Collections.singletonList(
                CLASS_REGISTRY.getClassToOidMap().get(ActAlarmTable.class)));

        IActAlarmTable deviceAlarms = (IActAlarmTable) networkDevice.getRootObject()
                .getEntity(CLASS_REGISTRY.getClassToOidMap().get(ActAlarmTable.class));
        if ((deviceAlarms != null) && (deviceAlarms.getActAlarmEntry() != null)
                && (!deviceAlarms.getActAlarmEntry().isEmpty())) {

            deviceAlarms.getActAlarmEntry().values().forEach((alarm) -> {
                DefaultAlarm.Builder alarmBuilder = new DefaultAlarm.Builder(
                        deviceId, alarm.getActAlarmDescription(),
                        mapAlarmSeverity(alarm.getActAlarmSeverity()),
                        getLocalDateAndTime(alarm.getActAlarmDateAndTime(), null, null).getTime())
                        .forSource(AlarmEntityId.alarmEntityId("other:" + alarm.getActAlarmInstanceIdx()));
                alarms.add(alarmBuilder.build());
            });

        }
        log.debug("Conditions retrieved: {}", deviceAlarms);

    } catch (IOException ex) {
        log.error("Error reading alarms for device {}.", deviceId, ex);
        alarms.add(controller.buildWalkFailedAlarm(deviceId));

    }

    return ImmutableList.copyOf(alarms);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:40,代码来源:Bti7000SnmpAlarmConsumer.java

示例10: consumeAlarms

import com.btisystems.pronx.ems.core.snmp.ISnmpSession; //导入依赖的package包/类
@Override
public List<Alarm> consumeAlarms() {
    SnmpController controller = checkNotNull(handler().get(SnmpController.class));
    List<Alarm> alarms = new ArrayList<>();
    ISnmpSession session;
    DeviceId deviceId = handler().data().deviceId();
    try {
        session = controller.getSession(deviceId);

        NetworkDevice networkDevice = new NetworkDevice(CLASS_REGISTRY,
                                                        session.getAddress()
                                                                .getHostAddress());
        session.walkDevice(networkDevice, Collections.singletonList(
                CLASS_REGISTRY.getClassToOidMap().get(IfTable.class)));

        IfTable interfaceTable = (IfTable) networkDevice.getRootObject()
                .getEntity(CLASS_REGISTRY.getClassToOidMap().get(IfTable.class));
        if (interfaceTable != null) {
            interfaceTable.getEntries().values().forEach((ifEntry) -> {
                if (ifEntry.getIfAdminStatus() == 1 && ifEntry.getIfOperStatus() == 2) {
                    alarms.add(new DefaultAlarm.Builder(deviceId, "Link Down.",
                                                        Alarm.SeverityLevel.CRITICAL,
                                                        System.currentTimeMillis())
                                       .forSource(AlarmEntityId
                                                          .alarmEntityId("port:" + ifEntry.
                                                                  getIfDescr())).build());
                }
                log.debug("Interface: " + ifEntry);
            });
        }
    } catch (IOException ex) {
        log.error("Error reading alarms for device {}.", deviceId, ex);
        alarms.add(controller.buildWalkFailedAlarm(deviceId));
    }
    return ImmutableList.copyOf(alarms);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:37,代码来源:NetSnmpAlarmConsumer.java

示例11: getSession

import com.btisystems.pronx.ems.core.snmp.ISnmpSession; //导入依赖的package包/类
@Override
public ISnmpSession getSession(DeviceId deviceId) throws IOException {
    return null;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:5,代码来源:SnmpControllerAdapter.java

示例12: getSession

import com.btisystems.pronx.ems.core.snmp.ISnmpSession; //导入依赖的package包/类
/**
 * Gets an Instance of ISnmpSession for a specific device.
 *
 * @param deviceId device to retrieve the session for.
 * @return ISnmp session.
 * @throws IOException if the session can't be established.
 */
ISnmpSession getSession(DeviceId deviceId) throws IOException;
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:SnmpController.java


注:本文中的com.btisystems.pronx.ems.core.snmp.ISnmpSession类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。