Module: check_mk
Branch: master
Commit: 67325fa196778bdb5d9ed9435131944400e01762
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=67325fa196778b…
Author: Florian Kromer <fk(a)mathias-kettner.de>
Date: Thu Apr 25 13:51:50 2019 +0200
postgres_stats: refactoring 2
Change-Id: I808f2f7bbc3cc4eb37971e7b0f61c3eabbf0758b
---
checks/postgres_stats | 54 +++++++++++++++++++++++++--------------------------
1 file changed, 27 insertions(+), 27 deletions(-)
diff --git a/checks/postgres_stats b/checks/postgres_stats
index 52a9469..13d1841 100644
--- a/checks/postgres_stats
+++ b/checks/postgres_stats
@@ -90,34 +90,34 @@ def check_postgres_stats(item, params, parsed):
if not never_checked:
set_item_state(key, now)
yield 0, "No never checked tables"
+ return
+
+ count = len(never_checked)
+ infotext = "%d tables were never %s: %s%s" % (count, text,
"/".join(never_checked[:5]),
+ " (first 5 shown)" if count
> 5 else "")
+
+ if "never_analyze_vacuum" in params:
+ last_ts = get_item_state(key)
+ if last_ts is None:
+ set_item_state(key, now)
+ yield 0, infotext
+ return
+
+ age = now - last_ts
+ warn, crit = params["never_analyze_vacuum"]
+ state = 0
+ if age >= crit:
+ state = 2
+ elif age >= warn:
+ state = 1
+ if state:
+ infotext += " (warn/crit at %s/%s)" % \
+ (get_age_human_readable(warn),
+ get_age_human_readable(crit),)
+ yield state, infotext
- elif never_checked:
- infotext = "%d tables were never %s: %s%s" % \
- (len(never_checked), text, "/".join(never_checked[:5]),
- len(never_checked) > 5 and " (first %d shown)" % min(5,
len(never_checked)) or "")
-
- if "never_analyze_vacuum" in params:
- last_ts = get_item_state(key)
- if last_ts is None:
- set_item_state(key, now)
- yield 0, infotext
- return
-
- age = now - last_ts
- warn, crit = params["never_analyze_vacuum"]
- state = 0
- if age >= crit:
- state = 2
- elif age >= warn:
- state = 1
- if state:
- infotext += " (warn/crit at %s/%s)" % \
- (get_age_human_readable(warn),
- get_age_human_readable(crit),)
- yield state, infotext
-
- else:
- yield 1, infotext
+ else:
+ yield 1, infotext
check_info['postgres_stats'] = {