Module: check_mk
Branch: master
Commit: 8da8c92ad2d1b56a3384f781e6577fd45e74f43b
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8da8c92ad2d1b5…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Nov 22 09:18:08 2012 +0100
Checking for existing auth.phgp and auth.serials independent of the used login method
---
web/htdocs/login.py | 10 ----------
web/htdocs/userdb.py | 23 ++++++++++++++++++++++-
2 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/web/htdocs/login.py b/web/htdocs/login.py
index 3c7557d..7e5e2ee 100644
--- a/web/htdocs/login.py
+++ b/web/htdocs/login.py
@@ -205,16 +205,6 @@ def page_login(no_html_output = False):
return normal_login_page()
def normal_login_page(called_directly = True):
- # Working around the problem that the auth.php file needed for multisite based
- # authorization of external addons might not exist when setting up a new installation
- # We assume: Each user must visit this login page before using the multisite based
- # authorization. So we can easily create the file here if it is missing.
- # This is a good place to replace old api based files in the future.
- auth_php = defaults.var_dir + '/wato/auth/auth.php'
- if not os.path.exists(auth_php) or os.path.getsize(auth_php) == 0:
- import wato
- wato.create_auth_file(wato.load_users())
-
html.set_render_headfoot(False)
html.header(_("Check_MK Multisite Login"), javascripts=[], stylesheets=["pages", "login"])
diff --git a/web/htdocs/userdb.py b/web/htdocs/userdb.py
index c49d112..e0da8ce 100644
--- a/web/htdocs/userdb.py
+++ b/web/htdocs/userdb.py
@@ -24,7 +24,7 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-import config
+import config, defaults
from lib import *
import time
from valuespec import *
@@ -217,6 +217,25 @@ def hook_save(users):
else:
raise
+# This function registers general stuff, which is independet of the single
+# connectors to each page load. It is exectued AFTER all other page hooks.
+def general_page_hook():
+ # Working around the problem that the auth.php file needed for multisite based
+ # authorization of external addons might not exist when setting up a new installation
+ # We assume: Each user must visit this login page before using the multisite based
+ # authorization. So we can easily create the file here if it is missing.
+ # This is a good place to replace old api based files in the future.
+ auth_php = defaults.var_dir + '/wato/auth/auth.php'
+ if not os.path.exists(auth_php) or os.path.getsize(auth_php) == 0:
+ import wato
+ wato.create_auth_file(wato.load_users())
+
+ # Create initial auth.serials file, same issue as auth.php above
+ serials_file = '%s/auth.serials' % os.path.dirname(defaults.htpasswd_file)
+ if not os.path.exists(serials_file):
+ import wato
+ wato.save_users(wato.load_users())
+
# Hook function can be registered here to execute actions on a "regular" base without
# user triggered action. This hook is called on each page load.
# Catch all exceptions and log them to apache error log. Let exceptions raise trough
@@ -235,3 +254,5 @@ def hook_page():
import traceback
html.log('Exception (%s, page handler): %s' %
(connector['id'], traceback.format_exc()))
+
+ general_page_hook()
Module: check_mk
Branch: master
Commit: 737bf92495e5fdd9df2f7a055f655f1aa621e739
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=737bf92495e5fd…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Nov 22 08:50:44 2012 +0100
apache_status: Modified to be usable on python < 2.6 (eg RHEL 5.x)
---
ChangeLog | 1 +
agents/plugins/apache_status | 16 +++++++++-------
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 38056c5..1d51143 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
* Linux Agent, mk_postgres: Supporting pgsql and postgres as user
* Linux Agent, mk_postgres: Fixed database stats query to be compatible
with more versions of postgres
+ * apache_status: Modified to be usable on python < 2.6 (eg RHEL 5.x)
Multisite:
* Implemented LDAP integration of Multisite. You can now authenticate your
diff --git a/agents/plugins/apache_status b/agents/plugins/apache_status
index dd0c607..fd63734 100755
--- a/agents/plugins/apache_status
+++ b/agents/plugins/apache_status
@@ -18,7 +18,7 @@
# It is also possible to override or extend the ssl_ports variable to make the
# check contact other ports than 443 with HTTPS requests.
-import os, sys, urllib
+import os, sys, urllib2
config_file = os.getenv("MK_CONFDIR", "/etc/check_mk") + "/apache_status.conf"
@@ -79,11 +79,13 @@ for proto, address, port in servers:
try:
# Try to fetch the status page for each server
url = '%s://%s:%s/server-status?auto' % (proto, address, port)
- fd = urllib.urlopen(url)
- if fd.getcode() == 200:
- for line in fd.read().split('\n'):
- if not line.strip():
- continue
- print address, port, line
+ fd = urllib2.urlopen(url)
+ for line in fd.read().split('\n'):
+ if not line.strip():
+ continue
+ print address, port, line
+ except urllib2.HTTPError, e:
+ sys.stderr.write('HTTP-Error (%s:%d): %s %s\n' % (address, port, e.code, e))
+
except Exception, e:
sys.stderr.write('Exception (%s:%d): %s\n' % (address, port, e))
Module: check_mk
Branch: master
Commit: 51d2110050b912c5e1255c7a18a88b19df240a65
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=51d2110050b912…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Nov 22 08:38:09 2012 +0100
apache_status: RHEL support - added the httpd.worker process
---
agents/plugins/apache_status | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/agents/plugins/apache_status b/agents/plugins/apache_status
index 871c428..dd0c607 100755
--- a/agents/plugins/apache_status
+++ b/agents/plugins/apache_status
@@ -41,7 +41,7 @@ def try_detect_servers():
pid, proc = parts[6].split('/')
# Skip unwanted processes
- if proc not in [ 'apache2', 'httpd', 'httpd2-prefork', 'httpd2-worker' ]:
+ if proc not in [ 'apache2', 'httpd', 'httpd2-prefork', 'httpd2-worker', 'httpd.worker' ]:
continue
# Add only the first found port of a single server process
Module: check_mk
Branch: master
Commit: 6510559ec3d666adc8c1f1eb3d7eccf5f96e6fa3
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6510559ec3d666…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Nov 21 16:59:25 2012 +0100
Linux Agent, mk_postgres: Fixed database stats query to be compatible with more versions of postgres
---
ChangeLog | 2 ++
agents/plugins/mk_postgres | 2 +-
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2abdce6..38056c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
1.2.1i4:
Checks & Agents:
* Linux Agent, mk_postgres: Supporting pgsql and postgres as user
+ * Linux Agent, mk_postgres: Fixed database stats query to be compatible
+ with more versions of postgres
Multisite:
* Implemented LDAP integration of Multisite. You can now authenticate your
diff --git a/agents/plugins/mk_postgres b/agents/plugins/mk_postgres
index adeb761..d98e431 100755
--- a/agents/plugins/mk_postgres
+++ b/agents/plugins/mk_postgres
@@ -13,5 +13,5 @@ echo '<<<postgres_sessions>>>'
echo "select current_query = '<IDLE>', count(*) from pg_stat_activity group by (current_query = '<IDLE>');" | su - $USER -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;' \
+echo 'select *, pg_database_size(datname) as "datsize" from pg_stat_database;' \
| su - $USER -c "psql -d postgres -A -F';'" | sed '$d'
Module: check_mk
Branch: master
Commit: c54bdc75784eda81ff0465abcc56f00de863b33b
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c54bdc75784eda…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Nov 21 16:42:08 2012 +0100
Linux Agent, mk_postgres: Supporting pgsql and postgres as user
---
ChangeLog | 3 +++
agents/plugins/mk_postgres | 21 ++++++++++++++-------
2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 07a633f..c977b00 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
1.2.1i4:
+ Checks & Agents:
+ * Linux Agent, mk_postgres: Supporting pgsql and postgres as user
+
Multisite:
* Implemented LDAP integration of Multisite. You can now authenticate your
users using the form based authentication with LDAP. It is also possible
diff --git a/agents/plugins/mk_postgres b/agents/plugins/mk_postgres
index 6667aab..adeb761 100755
--- a/agents/plugins/mk_postgres
+++ b/agents/plugins/mk_postgres
@@ -1,10 +1,17 @@
#!/bin/sh
-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 - 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'
+# Try to detect the postgres user
+if id pgsql >/dev/null 2>&1; then
+ USER=pgsql
+elif id postgres >/dev/null 2>&1; then
+ USER=postgres
+else
+ exit 0
fi
+
+echo '<<<postgres_sessions>>>'
+echo "select current_query = '<IDLE>', count(*) from pg_stat_activity group by (current_query = '<IDLE>');" | su - $USER -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 - $USER -c "psql -d postgres -A -F';'" | sed '$d'
Module: check_mk
Branch: master
Commit: dee64aaa6326b24584eac391fd857f53b91b255a
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=dee64aaa6326b2…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Nov 21 16:34:04 2012 +0100
New configuration check_periods
---
ChangeLog | 2 +
modules/check_mk.py | 22 +++++++++++++++++++-
modules/check_mk_base.py | 31 ++++++++++++++++++++++++++++
modules/notify.py | 18 ----------------
web/plugins/wato/check_mk_configuration.py | 10 ++++++++-
5 files changed, 63 insertions(+), 20 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b21b0a1..a506f70 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
1.2.1i3:
Core:
* added HOST/SERVICEPROBLEMID to notification macros
+ * New configuration check_periods for limiting execution of
+ Check_MK checks to a certain time period.
Checks & Agents:
* Windows agent: persist offsets for logfile monitoring
diff --git a/modules/check_mk.py b/modules/check_mk.py
index ea3131a..122389d 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -316,6 +316,7 @@ donation_command = 'mail -r checkmk(a)yoursite.de -s "Host do
scanparent_hosts = [ ( ALL_HOSTS ) ]
host_attributes = {} # needed by WATO, ignored by Check_MK
ping_levels = [] # special parameters for host/PING check_command
+check_periods = []
# global variables used to cache temporary values (not needed in check_mk_base)
ip_to_hostname_cache = None
@@ -676,6 +677,17 @@ def is_snmpv2c_host(hostname):
def is_usewalk_host(hostname):
return in_binary_hostlist(hostname, usewalk_hosts)
+def check_period_of(hostname, service):
+ periods = service_extra_conf(hostname, service, check_periods)
+ if periods:
+ period = periods[0]
+ if period == "24X7":
+ return None
+ else:
+ return period
+ else:
+ return None
+
def get_single_oid(hostname, ipaddress, oid):
# New in Check_MK 1.1.11: oid can end with ".*". In that case
# we do a snmpgetnext and try to find an OID with the prefix
@@ -2627,7 +2639,7 @@ no_inventory_possible = None
'snmpwalks_dir', 'check_mk_basedir', 'nagios_user',
'www_group', 'cluster_max_cachefile_age', 'check_max_cachefile_age',
'simulation_mode', 'agent_simulator', 'aggregate_check_mk', 'debug_log',
- 'check_mk_perfdata_with_times'
+ 'check_mk_perfdata_with_times', 'livestatus_unix_socket',
]:
output.write("%s = %r\n" % (var, globals()[var]))
@@ -2640,15 +2652,23 @@ no_inventory_possible = None
need_snmp_module = False
needed_check_types = set([])
needed_sections = set([])
+ service_timeperiods = {}
for check_type, item, param, descr, aggr in check_table:
if check_type not in check_info:
sys.stderr.write('Warning: Ignoring missing check %s.\n' % check_type)
continue
+ period = check_period_of(hostname, descr)
+ if period:
+ service_timeperiods[descr] = period
+
needed_sections.add(check_type.split(".")[0])
needed_check_types.add(check_type)
if check_uses_snmp(check_type):
need_snmp_module = True
+ output.write("precompiled_service_timeperiods = %r\n" % service_timeperiods)
+ output.write("def check_period_of(hostname, service):\n return precompiled_service_timeperiods.get(service)\n\n")
+
if need_snmp_module:
output.write(stripped_python_file(modules_dir + "/snmp.py"))
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index e46b2e5..43520ca 100755
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -831,6 +831,17 @@ def do_all_checks_on_host(hostname, ipaddress, only_check_types = None):
if only_check_types != None and checkname not in only_check_types:
continue
+ # Skip checks that are not in their check period
+ period = check_period_of(hostname, description)
+ if period and not check_timeperiod(period):
+ if opt_debug:
+ sys.stderr.write("Skipping service %s: currently not in timeperiod %s.\n" %
+ (description, period))
+ continue
+ elif period and opt_debug:
+ sys.stderr.write("Service %s: timeperiod %s is currently active.\n" %
+ (description, period))
+
# In case of a precompiled check table info is the aggrated
# service name. In the non-precompiled version there are the dependencies
if type(info) == str:
@@ -1210,3 +1221,23 @@ def get_age_human_readable(secs):
# in command definitions as $ARG1$)
def quote_shell_string(s):
return "'" + s.replace("'", "'\"'\"'") + "'"
+
+
+# Check if a timeperiod is currently active. We have no other way than
+# doing a Livestatus query. This is not really nice, but if you have a better
+# idea, please tell me...
+g_inactive_timerperiods = None
+def check_timeperiod(timeperiod):
+ global g_inactive_timerperiods
+ # Let exceptions happen, they will be handled upstream.
+ if g_inactive_timerperiods == None:
+ import socket
+ s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+ s.connect(livestatus_unix_socket)
+ # We just get the currently inactive timeperiods. All others
+ # (also non-existing) are considered to be active
+ s.send("GET timeperiods\nColumns:name\nFilter: in = 0\n")
+ s.shutdown(socket.SHUT_WR)
+ g_inactive_timerperiods = s.recv(10000000).splitlines()
+ return timeperiod not in g_inactive_timerperiods
+
diff --git a/modules/notify.py b/modules/notify.py
index e1ce824..a258034 100644
--- a/modules/notify.py
+++ b/modules/notify.py
@@ -275,24 +275,6 @@ def call_notification_script(plugin, parameters):
-# Check if a timeperiod is currently active. We have no other way than
-# doing a Livestatus query. This is not really nice, but if you have a better
-# idea, please tell me...
-g_inactive_timerperiods = None
-def check_timeperiod(timeperiod):
- global g_inactive_timerperiods
- # Let exceptions happen, they will be handled upstream.
- if g_inactive_timerperiods == None:
- import socket
- s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
- s.connect(livestatus_unix_socket)
- # We just get the currently inactive timeperiods. All others
- # (also non-existing) are considered to be active
- s.send("GET timeperiods\nColumns:name\nFilter: in = 0\n")
- s.shutdown(socket.SHUT_WR)
- g_inactive_timerperiods = s.recv(10000000).splitlines()
- return timeperiod not in g_inactive_timerperiods
-
def check_notification_type(context, host_events, service_events):
notification_type = context["NOTIFICATIONTYPE"]
diff --git a/web/plugins/wato/check_mk_configuration.py b/web/plugins/wato/check_mk_configuration.py
index 98a0326..a7ca00c 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -716,7 +716,7 @@ register_rule(group,
register_rule(group,
"extra_service_conf:check_period",
TimeperiodSelection(
- title = _("Check period for services"),
+ title = _("Check period for active services"),
help = _("If you specify a notification period for a service then active checks "
"of that service will only be done in that period. Please note, that the "
"checks driven by Check_MK are passive checks and are not affected by this "
@@ -724,6 +724,14 @@ register_rule(group,
itemtype = "service")
register_rule(group,
+ "check_periods",
+ TimeperiodSelection(
+ title = _("Check period for passive Check_MK services"),
+ help = _("If you specify a notification period for a Check_MK service then "
+ "results will be processed only within this period.")),
+ itemtype = "service")
+
+register_rule(group,
"extra_service_conf:process_perf_data",
DropdownChoice(
title = _("Enable/disable processing of perfdata for services"),