bash 我应该查看什么 snmp OID 以查看我的打印机和交换机是否正在运行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10295480/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What snmp OID should I watch to see if my printers and switches is up an running
提问by hpekristiansen
I am new to snmp, and I am trying to figure out what OID's I should get/trap to see if my printers, switches (and servers) is running? I do not need to know the details - just a simple test. I have successfully med get, getbulk, (and walk) request from a device, both from bash and iReasoning MIB browser.
我是snmp 的新手,我想弄清楚我应该获取/捕获什么 OID 以查看我的打印机、交换机(和服务器)是否正在运行?我不需要知道细节——只是一个简单的测试。我已经从 bash 和iReasoning MIB 浏览器成功地处理了来自设备的 med get、getbulk 和(和 walk)请求。
Edit:
编辑:
Maybe the
也许
.1.3.6.1.2.1.1.3.0
Name/OID: sysUpTime.0; Value (TimeTicks): 194 hours 43 seconds (69844352)
is used for just that!? What happens when something is wrong? -will this be reset immediately? -or will it just stop counting? or is it just the time since last power on?
就是用来做这个的!?当出现问题时会发生什么?- 这会立即重置吗?- 或者它会停止计数?还是只是自上次通电以来的时间?
采纳答案by Mike Pennington
Printers
打印机
You should use the Printer MIBv2to monitior printer error status for jams...
您应该使用打印机 MIBv2来监控卡纸的打印机错误状态...
hrPrinterDetectedErrorStatereports printer errors such as low toner, jams, etc... the RFC contains details on what specific codes meanhrDeviceStatuswill reveal the big picture ability of the printer to handle tasks. For more info, see Printer MIBv2, Section 2.2.13.2
hrPrinterDetectedErrorState报告打印机错误,例如碳粉不足、卡纸等...... RFC 包含有关特定代码含义的详细信息hrDeviceStatus将揭示打印机处理任务的大图能力。有关详细信息,请参阅打印机 MIBv2,第 2.2.13.2 节
sysUpTime.0is an OID that reports the time a system's SNMP stack has been up (reference RFC 1213: MIB-II). If this value is returned and incrementing, it's a 99% safe bet that a printer is up. Most people use sysUpTimeto detect whether the device has rebooted for some reason; if that happens, you'll see a sudden decrease in sysUpTime.0, unless your last value was around 248 days (where a 32-bit counter would roll).
sysUpTime.0是一个 OID,用于报告系统的 SNMP 堆栈已启动的时间(参考RFC 1213:MIB-II)。如果此值返回并递增,则打印机已启动是 99% 的安全赌注。大多数人sysUpTime用来检测设备是否因某种原因重新启动;如果发生这种情况,您会看到 突然减少sysUpTime.0,除非您的最后一个值大约是 248 天(其中 32 位计数器会滚动)。
Ethernet Switches
以太网交换机
Checking the basic health of ethernet switches is usually done with checks to sysDescr.0or sysUpTime.0; the problem with this heuristic comes if you care about the up/down status of particular links... at that point, you need to check values from ifOperStatus, which is indexed by ifIndexand uses interface names from ifName. See the following examples...
检查以太网交换机的基本健康状况通常通过检查sysDescr.0或完成sysUpTime.0;如果您关心特定链接的启动/关闭状态,则此启发式方法的问题就出现了……此时,您需要检查来自 的值ifOperStatus,该值由索引ifIndex并使用来自 的接口名称ifName。请参阅以下示例...
[mpenning@Hotcoffee ~]$ ## Walk ifName correlated to ifIndex
[mpenning@Hotcoffee ~]$ snmpwalk -v 2c -c Public 172.25.116.6 .1.3.6.1.2.1.31.1.1.1.1
iso.3.6.1.2.1.31.1.1.1.1.1 = STRING: "Fa0/0"
iso.3.6.1.2.1.31.1.1.1.1.2 = STRING: "Nu0"
[mpenning@Hotcoffee ~]$ ## Walk ifOperStatus (up==1)
[mpenning@Hotcoffee ~]$ snmpwalk -v 2c -c Public 172.25.116.6 .1.3.6.1.2.1.2.2.1.8
iso.3.6.1.2.1.2.2.1.8.1 = INTEGER: 1
iso.3.6.1.2.1.2.2.1.8.2 = INTEGER: 1
[mpenning@Hotcoffee ~]$
Thus we know from the example that both interface "Fa0/0" (index: 1) and "Nu0" (index: 2) have an ifOperStatus of "up"; the index value is the last integer returned in the OID of the results.
因此我们从示例中知道接口“Fa0/0”(索引:1)和“Nu0”(索引:2)的 ifOperStatus 都为“up”;索引值是结果的 OID 中返回的最后一个整数。
Scripting
脚本编写
I assume you will use bashfor your monitoring scripts; if so, check out Net-SNMPfor your SNMP manager
我假设您将bash用于监控脚本;如果是这样,请查看您的 SNMP 管理器的Net-SNMP

