[Pkg-nagios-changes] [pkg-check-mk] 02/02: upstream moved to using python for defaults
Matt Taggart
taggart at moszumanska.debian.org
Fri Aug 4 16:38:21 UTC 2017
This is an automated email from the git hooks/post-receive script.
taggart pushed a commit to branch master
in repository pkg-check-mk.
commit cf05efb62fabffed7756fb805cf6076ef0ce3c1a
Author: Matt Taggart <taggart at debian.org>
Date: Fri Aug 4 09:36:54 2017 -0700
upstream moved to using python for defaults
switch to having the config package install our own version of the
paths.py config file (this commit is the default, it will need adjusting)
---
debian/defaults.icinga | 54 -------------
debian/paths.py.icinga | 215 +++++++++++++++++++++++++++++++++++++++++++++++++
debian/rules | 13 +--
3 files changed, 222 insertions(+), 60 deletions(-)
diff --git a/debian/defaults.icinga b/debian/defaults.icinga
deleted file mode 100644
index 9740175..0000000
--- a/debian/defaults.icinga
+++ /dev/null
@@ -1,54 +0,0 @@
-# This file has been created during setup of check_mk at Thu Sep 24 12:57:08 PDT 2015.
-# Do not edit this file. Also do not try to override these settings
-# in main.mk since some of them are hardcoded into several files
-# during setup.
-#
-# If you need to change these settings, you have to re-run setup.sh
-# and enter new values when asked, or edit ~/.check_mk_setup.conf and
-# run ./setup.sh --yes.
-
-check_mk_version = '1.2.6p12'
-default_config_dir = '/etc/check_mk'
-check_mk_configdir = '/etc/check_mk/conf.d'
-share_dir = '/usr/share/check_mk'
-checks_dir = '/usr/share/check_mk/checks'
-notifications_dir = '/usr/share/check_mk/notifications'
-inventory_dir = '/usr/share/check_mk/inventory'
-check_manpages_dir = '/usr/share/check_mk/checks-man'
-modules_dir = '/usr/share/check_mk/modules'
-locale_dir = '/usr/share/check_mk/locale'
-agents_dir = '/usr/share/check_mk/agents'
-lib_dir = '/usr/lib/check_mk'
-var_dir = '/var/lib/check_mk'
-log_dir = '/var/lib/check_mk/log'
-snmpwalks_dir = '/var/lib/check_mk/snmpwalks'
-autochecksdir = '/var/lib/check_mk/autochecks'
-precompiled_hostchecks_dir = '/var/lib/check_mk/precompiled'
-counters_directory = '/var/lib/check_mk/counters'
-tcp_cache_dir = '/var/lib/check_mk/cache'
-tmp_dir = '/var/lib/check_mk/tmp'
-logwatch_dir = '/var/lib/check_mk/logwatch'
-nagios_objects_file = '/etc/icinga/objects/check_mk/check_mk_objects.cfg'
-rrd_path = '/var/lib/nagios/rrd'
-rrddcached_socket = '/tmp/rrdcached.sock'
-nagios_command_pipe_path = '/var/lib/icinga/rw/icinga.cmd'
-check_result_path = '/var/lib/icinga/spool/checkresults'
-nagios_status_file = '/var/lib/icinga/status.dat'
-nagios_conf_dir = '/etc/icinga/objects/check_mk'
-nagios_user = 'nagios'
-logwatch_notes_url = '/check_mk/logwatch.py?host=%s&file=%s'
-www_group = 'nagios'
-nagios_config_file = '/etc/icinga/icinga.cfg'
-nagios_startscript = '/etc/init.d/icinga'
-nagios_binary = '/usr/sbin/icinga'
-apache_config_dir = '/etc/apache2/conf.d'
-htpasswd_file = '/etc/icinga/htpasswd.users'
-nagios_auth_name = 'Nagios Access'
-web_dir = '/usr/share/check_mk/web'
-livestatus_unix_socket = '/var/lib/icinga/rw/live'
-livebackendsdir = '/usr/share/check_mk/livestatus'
-url_prefix = '/'
-pnp_url = '/pnp4nagios/'
-pnp_templates_dir = '/usr/share/check_mk/pnp-templates'
-doc_dir = '/usr/share/doc/check-mk-doc'
-check_mk_automation = 'sudo -u nagios /usr/bin/check_mk --automation'
diff --git a/debian/paths.py.icinga b/debian/paths.py.icinga
new file mode 100644
index 0000000..7092d45
--- /dev/null
+++ b/debian/paths.py.icinga
@@ -0,0 +1,215 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2016 mk at mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# tails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+"""This module serves the path structure of the Check_MK environment
+to all components of Check_MK."""
+
+import os
+
+from .exceptions import MKGeneralException
+
+# TODO: Clean this up one day by using the way recommended by gettext.
+# (See https://docs.python.org/2/library/gettext.html). For this we
+# need the path to the locale files here.
+try:
+ _
+except NameError:
+ _ = lambda x: x # Fake i18n when not available
+
+
+#
+# First declare the possible paths for the linters. Then set it within _set_paths()
+#
+
+# TODO: Add piggyback_dir and use it in code
+omd_root = None
+default_config_dir = None
+main_config_file = None
+final_config_file = None
+local_config_file = None
+check_mk_config_dir = None
+modules_dir = None
+var_dir = None
+log_dir = None
+autochecks_dir = None
+precompiled_hostchecks_dir= None
+snmpwalks_dir = None
+counters_dir = None
+tcp_cache_dir = None
+tmp_dir = None
+logwatch_dir = None
+nagios_objects_file = None
+nagios_command_pipe_path = None
+check_result_path = None
+nagios_status_file = None
+nagios_conf_dir = None
+nagios_config_file = None
+nagios_startscript = None
+nagios_binary = None
+apache_config_dir = None
+htpasswd_file = None
+livestatus_unix_socket = None
+pnp_rraconf_dir = None
+livebackendsdir = None
+
+share_dir = None
+checks_dir = None
+notifications_dir = None
+inventory_dir = None
+check_manpages_dir = None
+agents_dir = None
+mibs_dir = None
+web_dir = None
+pnp_templates_dir = None
+doc_dir = None
+locale_dir = None
+bin_dir = None
+lib_dir = None
+mib_dir = None
+
+# TODO: Add active_checks_dir and make it used in code
+local_share_dir = None
+local_checks_dir = None
+local_notifications_dir = None
+local_inventory_dir = None
+local_check_manpages_dir = None
+local_agents_dir = None
+local_mibs_dir = None
+local_web_dir = None
+local_pnp_templates_dir = None
+local_doc_dir = None
+local_locale_dir = None
+local_bin_dir = None
+local_lib_dir = None
+local_mib_dir = None
+
+
+def _set_paths():
+ omd_root = _omd_root()
+
+ globals().update({
+ "omd_root" : omd_root,
+ "default_config_dir" : os.path.join(omd_root, "etc/check_mk"),
+ "main_config_file" : os.path.join(omd_root, "etc/check_mk/main.mk"),
+ "final_config_file" : os.path.join(omd_root, "etc/check_mk/final.mk"),
+ "local_config_file" : os.path.join(omd_root, "etc/check_mk/local.mk"),
+ "check_mk_config_dir" : os.path.join(omd_root, "etc/check_mk/conf.d"),
+ "modules_dir" : os.path.join(omd_root, "share/check_mk/modules"),
+ "var_dir" : os.path.join(omd_root, "var/check_mk"),
+ "log_dir" : os.path.join(omd_root, "var/log"),
+ "autochecks_dir" : os.path.join(omd_root, "var/check_mk/autochecks"),
+ "precompiled_hostchecks_dir" : os.path.join(omd_root, "var/check_mk/precompiled"),
+ "snmpwalks_dir" : os.path.join(omd_root, "var/check_mk/snmpwalks"),
+ "counters_dir" : os.path.join(omd_root, "tmp/check_mk/counters"),
+ "tcp_cache_dir" : os.path.join(omd_root, "tmp/check_mk/cache"),
+ "tmp_dir" : os.path.join(omd_root, "tmp/check_mk"),
+ "logwatch_dir" : os.path.join(omd_root, "var/check_mk/logwatch"),
+ "nagios_startscript" : os.path.join(omd_root, "etc/init.d/core"),
+
+ # Switched via symlinks on icinga/nagios change
+ "nagios_conf_dir" : os.path.join(omd_root, "etc/nagios/conf.d"),
+ "nagios_objects_file" : os.path.join(omd_root, "etc/nagios/conf.d/check_mk_objects.cfg"),
+ "check_result_path" : os.path.join(omd_root, "tmp/nagios/checkresults"),
+ "nagios_status_file" : os.path.join(omd_root, "tmp/nagios/status.dat"),
+
+ "apache_config_dir" : os.path.join(omd_root, "etc/apache"),
+ "htpasswd_file" : os.path.join(omd_root, "etc/htpasswd"),
+ "livestatus_unix_socket" : os.path.join(omd_root, "tmp/run/live"),
+ "pnp_rraconf_dir" : os.path.join(omd_root, "share/check_mk/pnp-rraconf"),
+ "livebackendsdir" : os.path.join(omd_root, "share/check_mk/livestatus"),
+ })
+
+ _set_core_specific_paths()
+ _set_overridable_paths()
+ _set_overridable_paths(local=True)
+
+
+def _omd_root():
+ return os.environ.get("OMD_ROOT", "")
+ #try:
+ #except KeyError:
+ # raise MKGeneralException(_("OMD_ROOT environment variable not set. You can "
+ # "only execute this in an OMD site."))
+
+
+def _set_core_specific_paths():
+ omd_root = _omd_root()
+ core = _get_core_name()
+
+ if core == "icinga":
+ globals().update({
+ "nagios_binary" : os.path.join(omd_root, "bin/icinga"),
+ "nagios_config_file" : os.path.join(omd_root, "tmp/icinga/icinga.cfg"),
+ "nagios_command_pipe_path" : os.path.join(omd_root, "tmp/run/icinga.cmd"),
+ })
+ else:
+ globals().update({
+ "nagios_binary" : os.path.join(omd_root, "bin/nagios"),
+ "nagios_config_file" : os.path.join(omd_root, "tmp/nagios/nagios.cfg"),
+ "nagios_command_pipe_path" : os.path.join(omd_root, "tmp/run/nagios.cmd"),
+ })
+
+
+# TODO: Find a better way to determine the currently configured core.
+# For example generalize the etc/check_mk/conf.d/microcore.mk which is written by the CORE
+# hook -> Change the name to core.mk and write it for all configured cores.
+def _get_core_name():
+ try:
+ for l in open(os.path.join(omd_root, "etc/omd/site.conf")):
+ if l.startswith("CONFIG_CORE='"):
+ return l.split("'")[1]
+ except IOError, e:
+ # At least in test environment the file is not available. We only added this try/except for
+ # this case. This should better be solved in a cleaner way.
+ if e.errno == 2:
+ pass
+ else:
+ raise
+
+
+def _set_overridable_paths(local=False):
+ rel_base = "local" if local else ""
+ var_prefix = "local_" if local else ""
+
+ globals().update({
+ var_prefix+"share_dir" : os.path.join(omd_root, rel_base, "share/check_mk"),
+ var_prefix+"checks_dir" : os.path.join(omd_root, rel_base, "share/check_mk/checks"),
+ var_prefix+"notifications_dir" : os.path.join(omd_root, rel_base, "share/check_mk/notifications"),
+ var_prefix+"inventory_dir" : os.path.join(omd_root, rel_base, "share/check_mk/inventory"),
+ var_prefix+"check_manpages_dir" : os.path.join(omd_root, rel_base, "share/check_mk/checkman"),
+ var_prefix+"agents_dir" : os.path.join(omd_root, rel_base, "share/check_mk/agents"),
+ var_prefix+"mibs_dir" : os.path.join(omd_root, rel_base, "share/check_mk/mibs"),
+ var_prefix+"web_dir" : os.path.join(omd_root, rel_base, "share/check_mk/web"),
+ var_prefix+"pnp_templates_dir" : os.path.join(omd_root, rel_base, "share/check_mk/pnp-templates"),
+ var_prefix+"doc_dir" : os.path.join(omd_root, rel_base, "share/doc/check_mk"),
+ var_prefix+"locale_dir" : os.path.join(omd_root, rel_base, "share/check_mk/locale"),
+ var_prefix+"bin_dir" : os.path.join(omd_root, rel_base, "bin"),
+ var_prefix+"lib_dir" : os.path.join(omd_root, rel_base, "lib"),
+ var_prefix+"mib_dir" : os.path.join(omd_root, rel_base, "share/snmp/mibs"),
+ })
+
+
+_set_paths()
diff --git a/debian/rules b/debian/rules
index 23eedca..a273350 100755
--- a/debian/rules
+++ b/debian/rules
@@ -88,12 +88,13 @@ install: build
#rm -rf debian/tmp/usr/lib/python2.7/dist-packages/cmk_base/*.pyc
#rm -rf debian/tmp/usr/lib/python2.7/dist-packages/cmk/*.pyc
## config files
- # We need 2 different "defaults" files for Icinga and Nagios3
- rm debian/tmp/usr/share/check_mk/modules/defaults
- rm debian/tmp/usr/share/check_mk/web/htdocs/defaults.py
- mkdir -p debian/check-mk-config-icinga/usr/share/check_mk/modules/
- cp debian/defaults.icinga debian/check-mk-config-icinga/usr/share/check_mk/modules/defaults
- # Switch the apache config to reference icinga
+ # We need a "paths.py" file with edited paths for FHS and monitoring
+ # system changes
+ # remove the provided one
+ rm debian/check-mk-common/usr/share/check_mk/cmk/paths.py
+ # copy an icinga specific one into the icinga config package
+ cp debian/paths.py.icinga debian/check-mk-config-icinga/usr/share/check_mk/cmk/paths.py
+ # provide a safe apache config that references icinga
mkdir -p debian/check-mk-config-icinga/etc/apache2/conf-available/
cp debian/apache.icinga debian/check-mk-config-icinga/etc/apache2/conf-available/check-mk-multisite.conf
# Adjust path names
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-nagios/pkg-check-mk.git
More information about the Pkg-nagios-changes
mailing list