當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。