Module: check_mk
Branch: master
Commit: bdf710a7c789ddc2fd74701c98e609aae8ec67ad
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bdf710a7c789dd…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Apr 14 10:08:12 2014 +0200
New options --oid and --extraoid for cmk --snmpwalk
It is now possible to specify alternative or additional OIDs to fetch
from a host when using <tt>cmk --snmpwalk</tt>. Please always specify
numeric OIDs. Example:
C+:
OM:cmk --extraoid .1.3.6.1.4.1.8072 --snmpwalk switch4712
C-:
---
.werks/884 | 14 ++++++++++++++
ChangeLog | 1 +
modules/check_mk.py | 30 +++++++++++++++++++++++++-----
modules/check_mk_base.py | 2 ++
4 files changed, 42 insertions(+), 5 deletions(-)
diff --git a/.werks/884 b/.werks/884
new file mode 100644
index 0000000..903692a
--- /dev/null
+++ b/.werks/884
@@ -0,0 +1,14 @@
+Title: New options --oid and --extraoid for cmk --snmpwalk
+Level: 2
+Component: core
+Version: 1.2.5i3
+Date: 1397462765
+Class: feature
+
+It is now possible to specify alternative or additional OIDs to fetch
+from a host when using <tt>cmk --snmpwalk</tt>. Please always specify
+numeric OIDs. Example:
+
+C+:
+OM:cmk --extraoid .1.3.6.1.4.1.8072 --snmpwalk switch4712
+C-:
diff --git a/ChangeLog b/ChangeLog
index 4835d69..7510b61 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
1.2.5i3:
Core & Setup:
+ * 0884 New options --oid and --extraoid for cmk --snmpwalk...
* 0785 FIX: Availability: fixed memory leak in table statehist...
Checks & Agents:
diff --git a/modules/check_mk.py b/modules/check_mk.py
index fffad57..0439188 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -4367,6 +4367,9 @@ def do_snmptranslate(walk):
sys.stdout.write(format_string % (translation, line))
def do_snmpwalk(hostnames):
+ if opt_oids and opt_extra_oids:
+ raise MKGeneralException("You cannot specify --oid and --extraoid at the
same time.")
+
if len(hostnames) == 0:
sys.stderr.write("Please specify host names to walk on.\n")
return
@@ -4386,10 +4389,14 @@ def do_snmpwalk_on(hostname, filename):
ip = lookup_ipaddress(hostname)
out = file(filename, "w")
- for oid in [
+ oids_to_walk = opt_oids
+ if not opt_oids:
+ oids_to_walk = [
".1.3.6.1.2.1", # SNMPv2-SMI::mib-2
".1.3.6.1.4.1" # SNMPv2-SMI::enterprises
- ]:
+ ] + opt_extra_oids
+
+ for oid in oids_to_walk:
if opt_verbose:
sys.stdout.write("Walk on \"%s\"..." % oid)
sys.stdout.flush()
@@ -4673,7 +4680,7 @@ def usage():
cmk --restore BACKUPFILE.tar.gz restore configuration and data
cmk --flush [HOST1 HOST2...] flush all data of some or all hosts
cmk --donate Email data of configured hosts to MK
- cmk --snmpwalk HOST1 HOST2 ... Do snmpwalk on host
+ cmk --snmpwalk HOST1 HOST2 ... Do snmpwalk on one or more hosts
cmk --snmptranslate HOST Do snmptranslate on walk
cmk --snmpget OID HOST1 HOST2 ... Fetch single OIDs and output them
cmk --scan-parents [HOST1 HOST2...] autoscan parents, create conf.d/parents.mk
@@ -4705,6 +4712,10 @@ OPTIONS:
--keepalive used by Check_MK Mirco Core: run check and --notify in continous
mode. Read data from stdin and von from cmd line and environment
--cmc-file=X relative filename for CMC config file (used by -B/-U)
+ --extraoid A Do --snmpwalk also on this OID, in addition to mib-2 and enterprises.
+ You can specify this option multiple times.
+ --oid A Do --snmpwalk on this OID instead of mib-2 and enterprises.
+ You can specify this option multiple times.
NOTES:
-I can be restricted to certain check types. Write '--checks df -I' if you
@@ -4773,7 +4784,11 @@ NOTES:
--snmpwalk does a complete snmpwalk for the specified hosts both
on the standard MIB and the enterprises MIB and stores the
- result in the directory %s.
+ result in the directory %s. Use the option --oid one or several
+ times in order to specify alternative OIDs to walk. You need to
+ specify numeric OIDs. If you want to keep the two standard OIDS
+ .1.3.6.1.2.1 and .1.3.6.1.4.1 then use --extraoid for just adding
+ additional OIDs to walk.
--snmptranslate does not contact the host again, but reuses the hosts
walk from the directory %s.%s
@@ -5807,7 +5822,8 @@ if __name__ == "__main__":
short_options = 'SHVLCURODMmd:Ic:nhvpXPNBil'
long_options = [ "help", "version", "verbose",
"compile", "debug",
"list-checks", "list-hosts",
"list-tag", "no-tcp", "cache",
- "flush", "package", "localize",
"donate", "snmpwalk", "snmptranslate",
+ "flush", "package", "localize",
"donate", "snmpwalk", "oid=", "extraoid=",
+ "snmptranslate",
"usewalk", "scan-parents", "procs=",
"automation=", "notify",
"snmpget=", "profile", "keepalive",
"keepalive-fd=", "create-rrd",
"no-cache", "update", "restart",
"reload", "dump", "fake-dns=",
@@ -5860,6 +5876,10 @@ if __name__ == "__main__":
opt_keepalive_fd = int(a)
elif o == '--usewalk':
opt_use_snmp_walk = True
+ elif o == '--oid':
+ opt_oids.append(a)
+ elif o == '--extraoid':
+ opt_extra_oids.append(a)
elif o == '--procs':
max_num_processes = int(a)
elif o == '--nowiki':
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index cc3dffc..3af4219 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -106,6 +106,8 @@ fake_dns = False
opt_keepalive = False
opt_cmc_relfilename = "config"
opt_keepalive_fd = None
+opt_oids = []
+opt_extra_oids = []
# register SIGINT handler for consistenct CTRL+C handling
def interrupt_handler(signum, frame):