Module: check_mk
Branch: master
Commit: e88e934a311a70bca9918b2dd6f7f6bd24a59e96
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e88e934a311a70…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Mar 4 14:39:37 2011 +0100
new option --snmpget
---
modules/check_mk.py | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 6039187..0a7a2cb 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -2757,6 +2757,18 @@ def do_snmpwalk_on(hostname, filename):
if opt_verbose:
sys.stdout.write("Successfully Wrote %s%s%s.\n" % (tty_bold, filename,
tty_normal))
+def do_snmpget(oid, hostnames):
+ if len(hostnames) == 0:
+ for host in all_active_hosts():
+ if is_snmp_host(host):
+ hostnames.append(host)
+
+ for host in hostnames:
+ ip = lookup_ipaddress(host)
+ value = get_single_oid(host, ip, oid)
+ sys.stdout.write("%s (%s): %r\n" % (host, ip, value))
+
+
def show_paths():
inst = 1
conf = 2
@@ -2976,6 +2988,7 @@ def usage():
check_mk --flush [HOST1 HOST2...] flush all data of some or all hosts
check_mk --donate Email data of configured hosts to MK
check_mk --snmpwalk HOST1 HOST2 ... Do snmpwalk on host
+ check_mk --snmpget OID HOST1 HOST2 ... Fetch single OIDs and output them
check_mk --scan-parents [HOST1 HOST2...] autoscan parents, create conf.d/parents.mk
check_mk -P, --package COMMAND do package operations
check_mk -V, --version print version
@@ -3924,6 +3937,7 @@ if __name__ == "__main__":
"list-checks", "list-hosts",
"list-tag", "no-tcp", "cache",
"flush", "package", "donate",
"snmpwalk", "usewalk",
"scan-parents", "procs=",
"automation=",
+ "snmpget=",
"no-cache", "update", "restart",
"reload", "dump", "fake-dns=",
"man", "nowiki", "config-check",
"backup=", "restore=",
"check-inventory=", "paths",
"cleanup-autochecks", "checks=" ]
@@ -4029,6 +4043,9 @@ if __name__ == "__main__":
elif o == '--snmpwalk':
do_snmpwalk(args)
done = True
+ elif o == '--snmpget':
+ do_snmpget(a, args)
+ done = True
elif o in [ '-M', '--man' ]:
if len(args) > 0:
show_check_manual(args[0])