Module: check_mk
Branch: master
Commit: 56b3f060ece92f678837536d6c6ab44deba7da01
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=56b3f060ece92f…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Aug 22 15:46:03 2011 +0200
Removed obsolete code of snmp_info_single
---
.bugs/110 | 13 ++++++++++---
ChangeLog | 1 +
doc/helpers/validate_checks | 2 +-
modules/check_mk.py | 6 +-----
modules/check_mk_base.py | 14 --------------
modules/snmp.py | 42 ------------------------------------------
6 files changed, 13 insertions(+), 65 deletions(-)
diff --git a/.bugs/110 b/.bugs/110
index 5583786..4614bea 100644
--- a/.bugs/110
+++ b/.bugs/110
@@ -1,10 +1,17 @@
Title: Remove obsolete code of snmp_info_single
Component: core
+State: done
+Class: cleanup
+Date: 2011-01-27 09:39:10
Benefit: 1
-State: open
Cost: 1
-Date: 2011-01-27 09:39:10
-Class: cleanup
+Fun: 0
Obsolete code formerly used by snmp_info_single should be removed
from the code.
+
+Seems that no (shipped) check uses this anymore, so we can go
+forward. The documentation does not mention this anyway.
+
+2011-08-22 15:44:37: changed state open -> done
+Removed the code.
diff --git a/ChangeLog b/ChangeLog
index 6f0c22e..b41bbda 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,7 @@
* Show datasource program on cmk -D
* Remove .f12 compile helper files from agents directory
* Output missing sections in case of "WARNING - Only __ output of __..."
+ * Remove obsolete code of snmp_info_single
Checks & Agents:
* FIX: hr_mem: take into account cache and buffers
diff --git a/doc/helpers/validate_checks b/doc/helpers/validate_checks
index 65b97d4..49fcc41 100755
--- a/doc/helpers/validate_checks
+++ b/doc/helpers/validate_checks
@@ -82,7 +82,7 @@ def get_all_checks():
return k
def is_snmp_check(check):
- return check in snmp_info or check in snmp_info_single
+ return check in snmp_info
def all_nonfunction_vars():
return set([ name for name,value in globals().items() if name[0] != '_' and
type(value) != type(lambda:0) ])
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 2d8d9f9..328a2d2 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -317,7 +317,6 @@ check_default_levels = {} # dictionary-configured checks
declare t
factory_settings = {} # factory settings for dictionary-configured
checks
check_config_variables = [] # variables (names) in checks/* needed for check
itself
snmp_info = {} # whichs OIDs to fetch for which check (for
tabular information)
-snmp_info_single = {} # similar, but for single SNMP variables
(MIB-Name BASE-OID List-of-Suffixes)
snmp_scan_functions = {} # SNMP autodetection
@@ -612,7 +611,7 @@ def get_snmp_character_encoding(hostname):
def check_uses_snmp(check_type):
check_name = check_type.split(".")[0]
- return snmp_info.has_key(check_name) or snmp_info_single.has_key(check_name)
+ return snmp_info.has_key(check_name)
def is_snmp_host(hostname):
return in_binary_hostlist(hostname, snmp_hosts)
@@ -2266,7 +2265,6 @@ no_inventory_possible = None
"check_config_variables = []\n" +
"check_default_levels = {}\n" +
"snmp_info = {}\n" +
- "snmp_info_single = {}\n" +
"snmp_scan_functions = {}\n")
for filename in filenames:
@@ -2650,8 +2648,6 @@ def show_check_manual(checkname):
agent = agent.strip()
ags.append({ "vms" : "VMS",
"linux":"Linux", "aix": "AIX",
"solaris":"Solaris", "windows":"Windows",
"snmp":"SNMP"}.get(agent, agent.upper()))
print_splitline(header_color_left, "Supported Agents: ",
header_color_right, ", ".join(ags))
- if checkname in snmp_info_single:
- print_splitline(header_color_left, "Required MIB: ",
header_color_right, snmp_info_single[checkname][0])
empty_line()
print_textbody(header['description'])
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index 23f7dbe..8fd7fa7 100755
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -329,20 +329,6 @@ def get_realhost_info(hostname, ipaddress, checkname,
max_cache_age):
write_cache_file(cache_relpath, repr(table) + "\n")
return table
- # now try SNMP explicity values
- try:
- mib, baseoid, suffixes = snmp_info_single[checkname]
- except:
- baseoid = None
- if baseoid:
- content = read_cache_file(cache_relpath, max_cache_age)
- if content:
- return eval(content)
- table = get_snmp_explicit(hostname, ipaddress, mib, baseoid, suffixes)
- store_cached_checkinfo(hostname, checkname, table)
- write_cache_file(cache_relpath, repr(table) + "\n")
- return table
-
# No SNMP check. Then we must contact the check_mk_agent. Have we already
# to get data from the agent? If yes we must not do that again! Even if
# no cache file is present
diff --git a/modules/snmp.py b/modules/snmp.py
index 4d5450e..211a164 100644
--- a/modules/snmp.py
+++ b/modules/snmp.py
@@ -70,48 +70,6 @@ def convert_from_hex(value):
def oid_to_bin(oid):
return u"".join([ unichr(int(p)) for p in
oid.strip(".").split(".") ])
-# Fetch single values via SNMP. This function is only used by snmp_info_single,
-# which is only rarely used. Most checks use snmp_info, which is handled by
-# get_snmp_table.
-def get_snmp_explicit(hostname, ipaddress, mib, baseoid, suffixes):
- if opt_debug:
- sys.stderr.write('Fetching misc values from OID %s%s%s%s from IP %s\n' %
\
- (tty_bold, tty_green, baseoid, tty_normal, ipaddress))
-
- info = []
- cmd = snmp_walk_command(hostname)
- for suffix in suffixes:
- if mib:
- mibinfo = " -m %s" % mib
- else:
- mibinfo = ""
- portspec = snmp_port_spec(hostname)
- command = cmd + "%s -OQ -OU -Oe %s%s %s.%s 2>/dev/null" % \
- (mibinfo, ipaddress, portspec, baseoid, suffix)
- if opt_debug:
- sys.stderr.write(' Running %s\n' % (command,))
- num_found = 0
- snmp_process = os.popen(command, "r")
- for line in snmp_process.readlines():
- if not '=' in line: # TODO: join onto previous line
- continue
- item, value = line.split("=")
- value_text = strip_snmp_value(value)
- # try to remove text, only keep number
- value_num = value_text.split(" ")[0]
- value_num = value_num.lstrip("+")
- value_num = value_num.rstrip("%")
- item = strip_snmp_value(item.split(":")[-1])
- if item.endswith(".0"):
- item = item[:-2]
- info.append( [ item, value_num, value_text ] )
- num_found += 1
- exitstatus = snmp_process.close()
- if exitstatus:
- if opt_verbose:
- sys.stderr.write(tty_red + tty_bold + "ERROR: " + tty_normal +
"SNMP error\n")
- raise MKSNMPError("SNMP Error on %s" % ipaddress)
- return info
def snmpwalk_on_suboid(hostname, ip, oid):
portspec = snmp_port_spec(hostname)