我是 SNMP 的新手,但我将使用 SNMP 和 PYSNMP 制作一些简单的监控应用程序
我想用我的自定义 MIB 监视我的代理(因为当我运行一些 MIB 时,它不能与 PYSNMP 一起使用),我已经阅读了 PYSNMP 文档,但它似乎无法帮助我,
你能告诉我,如何轻松地制作自定义 MIB PYSNMP 吗?所以我可以在经理和代理方面使用它:)
谢谢
谢谢你的回答我已经阅读了那些tuts,但我的mib仍然无法击中目标,
我想在我的分区上读取我的总磁盘,所以这是我的 MIB 代码:
DISKTOTAL-MIB DEFINITIONS ::= BEGIN
IMPORTS
OBJECT-TYPE, Integer32, NOTIFICATION-TYPE
FROM SNMPv2-SMI
;
internet OBJECT IDENTIFIER ::= { iso(1) org(3) dod(6) 1 }
enterprises OBJECT IDENTIFIER ::= { internet private(4) 1 }
ucdavis OBJECT IDENTIFIER ::= { enterprises 2021 }
diskcheck OBJECT IDENTIFIER ::= { ucdavis 9 }
snmpdiskcheck OBJECT IDENTIFIER ::= { diskcheck 1 }
totaldisk OBJECT IDENTIFIER ::= { snmpdiskcheck 6 }
diskTotal OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-only
STATUS current
DESCRIPTION "Total size of disk on partition."
::= { totaldisk 1 }
END
生成此代码后,这是我在 py 中的 MIB
# PySNMP SMI module. Autogenerated from smidump -f python DISKTOTAL-MIB
# by libsmi2pysnmp-0.1.3 at Wed Jul 3 01:30:48 2013,
# Python version sys.version_info(major=2, minor=7, micro=3, releaselevel='final', serial=0)
# Imports
( Integer, ObjectIdentifier, OctetString, ) = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString")
( NamedValues, ) = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
( ConstraintsIntersection, ConstraintsUnion, SingleValueConstraint, ValueRangeConstraint, ValueSizeConstraint, ) = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ConstraintsUnion", "SingleValueConstraint", "ValueRangeConstraint", "ValueSizeConstraint")
( Bits, Integer32, Integer32, MibIdentifier, NotificationType, MibScalar, MibTable, MibTableRow, MibTableColumn, TimeTicks, ) = mibBuilder.importSymbols("SNMPv2-SMI", "Bits", "Integer32", "Integer32", "MibIdentifier", "NotificationType", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "TimeTicks")
# Objects
internet = MibIdentifier((1, 3, 6, 1))
enterprises = MibIdentifier((1, 3, 6, 1, 4, 1))
ucdavis = MibIdentifier((1, 3, 6, 1, 4, 1, 2021))
diskcheck = MibIdentifier((1, 3, 6, 1, 4, 1, 2021, 9))
snmpdiskcheck = MibIdentifier((1, 3, 6, 1, 4, 1, 2021, 9, 1))
totaldisk = MibIdentifier((1, 3, 6, 1, 4, 1, 2021, 9, 1, 6))
diskTotal = MibScalar((1, 3, 6, 1, 4, 1, 2021, 9, 1, 6, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: diskTotal.setDescription("Total size of disk on partition.")
# Augmentions
# Exports
# Objects
mibBuilder.exportSymbols("DISKTOTAL-MIB", internet=internet, enterprises=enterprises, ucdavis=ucdavis, diskcheck=diskcheck, snmpdiskcheck=snmpdiskcheck, totaldisk=totaldisk, diskTotal=diskTotal)
但是,当我尝试调用 snmpget 时:
snmpget -v 2c -c public localhost .1.3.6.1.4.1.2021.9.1.6.1
我发现 :
iso.3.6.1.4.1.2021.9.1.6.1 = No Such Instance currently exists at this OID
谢谢你