Module: check_mk
Branch: master
Commit: 18b269f2af45cd48d2284f96a20773c1521169c5
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=18b269f2af45cd…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Nov 19 11:06:50 2014 +0100
Updated bug entries #2226
---
.bugs/2226 | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/.bugs/2226 b/.bugs/2226
new file mode 100644
index 0000000..7dd552e
--- /dev/null
+++ b/.bugs/2226
@@ -0,0 +1,12 @@
+Title: Remove update-alternatives stuff on Debuntu packages
+Component: core
+State: open
+Date: 2014-11-19 11:04:56
+Targetversion: 1.2.5i1
+Class: nastiness
+
+Currently the *.deb packages use the alternatives-mechanism in order to
+select the current default version and for handling the symlink of /usr/bin/omd.
+Remove this and use the same mechanism as with RPM. Our deb packages anyway
+can never adhere to the Debian package guidelines. So better make sure that
+they exactly behave like on rpm based systems.
Module: check_mk
Branch: master
Commit: 20257385f74b982a2778ddbe0a1d0dd506591853
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=20257385f74b98…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Nov 19 10:43:26 2014 +0100
#1504 WATO makes host tag and group information available for NagVis
NagVis can now (till version 1.8rc1) handle Check_MK's host tag and tag group information.
These information can be added to the hover menus of the NagVis objects.
WATO exports the host tag and tag group definitions to a PHP file which is then read by
NagVis to gather the needed information. The PHP file is located at var/check_mk/wato/php-api/hosttags.php
in OMD environments.
---
.werks/1504 | 14 ++++++
ChangeLog | 1 +
web/htdocs/wato.py | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 137 insertions(+)
diff --git a/.werks/1504 b/.werks/1504
new file mode 100644
index 0000000..af52a89
--- /dev/null
+++ b/.werks/1504
@@ -0,0 +1,14 @@
+Title: WATO makes host tag and group information available for NagVis
+Level: 1
+Component: wato
+Compatible: compat
+Version: 1.2.5i7
+Date: 1416390031
+Class: feature
+
+NagVis can now (till version 1.8rc1) handle Check_MK's host tag and tag group information.
+These information can be added to the hover menus of the NagVis objects.
+
+WATO exports the host tag and tag group definitions to a PHP file which is then read by
+NagVis to gather the needed information. The PHP file is located at var/check_mk/wato/php-api/hosttags.php
+in OMD environments.
diff --git a/ChangeLog b/ChangeLog
index f80562c..6c2e509 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -60,6 +60,7 @@
* 1170 Added buttons to move rules to top/bottom of the list to ruleset edit dialog
* 1489 Added iCalendar import for generating timeperiods e.g. for holidays...
* 1495 Most WATO tables can now be sorted (where useful)...
+ * 1504 WATO makes host tag and group information available for NagVis...
* 1165 FIX: Fixed exception in service discovery of logwatch event console forwarding checks...
* 1490 FIX: Timperiod excludes can now even be configured when creating a timeperiod...
* 1491 FIX: Fixed bug in dynamic lists where removing an item was not always possible...
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index c56d451..432691f 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -123,6 +123,7 @@ sites_mk = defaults.default_config_dir + "/multisite.d/sites.mk"
var_dir = defaults.var_dir + "/wato/"
log_dir = var_dir + "log/"
snapshot_dir = var_dir + "snapshots/"
+php_api_dir = var_dir + "php-api/"
repstatus_file = var_dir + "replication_status.mk"
@@ -13080,6 +13081,126 @@ def show_localization_hint():
html.message("<sup>*</sup>" + _("These texts may be localized depending on the users' "
"language. You can configure the localizations <a href=\"%s\">in the global settings</a>.") % url)
+def format_php(data, lvl = 1):
+ s = ''
+ if isinstance(data, tuple) or isinstance(data, list):
+ s += 'array(\n'
+ for item in data:
+ s += ' ' * lvl + format_php(item, lvl + 1) + ',\n'
+ s += ' ' * (lvl - 1) + ')'
+ elif isinstance(data, dict):
+ s += 'array(\n'
+ for key, val in data.iteritems():
+ s += ' ' * lvl + format_php(key, lvl + 1) + ' => ' + format_php(val, lvl + 1) + ',\n'
+ s += ' ' * (lvl - 1) + ')'
+ elif isinstance(data, str):
+ s += '\'%s\'' % data.replace('\'', '\\\'')
+ elif isinstance(data, unicode):
+ s += '\'%s\'' % data.encode('utf-8').replace('\'', '\\\'')
+ elif isinstance(data, bool):
+ s += data and 'true' or 'false'
+ elif data is None:
+ s += 'null'
+ else:
+ s += str(data)
+
+ return s
+
+# Creates a includable PHP file which provides some functions which
+# can be used by the calling program, for example NagVis. It declares
+# the following API:
+#
+# taggroup_title(group_id)
+# Returns the title of a WATO tag group
+#
+# taggroup_choice(group_id, list_of_object_tags)
+# Returns either
+# false: When taggroup does not exist in current config
+# null: When no choice can be found for the given taggroup
+# array(tag, title): When a tag of the taggroup
+#
+# all_taggroup_choices(object_tags):
+# Returns an array of elements which use the tag group id as key
+# and have an assiciative array as value, where 'title' contains
+# the tag group title and the value contains the value returned by
+# taggroup_choice() for this tag group.
+#
+def export_hosttags(hosttags, auxtags):
+ path = php_api_dir + '/hosttags.php'
+ make_nagios_directory(php_api_dir)
+
+ # need an extra lock file, since we move the auth.php.tmp file later
+ # to auth.php. This move is needed for not having loaded incomplete
+ # files into php.
+ tempfile = path + '.tmp'
+ lockfile = path + '.state'
+ file(lockfile, 'a')
+ aquire_lock(lockfile)
+
+ # Transform WATO internal data structures into easier usable ones
+ hosttags_dict = {}
+ for id, title, choices in hosttags:
+ tags = {}
+ for tag_id, tag_title, auxtags in choices:
+ tags[tag_id] = tag_title, auxtags
+ topic, title = parse_hosttag_title(title)
+ hosttags_dict[id] = topic, title, tags
+ auxtags_dict = dict(auxtags)
+
+ # First write a temp file and then do a move to prevent syntax errors
+ # when reading half written files during creating that new file
+ file(tempfile, 'w').write('''<?php
+// Created by WATO
+global $mk_hosttags, $mk_auxtags;
+$mk_hosttags = %s;
+$mk_auxtags = %s;
+
+function taggroup_title($group_id) {
+ global $mk_hosttags;
+ if (isset($mk_hosttags[$group_id]))
+ return $mk_hosttags[$group_id][0];
+ else
+ return $taggroup;
+}
+
+function taggroup_choice($group_id, $object_tags) {
+ global $mk_hosttags;
+ if (!isset($mk_hosttags[$group_id]))
+ return false;
+ foreach ($object_tags AS $tag) {
+ if (isset($mk_hosttags[$group_id][2][$tag])) {
+ // Found a match of the objects tags with the taggroup
+ // now return an array of the matched tag and its alias
+ return array($tag, $mk_hosttags[$group_id][2][$tag][0]);
+ }
+ }
+ // no match found. Test whether or not a "None" choice is allowed
+ if (isset($mk_hosttags[$group_id][2][null]))
+ return array(null, $mk_hosttags[$group_id][2][null][0]);
+ else
+ return null; // no match found
+}
+
+function all_taggroup_choices($object_tags) {
+ global $mk_hosttags;
+ $choices = array();
+ foreach ($mk_hosttags AS $group_id => $group) {
+ $choices[$group_id] = array(
+ 'topic' => $group[0],
+ 'title' => $group[1],
+ 'value' => taggroup_choice($group_id, $object_tags),
+ );
+ }
+ return $choices;
+}
+
+?>
+''' % (format_php(hosttags_dict), format_php(auxtags_dict)))
+ # Now really replace the destination file
+ os.rename(tempfile, path)
+ release_lock(lockfile)
+ os.unlink(lockfile)
+
# Current specification for hosttag entries: One tag definition is stored
# as tuple of at least three elements. The elements are used as follows:
# taggroup_id, group_title, list_of_choices, depends_on_tags, depends_on_roles, editable
@@ -13112,6 +13233,7 @@ def save_hosttags(hosttags, auxtags):
out.write("# Written by WATO\n# encoding: utf-8\n\n")
out.write("wato_host_tags += \\\n%s\n\n" % pprint.pformat(hosttags))
out.write("wato_aux_tags += \\\n%s\n" % pprint.pformat(auxtags))
+ export_hosttags(hosttags, auxtags)
# Handle renaming and deletion of host tags: find affected
# hosts, folders and rules. Remove or fix those rules according
Module: check_mk
Branch: master
Commit: 44dec50075fe2f78fb48afbf5b65821c5486b5ee
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=44dec50075fe2f…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Nov 18 15:13:17 2014 +0100
#1503 FIX Fixed monitoring of multiple SAP instances with one mk_sap plugin
When monitoring multiple SAP instances from one host by configuring
multiple instances in the sap.cfg, the monitoring of all following
instances was skipped when one single instance had connection
problems.
---
.werks/1503 | 14 ++++++++++++++
ChangeLog | 1 +
agents/plugins/mk_sap | 21 ++++++++++-----------
3 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/.werks/1503 b/.werks/1503
new file mode 100644
index 0000000..061ba8d
--- /dev/null
+++ b/.werks/1503
@@ -0,0 +1,14 @@
+Title: Fixed monitoring of multiple SAP instances with one mk_sap plugin
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.5i7
+Date: 1416319927
+
+When monitoring multiple SAP instances from one host by configuring
+multiple instances in the sap.cfg, the monitoring of all following
+instances was skipped when one single instance had connection
+problems.
+
diff --git a/ChangeLog b/ChangeLog
index c55d9c4..cd635e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -32,6 +32,7 @@
* 1437 FIX: veeam_jobs: fixed incorrect state for BackupSync job...
* 1511 FIX: oracle_jobs: avoid broken checks, make compatible with old version...
* 1513 FIX: Handle broken SNMP bulk walk implementation of Mikrotik Router firmware RouterOS v6.22...
+ * 1503 FIX: Fixed monitoring of multiple SAP instances with one mk_sap plugin...
Multisite:
* 1508 Allow input of plugin output and perfdata when faking check results...
diff --git a/agents/plugins/mk_sap b/agents/plugins/mk_sap
index 0ce9546..8f867df 100755
--- a/agents/plugins/mk_sap
+++ b/agents/plugins/mk_sap
@@ -221,7 +221,7 @@ def logout():
'INTERFACE': 'XAL',
})
-def mon_list( cfg ):
+def mon_list(cfg):
f = query("BAPI_SYSTEM_MON_GETLIST", {
'EXTERNAL_USER_NAME': cfg['user'],
})
@@ -355,21 +355,16 @@ def process_alerts(cfg, logs, ms_name, mon_name, node, alerts):
-def connect(cfg):
+def check(cfg):
global conn
- try:
- conn = sapnwrfc.base.rfc_connect(cfg)
- except sapnwrfc.RFCCommunicationError, e:
- sys.stderr.write('ERROR: Unable to connect (%s)\n' % e)
- return
-
+ conn = sapnwrfc.base.rfc_connect(cfg)
login()
logs = {}
sap_data = {}
# This loop is used to collect all information from SAP
- for ms_name, mon_name in mon_list( cfg ):
+ for ms_name, mon_name in mon_list(cfg):
path = ms_name + SEPARATOR + mon_name
if not to_be_monitored(path, True):
continue
@@ -455,10 +450,14 @@ def connect(cfg):
logout()
conn.close()
+# It is possible to configure multiple SAP instances to monitor. Loop them all, but
+# do not terminate when one connection failed
for entry in cfg:
try:
- connect(entry)
+ check(entry)
+ except sapnwrfc.RFCCommunicationError, e:
+ sys.stderr.write('ERROR: Unable to connect (%s)\n' % e)
except:
- pass # Make sure that other entries are executed anyway
+ sys.stderr.write('ERROR: Unhandled exception (%s)\n' % e)
sys.exit(0)
Module: check_mk
Branch: master
Commit: 2a7b7594461b066d4d733ab77d5b825450cd4654
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2a7b7594461b06…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Tue Nov 18 14:17:12 2014 +0100
#1439 mk-job: now also available on solaris systems
Regarding the mk-job feature itself, you can find more information
<a href="https://mathias-kettner.de/checkmk_job.html">here</a>.
---
.werks/1439 | 12 +++++++
ChangeLog | 1 +
agents/check_mk_agent.solaris | 30 +++++++++++++++--
agents/mk-job.solaris | 73 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 114 insertions(+), 2 deletions(-)
diff --git a/.werks/1439 b/.werks/1439
new file mode 100644
index 0000000..51d4d76
--- /dev/null
+++ b/.werks/1439
@@ -0,0 +1,12 @@
+Title: mk-job: now also available on solaris systems
+Level: 1
+Component: core
+Compatible: compat
+Version: 1.2.5i7
+Date: 1416315864
+Class: feature
+
+Regarding the mk-job feature itself, you can find more information
+<a href="https://mathias-kettner.de/checkmk_job.html">here</a>.
+
+
diff --git a/ChangeLog b/ChangeLog
index 3398a48..d32b19d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
1.2.5i7:
Core & Setup:
+ * 1439 mk-job: now also available on solaris systems...
* 1483 FIX: Savely replace illegal vertical bars in check plugin output...
* 1431 FIX: windows_agent: fixed error on parsing unicode formatted logfiles...
diff --git a/agents/check_mk_agent.solaris b/agents/check_mk_agent.solaris
index b5babc3..e8dac81 100755
--- a/agents/check_mk_agent.solaris
+++ b/agents/check_mk_agent.solaris
@@ -6,7 +6,7 @@
# | | |___| | | | __/ (__| < | | | | . \ |
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
# | |
-# | Copyright Mathias Kettner 2014 mk(a)mathias-kettner.de |
+# | Copyright Mathias Kettner 2013 mk(a)mathias-kettner.de |
# +------------------------------------------------------------------+
#
# This file is part of Check_MK.
@@ -86,7 +86,7 @@ function run_cached () {
# Cache file outdated and new job not yet running? Start it
if [ -z "$USE_CACHEFILE" -a ! -e "$CACHEFILE.new" ] ; then
- echo "set -o noclobber ; exec > \"$CACHEFILE.new\" || exit 1 ; $CMDLINE && mv \"$CACHEFILE.new\" \"$CACHEFILE\" || rm -f \"$CACHEFILE\" \"$CACHEFILE.new\"" | nohup bash 2>/dev/null &
+ echo "set -o noclobber ; exec > $CACHEFILE.new || exit 1 ; $CMDLINE && mv $CACHEFILE.new $CACHEFILE || rm -f $CACHEFILE $CACHEFILE.new" | nohup bash 2>/dev/null &
fi
}
@@ -108,6 +108,32 @@ else
fi
+# Get statistics about monitored jobs. Below the job directory there
+# is a sub directory per user that ran a job. That directory must be
+# owned by the user so that a symlink or hardlink attack for reading
+# arbitrary files can be avoided.
+if pushd /var/lib/check_mk_agent/job >/dev/null; then
+ echo '<<<job>>>'
+ for username in *
+ do
+ if [ -d "$username" ] && cd "$username" ; then
+ count=$(su "$username" -c "ls -1 * | wc -l")
+
+ if [ "$count" -eq "1" ]; then
+ filename=$(su "$username" -c "ls -1 *")
+ echo "==> $filename <=="
+ fi
+
+ su "$username" -c "head -n1000 *"
+ cd ..
+ fi
+ done
+ popd > /dev/null
+fi
+
+
+
+
# Filesystem usage for UFS and VXFS
echo '<<<df>>>'
for fs in ufs vxfs samfs lofs
diff --git a/agents/mk-job.solaris b/agents/mk-job.solaris
new file mode 100644
index 0000000..f584b95
--- /dev/null
+++ b/agents/mk-job.solaris
@@ -0,0 +1,73 @@
+#!/bin/bash
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2013 mk(a)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-
+# ails. 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.
+
+help() {
+ echo "Usage: mk-job IDENT PROGRAM [ARGS...]"
+ echo ""
+ echo "Execute PROGRAM as subprocess while measuring performance information"
+ echo "about the running process and writing it to an output file. This file"
+ echo "can be monitored using Check_MK. The Check_MK Agent will forward the"
+ echo "information of all job files to the monitoring server."
+ echo ""
+ echo "This file is being distributed with the Check_MK Agent."
+}
+
+if [ $# -lt 2 ]; then
+ help >&2
+ exit 1
+fi
+
+MYSELF=$(id | awk -F')' '{print $1}' | awk -F'(' '{print $2}')
+OUTPUT_PATH=/var/lib/check_mk_agent/job/$MYSELF
+IDENT=$1
+shift
+
+if [ ! -d "$OUTPUT_PATH" ]; then
+ if [ "$MYSELF" = root ] ; then
+ mkdir -p "$OUTPUT_PATH"
+ else
+ echo "ERROR: Missing output directory $OUTPUT_PATH for non-root user '$MYSELF'." >&2
+ exit 1
+ fi
+fi
+
+if ! type $1 >/dev/null 2>&1; then
+ echo -e "ERROR: Cannot run $1. Command not found.\n" >&2
+ help >&2
+ exit 1
+fi
+
+
+echo "start_time $(perl -e 'print time')" > "$OUTPUT_PATH/$IDENT.running"
+
+info=$((/usr/bin/time -p sh -c "$@ 2>/dev/null 1>&2" 2>&1; echo $?) | sed -e 's/,/\./g');
+RC=$(echo $info | awk '{print $7}')
+
+(echo $info | awk '{print "exit_code "$7"\nreal_time "$2"\nuser_time "$4"\nsystem_time "$6""}') >> "$OUTPUT_PATH/$IDENT.running"
+(echo -e "reads 0\nwrites 0\nmax_res_kbytes 0\navg_mem_kbytes 0\ninvol_context_switches 0\nvol_context_switches 0";) >> "$OUTPUT_PATH/$IDENT.running"
+
+mv "$OUTPUT_PATH/$IDENT.running" "$OUTPUT_PATH/$IDENT"
+exit $RC
+