Module: check_mk
Branch: master
Commit: 6e37a7b43115bc1ac2cc9b07f7b4ae11d571dd14
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6e37a7b43115bc…
Author: Florian Kromer <fk(a)mathias-kettner.de>
Date: Wed Apr 24 08:42:43 2019 +0200
7295: postgres_stats: Optional ignore of db table
This check plugin notifies about db tables which have never been analyzed or
vacuumed with status according to the configuration in the WATO rule
"PostgresSQL VACUUM and ANALYZE: Age of never analyzed/vacuumed tables".
Users can now disable this rule, such that never analyzed or vacuumed tables
are always {OK}.
CMK-1385
Change-Id: I858fb6784321a45ad0ffb617d9be4d818a6b9570
---
.werks/7295 | 14 ++++++++++++++
checkman/postgres_stats | 11 ++++++++++-
checks/postgres_stats | 2 +-
.../wato/check_parameters/postgres_maintenance.py | 22 ++++++++++++++++++----
.../checks/generictests/datasets/postgres_stats.py | 4 ++--
5 files changed, 45 insertions(+), 8 deletions(-)
diff --git a/.werks/7295 b/.werks/7295
new file mode 100644
index 0000000..842d74b
--- /dev/null
+++ b/.werks/7295
@@ -0,0 +1,14 @@
+Title: postgres_stats: Optional ignore of db table
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1556035464
+Class: feature
+
+This check plugin notifies about db tables which have never been analyzed or
+vacuumed with status according to the configuration in the WATO rule
+"PostgresSQL VACUUM and ANALYZE: Age of never analyzed/vacuumed tables".
+Users can now disable this rule, such that never analyzed or vacuumed tables
+are always {OK}.
diff --git a/checkman/postgres_stats b/checkman/postgres_stats
index 91360da..2488ba0 100644
--- a/checkman/postgres_stats
+++ b/checkman/postgres_stats
@@ -8,7 +8,16 @@ description:
a PostgreSQL database. You can configure limits specifiying the maximum age of the last
operation.
Without additional limits configuration this check is always OK.
- This check relies on data reported by the agent-side plugin {mk_postgres}
+ This check relies on data reported by the agent-side plugin {mk_postgres}.
+
+ Check status:
+
+ For every table the time since it has last been analyzed or vacuumed is checked
+ according to the WATO rule "PostgresSQL VACUUM and ANALYZE: Time since the last
+ VACUUM" and "Time since the last ANALYZE" respectively. For tables that
were
+ never analyzed or vacuumed the time period for which they exist is checked
+ according to the WATO rule "PostgresSQL VACUUM and ANALYZE: Age of never
+ analyzed/vacuumed tables".
inventory:
Two services for each database. One for VACUUM and one for ANALYZE.
diff --git a/checks/postgres_stats b/checks/postgres_stats
index b4903b2..da2958b 100644
--- a/checks/postgres_stats
+++ b/checks/postgres_stats
@@ -37,7 +37,7 @@
# postgres;pg_catalog;pg_attribute;-1;-1
factory_settings["postgres_stats_default_levels"] = {
- "never_analyze_vacuum": (0, float('inf')),
+ "never_analyze_vacuum": (0, 1000 * 365 * 24 * 3600),
}
diff --git a/cmk/gui/plugins/wato/check_parameters/postgres_maintenance.py
b/cmk/gui/plugins/wato/check_parameters/postgres_maintenance.py
index e6d9cac..92107d2 100644
--- a/cmk/gui/plugins/wato/check_parameters/postgres_maintenance.py
+++ b/cmk/gui/plugins/wato/check_parameters/postgres_maintenance.py
@@ -27,7 +27,9 @@
from cmk.gui.i18n import _
from cmk.gui.valuespec import (
Age,
+ Alternative,
Dictionary,
+ FixedValue,
TextAscii,
Tuple,
)
@@ -82,11 +84,23 @@ class
RulespecCheckgroupParametersPostgresMaintenance(CheckParameterRulespecWith
],
)),
("never_analyze_vacuum",
- Tuple(
- title=_("Age of never analyzed/vacuumed tables"),
+ Alternative(
+ title=_("Never analyzed/vacuumed tables"),
+ style="dropdown",
elements=[
- Age(title=_("Warning if older than"),
default_value=86400 * 7),
- Age(title=_("Critical if older than"),
default_value=86400 * 14)
+ Tuple(
+ title=_("Age of never analyzed/vacuumed tables"),
+ elements=[
+ Age(title=_("Warning if older than"),
default_value=0),
+ Age(title=_("Critical if older than"),
+ default_value=1000 * 365 * 24 * 3600)
+ ],
+ ),
+ FixedValue(
+ None,
+ title=_("Do not check age of never analyzed/vacuumed
tables"),
+ totext="",
+ ),
],
)),
],
diff --git a/tests/unit/checks/generictests/datasets/postgres_stats.py
b/tests/unit/checks/generictests/datasets/postgres_stats.py
index 0367d79..98fc68b 100644
--- a/tests/unit/checks/generictests/datasets/postgres_stats.py
+++ b/tests/unit/checks/generictests/datasets/postgres_stats.py
@@ -39,11 +39,11 @@ checks = {
(0, u'2 tables were never analyzed: anrede/auftrag_mediadaten', []),
(2, u'Unhandled tables for: 20 m (warn/crit at 16 m/18 m)', []),
]),
- (u'ANALYZE adwebconnect', {"never_analyze_vacuum": (0,
float('inf'))}, [
+ (u'ANALYZE adwebconnect', {'never_analyze_vacuum': (0, 1000 * 365
* 24 * 3600)}, [
(0, u'Table: auftrag', []),
(0, u'Time since last vacuum: 674 d', []),
(0, u'2 tables were never analyzed: anrede/auftrag_mediadaten', []),
- (1, u'Unhandled tables for: 20 m (warn/crit at 0.00 s/inf y)', []),
+ (1, u'Unhandled tables for: 20 m (warn/crit at 0.00 s/1000 y)', []),
]),
(u'ANALYZE adwebconnect', {'never_analyze_vacuum': None}, [
(0, u'Table: auftrag', []),