Module: check_mk
Branch: master
Commit: fd0f7d1d19982e8d53b384e1bd847cf8d0a1415b
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fd0f7d1d19982e…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sat Nov 6 13:31:23 2010 +0100
check_mk -I snmp will try all checks without scan function
---
ChangeLog | 2 ++
LIESMICH.zutun | 3 ---
checks/ifoperstatus | 5 ++---
checks/snmp_info | 3 +++
modules/check_mk.py | 15 ++++++++++++++-
5 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8be561a..815e857 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -33,6 +33,8 @@
make Nagios reject the configuration.
* --snmpwalk: do not translate anymore, use numbers. All checks work
with numbers now anyway.
+ * check_mk -I snmp will now try all checktypes not having an snmp scan
+ function. That way all possible checks should be inventorized.
Checks & Agents:
* megaraid_pdisks: Using the real enclosure number as check item now
diff --git a/LIESMICH.zutun b/LIESMICH.zutun
index 48f8913..da47ea0 100644
--- a/LIESMICH.zutun
+++ b/LIESMICH.zutun
@@ -80,9 +80,6 @@ getrennte Checks für Memory and Pagefile.
-------------------------------------------------------------------------------
ab 1.1.9i1:
--------------------------------------------------------------------------------
-IDEE: Scan-Modus: Wenn man einen Host per SNMP scannt und *keine*
-Antwort kommt, dann probiert man einfach alle SNMP-Checks aus.
-
PNP4Nagios-Popups automatisch einbauen, mit eigenen intelligenten
Icons.
diff --git a/checks/ifoperstatus b/checks/ifoperstatus
index 4861ee9..5241fd6 100644
--- a/checks/ifoperstatus
+++ b/checks/ifoperstatus
@@ -59,6 +59,5 @@ def check_ifoperstatus(item, targetstate, info):
check_info['ifoperstatus'] = (check_ifoperstatus, "Interface %s", 0, inventory_ifoperstatus)
snmp_info['ifoperstatus'] = ( ".1.3.6.1.2.1.2.2.1", [ 2, 3, 8 ] )
-# check if number of network interfaces (IF-MIB::ifNumber.0) is at least 2
-# snmp_scan_functions['ifoperstatus'] = \
-# lambda oid: int(oid(".1.3.6.1.2.1.2.1.0")) >= 2
+# Never inventorize automatically. let if/if64 be the default
+snmp_scan_functions['ifoperstatus'] = lambda oid: False
diff --git a/checks/snmp_info b/checks/snmp_info
index 4577f7d..62b5b47 100644
--- a/checks/snmp_info
+++ b/checks/snmp_info
@@ -38,3 +38,6 @@ def check_snmp_info(checktype, params, info):
check_info['snmp_info'] = (check_snmp_info, "SNMP Info", 0, inventory_snmp_info)
snmp_info_single['snmp_info'] = ( None, ".1.3.6.1.2.1.1", [ "1.0", "4.0", "5.0", "6.0" ] )
+
+# Do not use this check per default
+snmp_scan_functions['snmp_info'] = lambda oid: False
diff --git a/modules/check_mk.py b/modules/check_mk.py
index b77d01f..8472556 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -665,10 +665,21 @@ def snmp_scan(hostname, ipaddress):
try:
if detect_function(lambda oid: get_single_oid(hostname, ipaddress, oid)):
found.append(checktype)
- sys.stdout.write("%s " % checktype)
+ sys.stdout.write(tty_green + tty_bold + checktype + " " + tty_normal)
sys.stdout.flush()
except:
pass
+
+ # Now try all checks not having a scan function
+ for checktype in check_info.keys():
+ datatype = checktype.split('.')[0]
+ if datatype not in snmp_info:
+ continue # no snmp check
+ if checktype not in snmp_scan_functions:
+ sys.stdout.write(tty_blue + tty_bold + checktype + tty_normal + " ")
+ sys.stdout.flush()
+ found.append(checktype)
+
if found == []:
sys.stdout.write("nothing detected.\n")
else:
@@ -1583,6 +1594,8 @@ def do_snmp_scan(hostnamelist):
continue
checknames = snmp_scan(hostname, ipaddress)
for checkname in checknames:
+ if opt_debug:
+ sys.stdout.write("Trying inventory for %s on %s\n" % (checkname, hostname))
make_inventory(checkname, [hostname])
Module: check_mk
Branch: master
Commit: 0bbff761d27d14ec01fb49899b153e82f8e80c18
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0bbff761d27d14…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sat Nov 6 12:32:52 2010 +0100
--snmpwalk: do not translate, directly use numeric values
All checks are now only using numeric values. No mibs are
loaded in any case anyway.
---
ChangeLog | 2 ++
LIESMICH.zutun | 13 -------------
modules/check_mk.py | 7 +++----
modules/snmp.py | 12 ------------
4 files changed, 5 insertions(+), 29 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index cd99896..8be561a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -31,6 +31,8 @@
* Make sure, host has no duplicate service - this is possible e.g. by
monitoring via agent and snmp in parallel. duplicate services will
make Nagios reject the configuration.
+ * --snmpwalk: do not translate anymore, use numbers. All checks work
+ with numbers now anyway.
Checks & Agents:
* megaraid_pdisks: Using the real enclosure number as check item now
diff --git a/LIESMICH.zutun b/LIESMICH.zutun
index a4f1d1b..48f8913 100644
--- a/LIESMICH.zutun
+++ b/LIESMICH.zutun
@@ -63,10 +63,6 @@ springt dann immer nach ganz oben.
LARS: Im Opera wird sich die aktuelle Scroll-Position der Sidebar nicht korrekt gemerkt.
-SNMP-Checks: Es wurde berichtet, dass - wenn die Community falsch ist -
-der Check_MK gruen war, aber die Checks unknown. Sollte es dann nicht
-genau umgekehrt sein? Wird der Exit-code von snmpwalk ausgewertet?
-
LARS: Wenn man gerade die Kommandobox auf hat (oder den Filter?) dann sollte
kein Refresh stattfinden. Sonst wird man mitten im Tippen abgewürgt. Kann man
das mit Javascript hinbekommen? (kann Lars sich hier was überlegen? Man
@@ -84,10 +80,6 @@ getrennte Checks für Memory and Pagefile.
-------------------------------------------------------------------------------
ab 1.1.9i1:
--------------------------------------------------------------------------------
---snmpwalk: Braucht man das translaten noch? Ich arbeite doch jetzt eh
-nur noch ohne MIB-Dateien. Das würde das ganze deutlich vereinfachen!
-Direct rrd updates ganz entfernen.
-
IDEE: Scan-Modus: Wenn man einen Host per SNMP scannt und *keine*
Antwort kommt, dann probiert man einfach alle SNMP-Checks aus.
@@ -128,11 +120,6 @@ Multisite: Zeitanzeige der Downtimes (ende) zu ungenau. "in 6 hrs" ist
blöd. Auch bei Start "19 sec" ist dumm, hier wäre besser (vor 19 sec). Oder
bei Downtimes immer absolute Zeiten angeben? Evtl. Zusatzspalte der Duration.
-bulkwalk_hosts: Hier ist der Default None und nicht []. Problem dabei
-ist, dass dann ein += nicht funktioniert. Kann man nicht non_bulkwalk_hosts
-ganz rausschmeissen und bulkwalk_hosts auf [] setzen? Ausserdem gibt
-es ja fuer binaere Hostlisten das NEGATE (=> Doku). In 1.2 einbauen.
-
--------------------------------------------------------------------------------
IDEEN & VERBESSERUNGEN
--------------------------------------------------------------------------------
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 1558007..b77d01f 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -2637,7 +2637,7 @@ def do_snmpwalk_on(hostname, filename):
if opt_verbose:
sys.stdout.write("%s:\n" % hostname)
ip = lookup_ipaddress(hostname)
- cmd = snmp_walk_command(hostname) + " -Ob -OQ %s " % ip
+ cmd = snmp_walk_command(hostname) + " -On -Ob -OQ %s " % ip
if opt_debug:
print 'Executing: %s' % cmd
out = file(filename, "w")
@@ -2665,9 +2665,8 @@ def do_snmpwalk_on(hostname, filename):
oid = oid[1:]
oids.append(oid)
values.append(value)
- numoids = snmptranslate(oids)
- for numoid, value in zip(numoids, values):
- out.write("%s %s\n" % (numoid, value.strip()))
+ for oid, value in zip(oids, values):
+ out.write("%s %s\n" % (oid, value.strip()))
count += 1
if opt_verbose:
sys.stdout.write("%d variables.\n" % count)
diff --git a/modules/snmp.py b/modules/snmp.py
index ea45083..47d9904 100644
--- a/modules/snmp.py
+++ b/modules/snmp.py
@@ -337,18 +337,6 @@ def check_snmp_fixed(item, targetvalue, info):
return (0, "OK - %s" % (value,))
return (3, "Missing item %s in SNMP data" % item)
-def snmptranslate(oids):
- numoids = []
- while len(oids) > 0:
- m = min(len(oids), 100)
- cmd = "snmptranslate -On %s 2>/dev/null" % " ".join(["'%s'" % o.strip() for o in oids[:m]])
- n = os.popen(cmd).read().split()
- if len(n) != m:
- raise MKGeneralException("snmptranslated lost %d out of %d oids" % (m - len(n), m))
- oids = oids[m:]
- numoids += n
- return numoids
-
def get_stored_snmpwalk(hostname, oid):
if oid.startswith("."):
oid = oid[1:]
Module: check_mk
Branch: master
Commit: f54b0d6f197957b443c64f00006b7612c345bcae
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f54b0d6f197957…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sat Nov 6 12:25:02 2010 +0100
Always make implicity config check -X
---
ChangeLog | 3 +++
LIESMICH.zutun | 3 ---
modules/check_mk.py | 49 ++++++++++++++++++++++---------------------------
3 files changed, 25 insertions(+), 30 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 53c5e4f..cd99896 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,9 @@
be a dict any longer.
* bulkwalk_hosts is now initizlized with []. You can do += here just
is with all other rule variables.
+ * Configuration check (-X) is now always done. It is now impossible to
+ call any Check_MK action with an invalid configuration. This saves
+ you agains mistyped variables.
Core, Setup, etc.:
* Improve error handling: if hosts are monitored with SNMP *and* TCP,
diff --git a/LIESMICH.zutun b/LIESMICH.zutun
index 6e83eb1..a4f1d1b 100644
--- a/LIESMICH.zutun
+++ b/LIESMICH.zutun
@@ -84,9 +84,6 @@ getrennte Checks für Memory and Pagefile.
-------------------------------------------------------------------------------
ab 1.1.9i1:
--------------------------------------------------------------------------------
-check_mk -X erzwingen. Das -R soll nur noch klappen, wenn kein Configfehler
-auftritt.
-
--snmpwalk: Braucht man das translaten noch? Ich arbeite doch jetzt eh
nur noch ohne MIB-Dateien. Das würde das ganze deutlich vereinfachen!
Direct rrd updates ganz entfernen.
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 5f75973..1558007 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -37,11 +37,9 @@ check_mk_version = '(inofficial)'
if __name__ == "__main__":
opt_verbose = '-v' in sys.argv[1:] or '--verbose' in sys.argv[1:]
opt_debug = '--debug' in sys.argv[1:]
- opt_config_check = '-X' in sys.argv[1:] or '--config-check' in sys.argv[1:]
else:
opt_verbose = False
opt_debug = False
- opt_config_check = False
# are we running OMD? If yes, honor local/ hierarchy
omd_root = os.getenv("OMD_ROOT", None)
@@ -3378,8 +3376,7 @@ def ip_to_hostname(ip):
def all_nonfunction_vars():
return set([ name for name,value in globals().items() if name[0] != '_' and type(value) != type(lambda:0) ])
-if opt_config_check:
- vars_before_config = all_nonfunction_vars()
+vars_before_config = all_nonfunction_vars()
list_of_files = [ check_mk_configfile ] + glob.glob(check_mk_configdir + '/*.mk')
@@ -3463,31 +3460,29 @@ if __name__ == "__main__":
checks = autochecks + checks
-
-if opt_config_check:
- vars_after_config = all_nonfunction_vars()
- ignored_variables = set(['vars_before_config', 'rrdtool', 'final_mk', 'list_of_files', 'autochecks',
- 'parts' ,'hosttags' ,'seen_hostnames' ,'all_hosts_untagged' ,'taggedhost' ,'hostname'])
- errors = 0
- for name in vars_after_config:
- if name not in ignored_variables and name not in vars_before_config:
- sys.stderr.write("Invalid configuration variable '%s'\n" % name)
- errors += 1
-
- # Special handling for certain deprecated variables
- if filesystem_levels != []:
- sys.stderr.write("WARNING: filesystem_levels is deprecated and will be removed\n"
- "any decade now. Please use check_parameters instead! Details can be\n"
- "found at http://mathias-kettner.de/checkmk_check_parameters.html.\n")
-
- if type(snmp_communities) == dict:
- sys.stderr.write("ERROR: snmp_communities cannot be a dict any more.\n")
+vars_after_config = all_nonfunction_vars()
+ignored_variables = set(['vars_before_config', 'rrdtool', 'final_mk', 'list_of_files', 'autochecks',
+ 'parts' ,'hosttags' ,'seen_hostnames' ,'all_hosts_untagged' ,'taggedhost' ,'hostname'])
+errors = 0
+for name in vars_after_config:
+ if name not in ignored_variables and name not in vars_before_config:
+ sys.stderr.write("Invalid configuration variable '%s'\n" % name)
errors += 1
- if errors > 0:
- sys.stderr.write("--> Found %d invalid variables\n" % errors)
- sys.stderr.write("If you use own helper variables, please prefix them with _.\n")
- sys.exit(1)
+# Special handling for certain deprecated variables
+if filesystem_levels != []:
+ sys.stderr.write("WARNING: filesystem_levels is deprecated and will be removed\n"
+ "any decade now. Please use check_parameters instead! Details can be\n"
+ "found at http://mathias-kettner.de/checkmk_check_parameters.html.\n")
+
+if type(snmp_communities) == dict:
+ sys.stderr.write("ERROR: snmp_communities cannot be a dict any more.\n")
+ errors += 1
+
+if errors > 0:
+ sys.stderr.write("--> Found %d invalid variables\n" % errors)
+ sys.stderr.write("If you use own helper variables, please prefix them with _.\n")
+ sys.exit(1)
# Convert www_group into numeric id
Module: check_mk
Branch: master
Commit: 84776aa08638776b06d6a9f21ea2bad781849a3f
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=84776aa0863877…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sat Nov 6 11:56:10 2010 +0100
check for duplicate service descriptions
---
ChangeLog | 3 +++
LIESMICH.zutun | 3 ---
modules/check_mk.py | 23 +++++++++++++++++++++++
3 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 0d46dd5..53c5e4f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -25,6 +25,9 @@
is called from another directory)
* ALL_SERVICES: Instead of [ "" ] you can now write ALL_SERVICES
* debug_log: also output Check_MK version, check item and check parameters
+ * Make sure, host has no duplicate service - this is possible e.g. by
+ monitoring via agent and snmp in parallel. duplicate services will
+ make Nagios reject the configuration.
Checks & Agents:
* megaraid_pdisks: Using the real enclosure number as check item now
diff --git a/LIESMICH.zutun b/LIESMICH.zutun
index b955bd2..6e83eb1 100644
--- a/LIESMICH.zutun
+++ b/LIESMICH.zutun
@@ -4,9 +4,6 @@ Doku: Check_MK und OMD: Installieren von MKPs, local-Hierarchie
--------------------------------------------------------------------------------
BUGS beheben ab 1.1.9i1
--------------------------------------------------------------------------------
-Wenn zwei Checks mit dem gleichen Namen existieren bei einem Host
-soll mit einem Fehler abgebrochen werden.
-
ich bin mir nicht sicher ob das nun ein Thruk Problem oder ein Livestatus Problem ist. Vermutlich beides :-)
Wenn ich im Thruk im Suchfenster einfach Enter drücke, kommt folgende Query bei raus:
GET services
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 8da1029..5f75973 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -1292,7 +1292,19 @@ def create_nagios_servicedefs(outfile, hostname):
aggregated_services_conf = set([])
do_aggregation = host_is_aggregated(hostname)
have_at_least_one_service = False
+ used_descriptions = {}
for ((checkname, item), (params, description, deps)) in host_checks:
+ # Make sure, the service description is unique on this host
+ if description in used_descriptions:
+ cn, it = used_descriptions[description]
+ raise MKGeneralException(
+ "ERROR: Duplicate service description '%s' for host '%s'!\n"
+ " - 1st occurrance: checktype = %s, item = %r\n"
+ " - 2nd occurrance: checktype = %s, item = %r\n" %
+ (description, hostname, cn, it, checkname, item))
+
+ else:
+ used_descriptions[description] = ( checkname, item )
if have_perfdata(checkname):
template = passive_service_template_perf
else:
@@ -1420,6 +1432,17 @@ define servicedependency {
if len(legchecks) > 0:
outfile.write("\n\n# Legacy checks\n")
for command, description, has_perfdata in legchecks:
+ if description in used_descriptions:
+ cn, it = used_descriptions[description]
+ raise MKGeneralException(
+ "ERROR: Duplicate service description (legacy check) '%s' for host '%s'!\n"
+ " - 1st occurrance: checktype = %s, item = %r\n"
+ " - 2nd occurrance: checktype = legacy(%s), item = None\n" %
+ (description, hostname, cn, it, command))
+
+ else:
+ used_descriptions[description] = ( "legacy(" + command + ")", item )
+
extraconf = extra_service_conf_of(hostname, description)
if has_perfdata:
template = "check_mk_perf,"