Module: check_mk
Branch: master
Commit: 52a4bc6fae4048a1e96567b392265dffa4b7bb5a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=52a4bc6fae4048…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Nov 15 16:39:26 2017 +0100
Moved description of SNMP agent type to SNMP data source
Change-Id: If81550f89a4a8dec05443b0cf654979d3eea9d03
---
cmk_base/data_sources/snmp.py | 28 ++++++++++++++++++++++++++++
cmk_base/dump_host.py | 27 ---------------------------
2 files changed, 28 insertions(+), 27 deletions(-)
diff --git a/cmk_base/data_sources/snmp.py b/cmk_base/data_sources/snmp.py
index 33c734f..257fd0d 100644
--- a/cmk_base/data_sources/snmp.py
+++ b/cmk_base/data_sources/snmp.py
@@ -77,6 +77,34 @@ class SNMPDataSource(DataSource):
return "snmp"
+ def describe(self, hostname, ipaddress):
+ if config.is_usewalk_host(hostname):
+ return "SNMP (use stored walk)"
+
+ if config.is_inline_snmp_host(hostname):
+ inline = "yes"
+ else:
+ inline = "no"
+
+ credentials = config.snmp_credentials_of(hostname)
+ if type(credentials) in [ str, unicode ]:
+ cred = "Community: %r" % credentials
+ else:
+ cred = "Credentials: '%s'" % ",
".join(credentials)
+
+ if config.is_snmpv3_host(hostname) or config.is_bulkwalk_host(hostname):
+ bulk = "yes"
+ else:
+ bulk = "no"
+
+ portinfo = config.snmp_port_of(hostname)
+ if portinfo == None:
+ portinfo = 'default'
+
+ return "SNMP (%s, Bulk walk: %s, Port: %s, Inline: %s)" % \
+ (cred, bulk, portinfo, inline)
+
+
def _from_cache_file(self, raw_data):
return ast.literal_eval(raw_data)
diff --git a/cmk_base/dump_host.py b/cmk_base/dump_host.py
index 20f2ada..c91d10c 100644
--- a/cmk_base/dump_host.py
+++ b/cmk_base/dump_host.py
@@ -85,33 +85,6 @@ def dump_host(hostname):
for source in sources.get_data_sources():
agenttypes.append(source.describe(hostname, ipaddress))
- if config.is_snmp_host(hostname):
- if config.is_usewalk_host(hostname):
- agenttypes.append("SNMP (use stored walk)")
- else:
- if config.is_inline_snmp_host(hostname):
- inline = "yes"
- else:
- inline = "no"
-
- credentials = config.snmp_credentials_of(hostname)
- if type(credentials) in [ str, unicode ]:
- cred = "community: \'%s\'" % credentials
- else:
- cred = "credentials: '%s'" % ",
".join(credentials)
-
- if config.is_snmpv3_host(hostname) or config.is_bulkwalk_host(hostname):
- bulk = "yes"
- else:
- bulk = "no"
-
- portinfo = config.snmp_port_of(hostname)
- if portinfo == None:
- portinfo = 'default'
-
- agenttypes.append("SNMP (%s, bulk walk: %s, port: %s, inline: %s)"
%
- (cred, bulk, portinfo, inline))
-
if config.is_ping_host(hostname):
agenttypes.append('PING only')