Skip to content

Commit c864e7d

Browse files
committed
added tests/test_mesos.sh
1 parent 0633175 commit c864e7d

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

tests/test_mesos.sh

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/usr/bin/env bash
2+
# vim:ts=4:sts=4:sw=4:et
3+
#
4+
# Author: Hari Sekhon
5+
# Date: 2016-02-10 23:18:47 +0000 (Wed, 10 Feb 2016)
6+
#
7+
# https://github.com/harisekhon/nagios-plugins
8+
#
9+
# License: see accompanying Hari Sekhon LICENSE file
10+
#
11+
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback
12+
#
13+
# https://www.linkedin.com/in/harisekhon
14+
#
15+
16+
set -euo pipefail
17+
[ -n "${DEBUG:-}" ] && set -x
18+
19+
srcdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
20+
21+
cd "$srcdir/.."
22+
23+
. "$srcdir/utils.sh"
24+
25+
MESOS_HOST="${DOCKER_HOST:-${MESOS_HOST:-${HOST:-localhost}}}"
26+
MESOS_HOST="${MESOS_HOST##*/}"
27+
MESOS_HOST="${MESOS_HOST%%:*}"
28+
export MESOS_HOST
29+
echo "using docker address '$MESOS_HOST'"
30+
export MESOS_MASTER_PORT="${MESOS_MASTER_PORT:-5050}"
31+
export MESOS_WORKER_PORT="${MESOS_WORKER_PORT:-5051}"
32+
export MESOS_MASTER="$MESOS_HOST:$MESOS_MASTER_PORT"
33+
34+
export DOCKER_CONTAINER="nagios-plugins-mesos"
35+
36+
if ! which docker &>/dev/null; then
37+
echo 'WARNING: Docker not found, skipping mesos checks!!!'
38+
exit 0
39+
fi
40+
41+
startupwait=10
42+
[ -n "${TRAVIS:-}" ] && let startupwait+=20
43+
44+
hr
45+
echo "Setting up test Mesos container"
46+
hr
47+
# reuse container it's faster
48+
#docker rm -f "$DOCKER_CONTAINER" &>/dev/null
49+
#sleep 1
50+
if ! docker ps | tee /dev/stderr | grep -q "[[:space:]]$DOCKER_CONTAINER$"; then
51+
docker rm -f "$DOCKER_CONTAINER" &>/dev/null || :
52+
echo "Starting Docker Mesos test container"
53+
# need tty for sudo which mesos-start.sh local uses while ssh'ing localhost
54+
docker run -d -t --name "$DOCKER_CONTAINER" -p $MESOS_MASTER_PORT:$MESOS_MASTER_PORT -p $MESOS_WORKER_PORT:$MESOS_WORKER_PORT harisekhon/mesos
55+
echo "waiting $startupwait seconds for Mesos Master + Worker to become responsive..."
56+
sleep $startupwait
57+
else
58+
echo "Docker Mesos test container already running"
59+
fi
60+
61+
hr
62+
./check_mesos_activated_slaves.pl -v
63+
hr
64+
#./check_mesos_chronos_jobs.pl -v
65+
hr
66+
./check_mesos_deactivated_slaves.pl -v
67+
hr
68+
./check_mesos_master_health.pl -v
69+
hr
70+
./check_mesos_master_state.pl -v
71+
hr
72+
./check_mesos_metrics.pl -P 5050 -v
73+
hr
74+
./check_mesos_metrics.pl -P 5051 -v
75+
hr
76+
./check_mesos_master_metrics.pl -v
77+
hr
78+
./check_mesos_slave_metrics.pl -v
79+
hr
80+
# Not implemented yet
81+
#./check_mesos_registered_framework.py -v
82+
hr
83+
# Not implemented yet
84+
#./check_mesos_slave_container_statistics.pl -v
85+
hr
86+
./check_mesos_slave_state.pl
87+
hr
88+
echo
89+
echo -n "Deleting container "
90+
docker rm -f "$DOCKER_CONTAINER"
91+
echo; echo

0 commit comments

Comments
 (0)