首页 \ 问答 \ 发送包含自定义数据的SNMP陷阱(Sending SNMP Traps containing custom data)

发送包含自定义数据的SNMP陷阱(Sending SNMP Traps containing custom data)

客户已请求我们将SNMP陷阱发送到其Nagios服务器而不是电子邮件警报。 我昨天才知道关于SNMP的唯一事情就是它听起来像一个缩写词,所以请原谅(并纠正我)我可能有的任何误解。

需要在陷阱中发送的唯一信息涉及我们警告客户的事件的数据,这只是从我们的数据库中提取的几个值。 毋庸置疑,这些不属于任何类型的MIB,也没有任何OID,这就是我无法找到答案的地方。

我无法弄清楚我是如何在没有使用MIB OID的情况下将我们的特定数据添加到陷阱中的,我没有。

我正在使用PySNMP来生成请求,并且现在只有不完整的代码,因为我不确定如何将数据合并到数据包中。

from pysnmp.hlapi import *

def sendSNMP(destination, community_string, data):
    community = CommunityData(community_string, mpModel = 0)
    target = UdpTransportTarget((destination, 162))
    notification_type = None
    req = sendNotification(SnmpEngine(), community, target, ContextData(), 'trap', notification_type)
    errorIndication, errorStatus, errorIndex, varBinds = next(req)

任何帮助表示赞赏! 谢谢。


A client has requested that instead of email alerts that we send SNMP Traps to their Nagios server instead. The only thing I knew about SNMP before yesterday was that it sounded like an acronym, so please excuse (and correct me on) any misconceptions about it that I may have.

The only information that needs to be sent in the trap pertains to data about the event we are alerting our client about, which is just a couple of values pulled from our database. Needless to say these aren't in any sort of MIB, nor do they have any OIDs, and this is where I'm having trouble finding answers.

I can't figure out how I am meant to add our specific data to the trap without using MIB OIDs, which I don't have.

I'm using PySNMP to generate the request and have only incomplete code right now as I'm not sure how to go about incorporating our data into the packet.

from pysnmp.hlapi import *

def sendSNMP(destination, community_string, data):
    community = CommunityData(community_string, mpModel = 0)
    target = UdpTransportTarget((destination, 162))
    notification_type = None
    req = sendNotification(SnmpEngine(), community, target, ContextData(), 'trap', notification_type)
    errorIndication, errorStatus, errorIndex, varBinds = next(req)

Any assistance is appreciated! Thanks.


原文:https://stackoverflow.com/questions/34654949
更新时间:2022-09-20 17:09

最满意答案

要在没有类的情况下选择元素,可以使用:

Elements tds = row.select("td:not([class])");

这使用了伪选择器:not()由JSoup实现的:not()


To select elements specifically without a class you can use this:

Elements tds = row.select("td:not([class])");

This uses the pseudo selector :not() implemented by JSoup.

相关问答

更多
  • 如果您需要对单元格值的弱引用: object field = d.Rows[0][3] 要么 object field = d.Rows[0].ItemArray[3] 应该做 如果您需要强类型引用(在您的情况下为字符串),则可以使用DataRowExtensions.Field扩展方法: string field = d.Rows[0].Field(3); (在这种情况下,请确保System.Data在名称空间中列出) 索引为0,所以我们首先访问第一行(0),然后访问该行(3)中的第 ...
  • 您可以使用[tableView cellForRowAtIndexPath:indexPath]访问单元格,然后从单元格中,您可以使用viewWithTag访问它的子视图(内容) - - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // access the cell for selected cell UITableViewCell *cell ...
  • 我想你可能正在寻找Range("C2") 。 对于格式化信息,可以通过Excel对象模型的各种属性来获取。 有关更多信息,请参见http://msdn.microsoft.com/en-us/library/ff197454.aspx 。 Range类型(与上面引用的Range索引属性相对)也公开了Name属性,您可以在代码中设置它: worksheet.get_Range("C2").Name = "fdafdfs" worksheet.get_Range("fdafdfs").Select(); I ...
  • 要在没有类的情况下选择元素,可以使用: Elements tds = row.select("td:not([class])"); 这使用了伪选择器:not()由JSoup实现的:not() 。 To select elements specifically without a class you can use this: Elements tds = row.select("td:not([class])"); This uses the pseudo selector :not() impleme ...
  • 你会想要这个,因为你想要一个,然后两个。 $(this).parent().prev().prev().html('test'); 或者像这样: $(this).parent().prevAll(':last').html('test'); 或这个: $(this).parent().siblings(':first-child').html('test'); ...或者你可以在没有jQuery的情况下轻松完成: this.parentNode.parentNode.cells[0].innerHTM ...
  • 在你打印输出你有AttributeError: 'tuple' object ... ,你的单元格打印像(,) ,所以你的实际变量持有一个元组,但你正在对待它,就像它是细胞。 您需要解压缩元组以获取单元格变量。 如果你这样做: for cell, in rows: ... 这是拆包的一种方式,或者: for tmp in rows: cell = tmp[0] 是另一个。 顺便说一句, sheets = wb2.sheetnames #list of ...
  • @IBOutlet var companyName : UILabel是一个插座,如果你调用var vc = SearchTableViewController(style: UITableViewStyle.Plain)插座companyName标签没有初始化,因此它是nil,因此访问companyName标签会导致崩溃。 但在第一种情况下,您正在从storyboard初始化viewController,其中SearchTableViewController场景包含带有outlet companyName ...
  • 尝试使用Range.Formula: Microsoft.Office.Interop.Excel.Range cell //it points to address A1 object obj=cell.Formula; Try to use Range.Formula: Microsoft.Office.Interop.Excel.Range cell //it points to address A1 object obj=cell.Formula;
  • 喜欢 步骤1 button.tag = indexPath.row button.setTitle("ButtonTitle") button.addTarget(self, action: "buttonAction:", forControlEvents: UIControlEvents.TouchUpInside) 第2步 func buttonAction(sender: UIButton) { if let sendertitle = sender.titleLabel?.tex ...
  • 对于在故事板中创建的静态单元格,您可以简单地将IBOutlet设置为您想要编辑的元素,方法是将IBOutlet从故事板拖到相应的视图控制器,最后得到如下所示的内容: class MyViewController: UIViewController { @IBOutlet weak var cell1: UITableViewCell! @IBOutlet weak var cell2: UITableViewCell! } 然后,您可以使用cell1.textLabel等访问Basic视图中的内置 ...

相关文章

更多

最新问答

更多
  • 获取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的基本操作命令。。。