首页 \ 问答 \ SNMP:添加陷阱目标(SNMP : add a trap destination)

SNMP:添加陷阱目标(SNMP : add a trap destination)

我是SNMP的新手,我使用snmp4j库在java中创建了一个SNMP代理。 在我的代码中,我已将localhost添加为陷阱目标。 因此,我收到162端口的通知:

    targetMIB.addTargetAddress(new OctetString("notification"),
        TransportDomains.transportDomainUdpIpv4,
        new OctetString(new UdpAddress("127.0.0.1/162").getValue()),
        200, 1,
        new OctetString("notify"),
        new OctetString("v2c"),
        StorageType.permanent);

我现在要做的是使用snmp浏览器(例如iReasoning MIB Browser)从另一个ip地址接收陷阱。 但是我无法在目标mib中添加条目。

我错过了什么吗?

谢谢。

编辑:

我想使用mib浏览器向目标地址表添加一个条目。 使用iReasoning Mib浏览器我没有创建行按钮,而且使用ManageEngine的工具我有一个添加按钮,但似乎没有做任何事情。

因此,我只是在这里尝试使用代码更改我创建的行:

这是mib浏览器的屏幕截图: Mib浏览器snmpTargetAddrTable

当我尝试更改IP地址时,我收到一个错误: 设置窗口

错误信息

我试图使用OctetString设置值:127.0.0.1:162 127.0.0.1/162 0700000100A2 0x0700000100A2

但没有任何作用


I am fairly new to SNMP and i have created a SNMP Agent in java using the snmp4j library. In my code, i have added localhost as a trap destination. I therefore receive the notifications on the port 162 :

    targetMIB.addTargetAddress(new OctetString("notification"),
        TransportDomains.transportDomainUdpIpv4,
        new OctetString(new UdpAddress("127.0.0.1/162").getValue()),
        200, 1,
        new OctetString("notify"),
        new OctetString("v2c"),
        StorageType.permanent);

What i am trying to do now is to receive traps from another ip address using a snmp browser such as iReasoning MIB Browser. But there i cannot manage to add an entry to the target mib.

Am i missing something ?

Thank you.

EDIT :

I want to add an entry using the mib browser to the target Address table. With iReasoning Mib browser i don't have the create row button and with ManageEngine's tool i have an add button but it does not seem to do anything.

I am therefore only trying here to change the row i have created with the code :

Here is a screen shot of the mib browser : Mib Browser snmpTargetAddrTable

When i try to change the ip address i get an error : Set window

Error message

I have tried to set the value using an OctetString with : 127.0.0.1:162 127.0.0.1/162 0700000100A2 0x0700000100A2

but nothing works


原文:https://stackoverflow.com/questions/21609014
更新时间:2022-06-07 19:06

最满意答案

您可以使用func dropFirst(_ n: Int)来跳过初始行:

let lines = contents.components(separatedBy: "\n")
for line in lines.dropFirst(4) {
    // ...
}

dropFirst(4)返回一个“数组切片”,除了lines数组中的前4个元素外,这意味着元素存储不会被复制。


You can use func dropFirst(_ n: Int) to skip initial lines:

let lines = contents.components(separatedBy: "\n")
for line in lines.dropFirst(4) {
    // ...
}

dropFirst(4) returns an “array slice” with all but the first 4 elements in the lines array, which means that the element storage is not duplicated.

相关问答

更多

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。