Module: check_mk
Branch: master
Commit: 204a4094f165055b29c982fcf0d5363e4f84854a
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=204a4094f16505…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Oct 4 18:45:04 2017 +0200
windows agent chroot can now be acessed in parallel
When CHROOT_BUILD_DIR is set to a custom directory name when
calling the make-agent script, this will be used as mount point
to mount the current Check_MK base path into.
This makes it possible to use a single chroot for multiple
build jobs in parallel. This is needed for our build system.
Change-Id: Ibfe6a82041d8dede30d375347f81ad49aa19ad87
---
agents/windows/do-chroot | 14 +++++++++++---
agents/windows/make-agent | 4 +++-
agents/windows/make-chroot | 1 -
3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/agents/windows/do-chroot b/agents/windows/do-chroot
index eaef0cb..560e020 100755
--- a/agents/windows/do-chroot
+++ b/agents/windows/do-chroot
@@ -15,6 +15,10 @@ if [ -z $CHROOT_PATH ]; then
exit 1
fi
+if [ -z $CHROOT_BUILD_DIR ]; then
+ echo "ERROR: CHROOT_BUILD_DIR not set"
+ exit 1
+fi
if [ ! -e $CHROOT_PATH/proc/self ] ; then
mount -t proc proc $CHROOT_PATH/proc
@@ -28,8 +32,12 @@ if [ ! -e $CHROOT_PATH/dev/pts/ptmx ] ; then
mount -t devpts devpts $CHROOT_PATH/dev/pts 2>/dev/null || true
fi
-if [ ! -e $CHROOT_PATH/build/Makefile ] ; then
- mount -o bind $BASE $CHROOT_PATH/build
+if [ ! -e $CHROOT_PATH/$CHROOT_BUILD_DIR ]; then
+ mkdir $CHROOT_PATH/$CHROOT_BUILD_DIR
+fi
+
+if [ ! -e $CHROOT_PATH/$CHROOT_BUILD_DIR/Makefile ] ; then
+ mount -o bind $BASE $CHROOT_PATH/$CHROOT_BUILD_DIR
fi
if [ -n "$CMD" ] ; then
@@ -38,7 +46,7 @@ else
chroot $CHROOT_PATH /usr/bin/env CHROOTNAME=$CHROOTNAME bash -l
fi
-umount $CHROOT_PATH/build
+umount $CHROOT_PATH/$CHROOT_BUILD_DIR
umount $CHROOT_PATH/dev/pts
sleep 2
umount $CHROOT_PATH/dev
diff --git a/agents/windows/make-agent b/agents/windows/make-agent
index 2bf473e..124a6ad 100755
--- a/agents/windows/make-agent
+++ b/agents/windows/make-agent
@@ -21,6 +21,7 @@ base="$(dirname "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")")"
# May be set from external environment. Otherwise use chroot
# directory in agents/windows
export CHROOT_PATH=${CHROOT_PATH:-$base/agents/windows/chroot}
+export CHROOT_BUILD_DIR=${CHROOT_BUILD_DIR:-build}
setup() {
sudo apt-get install "${chroot_dependencies[@]}"
@@ -79,7 +80,8 @@ fi
ensure_chroot
# Pass remaining targets to make inside chroot.
-sudo CHROOT_PATH=$CHROOT_PATH ./do-chroot "cd build/agents/windows; make $targets"
+sudo CHROOT_PATH=$CHROOT_PATH CHROOT_BUILD_DIR=$CHROOT_BUILD_DIR \
+ ./do-chroot "cd $CHROOT_BUILD_DIR/agents/windows; make $targets"
# Some cleanup: chown build artifacts to the original user.
find . -maxdepth 1 -regextype egrep \
diff --git a/agents/windows/make-chroot b/agents/windows/make-chroot
index 25e3beb..d7bf81f 100755
--- a/agents/windows/make-chroot
+++ b/agents/windows/make-chroot
@@ -143,7 +143,6 @@ if [ ! -h $CHROOT_PATH/usr/bin/python ] ; then
cd -
fi
-mkdir $CHROOT_PATH/build
cp "$BASE/agents/windows/$VERSIONFILE" "$CHROOT_PATH/"
echo "+ CLEANING UP"
Module: check_mk
Branch: master
Commit: e7ae01ecf9bfce845dc4dac8e0936037b9f0b019
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e7ae01ecf9bfce…
Author: Jukka Aro <ja(a)mathias-kettner.de>
Date: Wed Oct 4 11:40:07 2017 +0200
Windows agent: do setup & chroot targets on demand
Change make-agent script to implicitly execute setup and chroot targets
if necessary, that is, if the chroot jail has not already been properly
set up or should be updated. Allow setup and chroot to be given as
explicit targets, possibly combined with explicit make targets within
chroot.
Change-Id: I4500828af52c0b6ba5f271d13506eac3a867c4e1
---
agents/windows/chroot_version | 1 +
agents/windows/make-agent | 77 ++++++++++++++++++++++++++++++-------------
agents/windows/make-chroot | 1 +
3 files changed, 56 insertions(+), 23 deletions(-)
diff --git a/agents/windows/chroot_version b/agents/windows/chroot_version
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/agents/windows/chroot_version
@@ -0,0 +1 @@
+0
diff --git a/agents/windows/make-agent b/agents/windows/make-agent
index 9b45984..4c646aa 100755
--- a/agents/windows/make-agent
+++ b/agents/windows/make-agent
@@ -5,46 +5,77 @@
# setup - install dependencies for chroot
# chroot - create a chroot for building Windows agent
# * - other targets passed to make within chroot, see Makefile
+#
+# Note: setup and chroot can be combined with explicit targets passed to make
+# inside chroot. However, giving setup or chroot without further targets does
+# *not* implicitly trigger default make target within chroot.
targets="$@" # no parameter -> default make target
setup_target=setup
chroot_target=chroot
+chroot_dependencies=(nsis lcab debootstrap debian-archive-keyring)
+versionfile=chroot_version
-check_no_of_targets() {
- if [ $1 != 1 ] ; then
- echo "You cannot combine $2 with other targets."
- exit 1
+base="$(dirname "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")")"
+mnt=$base/agents/windows/chroot
+
+setup() {
+ sudo apt-get install "${chroot_dependencies[@]}"
+}
+
+ensure_chroot() {
+ # Ensure that versionfile exists...
+ if [ ! -f "$mnt/$versionfile" ] ; then
+ echo "chroot version not found."
+ create=yes
+ # ... and it is up to date.
+ elif [ $(cat "$mnt/$versionfile") -ne $(cat "$base/agents/windows/$versionfile") ] ; then
+ echo "chroot is out of date."
+ create=yes
+ fi
+
+ if [ -z $create ] ; then
+ echo "chroot is up to date."
+ else
+ setup
+ sudo VERSIONFILE=$versionfile ./make-chroot
fi
}
-# setup target: install dependencies for chroot
+remove_target() {
+ targets=$(sed -e "s/$1//g" \
+ -e "s/^[[:blank:]]*//g" \
+ -e "s/[[:blank:]]*$//g" <<< "$targets")
+}
+
+if [ ! -f "$base/agents/windows/$versionfile" ] ; then
+ echo "Error: File $base/agents/windows/$versionfile not found."
+ echo "Is your Git repository up to date?"
+ exit 1
+fi
+
+# 1) setup target: install dependencies for chroot
if [[ " $targets " =~ " $setup_target " ]] ; then
- check_no_of_targets $# $setup_target
- sudo apt-get install \
- nsis \
- lcab \
- debootstrap \
- debian-archive-keyring
- exit
+ setup
+ remove_target $setup_target
fi
-# chroot target: create a chroot for building Windows agent
+# 2) chroot target: create a chroot for building Windows agent
if [[ " $targets " =~ " $chroot_target " ]] ; then
- check_no_of_targets $# $chroot_target
- sudo ./make-chroot
- exit
+ ensure_chroot
+ remove_target $chroot_target
fi
-# all other targets: assume chroot exists and pass targets to make inside chroot
+# If no other targets are left but originally there was at least one,
+# we did either setup or chroot -> we are done now (let us not do default make)
+[ -z "$targets" ] && [ $# != 0 ] && exit
-base="$(dirname "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")")"
-mnt=$base/agents/windows/chroot
+# 3) all other targets (including default target):
-if [ ! -d "$mnt/build" ] ; then
- echo "Did you forget to call '${BASH_SOURCE[0]} chroot' first?"
- exit 1
-fi
+# Ensure that chroot exists and is up to date.
+ensure_chroot
+# Pass remaining targets to make inside chroot.
sudo ./do-chroot "cd build/agents/windows; make $targets"
# Some cleanup: chown build artifacts to the original user.
diff --git a/agents/windows/make-chroot b/agents/windows/make-chroot
index f420455..f61586f 100755
--- a/agents/windows/make-chroot
+++ b/agents/windows/make-chroot
@@ -139,6 +139,7 @@ if [ ! -h $MNT/usr/bin/python ] ; then
fi
mkdir $MNT/build
+cp "$BASE/agents/windows/$VERSIONFILE" "$MNT/"
echo "+ CLEANING UP"
Module: check_mk
Branch: master
Commit: 015db5f7b4c2334b0915413e090764c732edc718
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=015db5f7b4c233…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Wed Oct 4 13:56:20 2017 +0200
5316 FIX cmciii.access: Fixed error state handling
If status is 'Closed' Check_MK reports OK,
if it is 'Open' check goes WARN, otherwise CRIT.
Change-Id: I6fce67eac1651b6abf379c0d3eeea73cf255f976
---
.werks/5316 | 12 ++++++++++++
checkman/cmciii.access | 4 ++--
checks/cmciii | 2 ++
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/.werks/5316 b/.werks/5316
new file mode 100644
index 0000000..eeb8500
--- /dev/null
+++ b/.werks/5316
@@ -0,0 +1,12 @@
+Title: cmciii.access: Fixed error state handling
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1507118033
+
+If status is 'Closed' Check_MK reports OK,
+if it is 'Open' check goes WARN, otherwise CRIT.
diff --git a/checkman/cmciii.access b/checkman/cmciii.access
index 434c1c6..7229099 100644
--- a/checkman/cmciii.access
+++ b/checkman/cmciii.access
@@ -9,8 +9,8 @@ description:
No limits are set in the check, since limits are configured in the
Rittal device itself. The state given by the Rittal device is
taken as the state of the check as follows:
- If the Rittal device returns {Closed}, the check is {OK}. Otherwise
- the check is {CRIT}.
+ If the Rittal device returns {Closed}, the check is {OK}, if it is
+ {Open} Check_MK reports WARN, otherwise {CRIT}.
item:
None
diff --git a/checks/cmciii b/checks/cmciii
index 2ef8ef6..db6adea 100644
--- a/checks/cmciii
+++ b/checks/cmciii
@@ -436,6 +436,8 @@ def check_cmciii_access(item, params, parsed):
if state_readable == "Closed":
state = 0
+ elif state_readable == "Open":
+ state = 1
else:
state = 2