SNMP输出选项-如何仅获取OID响应值? [英] SNMP OUTPUT OPTIONS - How do I get the OID response value only?

查看:290
本文介绍了SNMP输出选项-如何仅获取OID响应值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须使用我一直在使用的BASH脚本,从一些启用SNMP的网络打印机中收集一些OID.

I have to go through and collect a few OIDs from some SNMP enabled network printers with a BASH script I have been working on.

我的请求:

snmpget -v2c -c public 192.168.0.77 
.1.3.6.1.2.1.1.1 
.1.3.6.1.2.1.1.2 

我的实际回复:

 .1.3.6.1.2.1.1.1 = Counter32: 1974 
 .1.3.6.1.2.1.1.2 = Counter32: 633940

所需的响应:

1974
633940314

(仅是oid值)

我使用以下网站的资源查看并测试了几种选择:

I looked and tested several options using the resource from the site below:

http://www.netsnmp.org/docs/man/snmpcmd. html#lbAF

-Oq删除'='以便运行

snmpget -v2c -c public -Oq 10.15.105.133
.1.3.6.1.2.1.1.1 
.1.3.6.1.2.1.1.2 

返回

.1.3.6.1.2.1.1.1 Counter32: 1974
.1.3.6.1.2.1.1.2 Counter 32: 633940314

所以我知道我的措词正确.

so I know I am phrasing my request properly.

我正在获取值并将其写入MYSQL dB,我在我的故事模式中设置了数据类型,请求是一致的,所以我知道OID的定义,因此我不需要获得的所有信息返回,只是OID本身的值,因此我可以将其写入dB,而无需处理响应.我可能可以操纵响应,将信息拉到:"的右边并写入OID的值.

I am taking the values and writing them to a MYSQL dB, I set the data types in my tale schema, the request is consistent so I know the definition of the OID, so I do not need all the information I am getting back, just the value of the OID itself, so I can write it to my dB without manipulating the the response. I probably can manipulate the response pulling the information to the right of ":" and writing the value of the OID.

我是SNMP的新手( http://www.net-snmp.org/ ),但我看不到为什么这不是一个更常见的问题,因为我一直在到处寻找答案,而这篇文章是我最后的求助...

I am relatively new to SNMP (http://www.net-snmp.org/), but I can not see why this is not a more commonly asked question because I have been searching everywhere for an answer and this post is my last recourse...

推荐答案

您可以使用-O参数调整输出:

You can tune the output with the -O argument:

snmpgetnext -Oqv -v 2c -c public 192.168.0.77 .1
2

请参见--help:

q:  quick print for easier parsing
v:  print values only (not OID = value)

这篇关于SNMP输出选项-如何仅获取OID响应值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆