Module: check_mk
Branch: master
Commit: 7f575c886a7c3be19a3c8b137f9179dc04d359f6
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7f575c886a7c3b…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Jul 5 17:19:42 2012 +0200
BI: speedup of rule precompilation
---
ChangeLog | 4 ++
web/htdocs/bi.py | 88 ++++++++++++++++++++++++++++++++++++++----------------
2 files changed, 66 insertions(+), 26 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 93837a1..77318db 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+1.2.0p3:
+ BI:
+ * Great speed up of rule compilation in large environments
+
1.2.0p2:
Core:
* simulation_mode: legacy_checks, custom_checks and active_checks
diff --git a/web/htdocs/bi.py b/web/htdocs/bi.py
index c758b95..908c64f 100644
--- a/web/htdocs/bi.py
+++ b/web/htdocs/bi.py
@@ -107,6 +107,7 @@ g_config_information = None # for invalidating cache after config change
# without state.
def load_services():
services = {}
+ services_by_hostname = {}
html.live.set_prepend_site(True)
html.live.set_auth_domain('bi')
data = html.live.query("GET hosts\n"
@@ -118,9 +119,11 @@ def load_services():
for site, host, varnames, values, svcs, childs, parents in data:
vars = dict(zip(varnames, values))
tags = vars.get("TAGS", "").split(" ")
- services[(site, host)] = (tags, svcs, childs, parents)
+ entry = (tags, svcs, childs, parents)
+ services[(site, host)] = entry
+ services_by_hostname.setdefault(host, []).append(entry)
- return services
+ return services, services_by_hostname
# Keep complete list of time stamps of configuration
# and start of each site. Unreachable sites are registered
@@ -173,13 +176,15 @@ def compile_forest(user):
global did_compilation
did_compilation = True
+ services, services_by_hostname = load_services()
cache = {
"forest" : {},
"aggregations_by_hostname" : {},
"host_aggregations" : {},
"affected_hosts" : {},
"affected_services": {},
- "services" : load_services(),
+ "services" : services,
+ "services_by_hostname" : services_by_hostname,
"see_all" : config.may("bi.see_all"),
}
g_user_cache = cache
@@ -227,7 +232,6 @@ def compile_forest(user):
g_cache[user] = cache
-
# Execute an aggregation rule, but prepare arguments
# and iterate FOREACH first
def compile_rule_node(calllist, lvl):
@@ -278,33 +282,47 @@ def find_matching_services(what, calllist):
else:
service_re = calllist[1]
+ matches = set([])
honor_site = SITE_SEP in host_re
- matches = set([])
+ if host_re.startswith("^(") and host_re.endswith(")$"):
+ middle = host_re[2:-2]
+ if middle in g_user_cache["services_by_hostname"]:
+ entries = [ (("", host_re), entry) for entry in g_user_cache["services_by_hostname"][middle] ]
+ host_re = "(.*)"
+ elif not honor_site and not '*' in host_re and not '$' in host_re and not '|' in host_re:
+ entries = [ (("", host_re), entry) for entry in g_user_cache["services_by_hostname"][host_re] ]
+ else:
+ entries = g_user_cache["services"].items()
# TODO: Hier könnte man - wenn der Host bekannt ist, effektiver arbeiten, als
# komplett alles durchzugehen.
- for (site, hostname), (tags, services, childs, parents) in g_user_cache["services"].items():
+ for (site, hostname), (tags, services, childs, parents) in entries:
host_matches = None
if not match_host_tags(tags, required_tags):
continue
- # For regex to have '$' anchor for end. Users might be surprised
- # to get a prefix match on host names. This is almost never what
- # they want. For services this is useful, however.
- if host_re.endswith("$"):
- anchored = host_re
- else:
- anchored = host_re + "$"
-
- # In order to distinguish hosts with the same name on different
- # sites we prepend the site to the host name. If the host specification
- # does not contain the site separator - though - we ignore the site
- # an match the rule for all sites.
- if honor_site:
- host_matches = do_match(anchored, "%s%s%s" % (site, SITE_SEP, hostname))
+ host_matches = None
+
+ if host_re == '(.*)':
+ host_matches = (hostname, )
else:
- host_matches = do_match(anchored, hostname)
+ # For regex to have '$' anchor for end. Users might be surprised
+ # to get a prefix match on host names. This is almost never what
+ # they want. For services this is useful, however.
+ if host_re.endswith("$"):
+ anchored = host_re
+ else:
+ anchored = host_re + "$"
+
+ # In order to distinguish hosts with the same name on different
+ # sites we prepend the site to the host name. If the host specification
+ # does not contain the site separator - though - we ignore the site
+ # an match the rule for all sites.
+ if honor_site:
+ host_matches = do_match(anchored, "%s%s%s" % (site, SITE_SEP, hostname))
+ else:
+ host_matches = do_match(anchored, hostname)
if host_matches != None:
if what == config.FOREACH_CHILD:
@@ -319,9 +337,14 @@ def find_matching_services(what, calllist):
matches.add(host_matches)
else:
for service in services:
- svc_matches = do_match(service_re, service)
- if svc_matches != None:
+ mo = (service_re, service)
+ if mo in service_nomatch_cache:
+ continue
+ m = regex(service_re).match(service)
+ if m:
matches.add(host_matches + svc_matches)
+ else:
+ service_nomatch_cache.add(mo)
matches = list(matches)
matches.sort()
@@ -596,12 +619,16 @@ def match_host_tags(have_tags, required_tags):
def compile_leaf_node(host_re, service_re = config.HOST_STATE):
found = []
honor_site = SITE_SEP in host_re
+ if not honor_site and not '*' in host_re and not '$' in host_re and not '|' in host_re:
+ entries = [ (("", host_re), entry) for entry in g_user_cache["services_by_hostname"][host_re] ]
+ else:
+ entries = g_user_cache["services"].items()
# TODO: If we already know the host we deal with, we could avoid this loop
- for (site, hostname), (tags, services, childs, parents) in g_user_cache["services"].items():
+ for (site, hostname), (tags, services, childs, parents) in entries:
# If host ends with '|@all', we need to check host tags instead
# of regexes.
- if host_re.endswith('|@all'):
+ if False and host_re.endswith('|@all'):
if not match_host_tags(host_re[:-5], tags):
continue
elif host_re != '@all':
@@ -636,17 +663,25 @@ def compile_leaf_node(host_re, service_re = config.HOST_STATE):
else:
for service in services:
- if regex(service_re).match(service):
+ mo = (service_re, service)
+ if mo in service_nomatch_cache:
+ continue
+ m = regex(service_re).match(service)
+ if m:
found.append({"type" : NT_LEAF,
"reqhosts" : [(site, hostname)],
"host" : (site, hostname),
"service" : service,
"title" : "%s - %s" % (hostname, service)} )
+ else:
+ service_nomatch_cache.add(mo)
found.sort()
return found
+service_nomatch_cache = set([])
+
regex_cache = {}
def regex(r):
rx = regex_cache.get(r)
@@ -661,6 +696,7 @@ def regex(r):
+
# _____ _ _
# | ____|_ _____ ___ _ _| |_(_) ___ _ __
# | _| \ \/ / _ \/ __| | | | __| |/ _ \| '_ \
Module: check_mk
Branch: master
Commit: ea5038afc2b46dbf9590df29f94cc551533fb440
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ea5038afc2b46d…
Author: Florian Heigl <fh(a)mathias-kettner.de>
Date: Wed Jul 4 17:03:04 2012 +0200
close bug entry
---
.bugs/714 | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/.bugs/714 b/.bugs/714
index 8e5adcf..7b71846 100644
--- a/.bugs/714
+++ b/.bugs/714
@@ -1,9 +1,9 @@
Title: PostgreSQL check breaks on version 9 output
Component: checks
-State: open
+Class: bug
+State: closed
Date: 2012-06-26 14:14:46
Targetversion: 1.2.0
-Class: bug
Currently we do not support output from version 9 PostgreSQL.
They send one more data field and our agent sends with " " as separator
@@ -38,3 +38,8 @@ Fix suggested by user:
Methinks (flo) that we should
- not fetch the stats_reset timestamp at all since we dont need it
- not use -F' ' but -F'somethingelse'
+
+2012-07-04 17:02:48: changed state open -> closed
+Bug should be fixed now.
+They added a field for last stats reset which we don't need but still fetched.
+Agent now selects only defined fields and uses sep:() in case we run into this situation again.
Module: check_mk
Branch: master
Commit: d01a7488fc09d0a2023cbec4db94f0b19f7f6bd7
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d01a7488fc09d0…
Author: Florian Heigl <fh(a)mathias-kettner.de>
Date: Wed Jul 4 17:00:52 2012 +0200
Update PostgreSQL Check_MK plugin to work with PostgreSQL 8.3 and 9.1
---
ChangeLog | 2 ++
agents/plugins/mk_postgres | 15 +++++++--------
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a052e19..cc64d96 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -28,6 +28,8 @@
* FIX: winperf_phydisk: Fix typo (lead to WATO rule not being applied)
* Windows agent: new [global] option crash_debug (see online docu)
* AIX agent: new check for LVM volume status in rootvg.
+ * PostgreSQL plugin: agent is now modified to work with PostgreSQL
+ versions newer than 8.1. (multiple reports, thanks!)
Multisite:
* Show number of rows and number of selected rows in header line
diff --git a/agents/plugins/mk_postgres b/agents/plugins/mk_postgres
index ab69fd1..6667aab 100755
--- a/agents/plugins/mk_postgres
+++ b/agents/plugins/mk_postgres
@@ -1,11 +1,10 @@
-#!/bin/bash
+#!/bin/sh
-if id postgres >/dev/null ; then
+if id pgsql >/dev/null ; then
echo '<<<postgres_sessions>>>'
- echo "select current_query = '<IDLE>', count(*) from pg_stat_activity group by (current_query = '<IDLE>');" | su - postgres -c "psql -A -t -F' '"
- echo '<<<postgres_stat_database>>>'
- # The following statement might change in future for better cross-version
- # compatibility.
- echo 'select *, pg_database_size(datname) as "datsize" from pg_stat_database;' \
- | su - postgres -c "psql -A -F' '" | sed '$d'
+ echo "select current_query = '<IDLE>', count(*) from pg_stat_activity group by (current_query = '<IDLE>');" | su - pgsql -c "psql -d postgres -A -t -F' '"
+
+ echo '<<<postgres_stat_database:sep(59)>>>'
+ echo 'select datid,datname,numbackends,xact_commit,xact_rollback,blks_read,blks_hit,tup_returned,tup_fetched,tup_inserted,tup_updated,tup_deleted,conflicts, pg_database_size(datname) as "datsize" from pg_stat_database;' \
+ | su - pgsql -c "psql -d postgres -A -F';'" | sed '$d'
fi
Module: check_mk
Branch: master
Commit: aeb8ea491c8edf0e30ee762c7bf8917b01bf7535
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=aeb8ea491c8edf…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jul 4 11:07:32 2012 +0200
Mobile hint is now a prefix
---
.bugs/776 | 8 +++++++-
web/htdocs/views.py | 2 +-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/.bugs/776 b/.bugs/776
index 04bc4c5..32bb77a 100644
--- a/.bugs/776
+++ b/.bugs/776
@@ -1,6 +1,6 @@
Title: Link for Column in view editor shows duplicate views
Component: multisite
-State: open
+State: done
Date: 2012-06-20 14:07:19
Targetversion: 1.2.0
Class: nastiness
@@ -14,3 +14,9 @@ and put those at the bottom of the ist.
Also Only show view that have at least on "hide"-Filter.
Views without a context are not useful for linking.
+
+2012-07-04 11:06:55: changed state open -> done
+has just been fixed
+
+2012-07-04 11:07:03: changed state done -> done
+has just been fixed
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index b0856ac..bc14920 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -434,7 +434,7 @@ def select_view(varname, only_with_hidden = False):
for name, view in html.available_views.items():
if not only_with_hidden or len(view["hide_filters"]) > 0:
if view.get('mobile', False):
- title = view["title"] + _(' (Mobile)')
+ title = _('Mobile: ') + view["title"]
else:
title = view["title"]
choices.append(("%s" % name, title))
Module: check_mk
Branch: master
Commit: 06089c0105bdbd2d54836ee6e6291f7b7c164cf1
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=06089c0105bdbd…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jul 4 11:00:35 2012 +0200
FIX: view editor shows "(Mobile)" hint in view titles when linking to views
---
ChangeLog | 1 +
web/htdocs/views.py | 6 +++++-
2 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 374af9d..7cb1750 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -38,6 +38,7 @@
* FIX: fixed exception when refering to a language which does not exist
* FIX: Removing all downtimes of a host/service is now possible again
* FIX: The refresh time in footer is updated now when changing the value
+ * FIX: view editor shows "(Mobile)" hint in view titles when linking to views
WATO:
* Main menu of ruleeditor (Host & Service Parameters) now has
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 2c3f7e2..b0856ac 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -433,7 +433,11 @@ def select_view(varname, only_with_hidden = False):
choices = [("", "")]
for name, view in html.available_views.items():
if not only_with_hidden or len(view["hide_filters"]) > 0:
- choices.append(("%s" % name, view["title"]))
+ if view.get('mobile', False):
+ title = view["title"] + _(' (Mobile)')
+ else:
+ title = view["title"]
+ choices.append(("%s" % name, title))
html.sorted_select(varname, choices, "")
# -------------------------------------------------------------------------
Module: check_mk
Branch: master
Commit: f4a761031e6390de04515e48d542fc5c4b364912
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f4a761031e6390…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jul 4 10:59:50 2012 +0200
Updated bug entries #0770, #0759
---
.bugs/759 | 2 +-
.bugs/770 | 7 +++++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/.bugs/759 b/.bugs/759
index 5a35e43..8d4200a 100644
--- a/.bugs/759
+++ b/.bugs/759
@@ -2,7 +2,7 @@ Title: Checkbox handling in views sometimes broken
Component: multisite
State: open
Date: 2012-05-28 16:13:51
-Targetversion: 1.2.0
+Targetversion: future
Class: bug
The handling of the checkboxes in the views still has
diff --git a/.bugs/770 b/.bugs/770
index b1ae05a..1f93b41 100644
--- a/.bugs/770
+++ b/.bugs/770
@@ -1,11 +1,14 @@
Title: View editor: view shown at "Link:" are duplicate
Component: multisite
-State: open
+Class: bug
+State: done
Date: 2012-06-14 13:21:44
Targetversion: 1.2.0
-Class: bug
The list of views selectable when linking contains duplicates.
LM: The duplicate titles are in fact different views. The second
views are the mobile views.
+
+2012-07-04 10:59:44: changed state open -> done
+Added "(Mobile)" text to all mobile views to prevent duplicated entries