forked from ungleich-public/cdist
add support for new check types
Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
parent
6944998a19
commit
ce26deb706
3 changed files with 61 additions and 21 deletions
|
@ -20,18 +20,17 @@ None.
|
||||||
|
|
||||||
OPTIONAL PARAMETERS
|
OPTIONAL PARAMETERS
|
||||||
-------------------
|
-------------------
|
||||||
interval
|
docker-container-id
|
||||||
the interval in which the script given with --script should be run
|
the id of the docker container to run
|
||||||
|
|
||||||
script
|
http
|
||||||
the shell command to run every --interval
|
the url to check
|
||||||
|
|
||||||
ttl
|
|
||||||
how long a check is considered healthy without being updated through the
|
|
||||||
HTTP interfave
|
|
||||||
|
|
||||||
id
|
id
|
||||||
Defaults to --name
|
The id of this check.
|
||||||
|
|
||||||
|
interval
|
||||||
|
the interval in which the check should run
|
||||||
|
|
||||||
name
|
name
|
||||||
The name of this check. Defaults to __object_id
|
The name of this check. Defaults to __object_id
|
||||||
|
@ -39,9 +38,34 @@ name
|
||||||
notes
|
notes
|
||||||
human readable description
|
human readable description
|
||||||
|
|
||||||
|
script
|
||||||
|
the shell command to run
|
||||||
|
|
||||||
|
service-id
|
||||||
|
the id of the service this check is bound to
|
||||||
|
|
||||||
|
shell
|
||||||
|
the shell to run inside the docker container
|
||||||
|
|
||||||
state
|
state
|
||||||
if this check is 'present' or 'absent'. Defaults to 'present'.
|
if this check is 'present' or 'absent'. Defaults to 'present'.
|
||||||
|
|
||||||
|
status
|
||||||
|
specify the initial state of this health check
|
||||||
|
|
||||||
|
tcp
|
||||||
|
the host and port to check
|
||||||
|
|
||||||
|
timeout
|
||||||
|
after how long to timeout checks which take to long
|
||||||
|
|
||||||
|
token
|
||||||
|
ACL token to use for interacting with the catalog
|
||||||
|
|
||||||
|
ttl
|
||||||
|
how long a TTL check is considered healthy without being updated through the
|
||||||
|
HTTP interface
|
||||||
|
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
--------
|
--------
|
||||||
|
@ -67,5 +91,5 @@ SEE ALSO
|
||||||
|
|
||||||
COPYING
|
COPYING
|
||||||
-------
|
-------
|
||||||
Copyright \(C) 2015 Steven Armstrong. Free use of this software is
|
Copyright \(C) 2015-2016 Steven Armstrong. Free use of this software is
|
||||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# 2015 Steven Armstrong (steven-cdist at armstrong.cc)
|
# 2015-2016 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -24,12 +24,24 @@ conf_file="check_${name}.json"
|
||||||
state="$(cat "$__object/parameter/state")"
|
state="$(cat "$__object/parameter/state")"
|
||||||
|
|
||||||
# Sanity checks
|
# Sanity checks
|
||||||
if [ -f "$__object/parameter/script" -a -f "$__object/parameter/ttl" ]; then
|
if [ -f "$__object/parameter/ttl" ]; then
|
||||||
echo "Use either --script together with --interval OR --ttl, but not both" >&2
|
for conflicts_ttl in 'docker-container-id' 'http' 'script' 'tcp' 'timeout'; do
|
||||||
exit 1
|
if [ -f "$__object/parameter/${conflicts_ttl}" ]; then
|
||||||
|
echo "Can not use --ttl together with --${conflicts_ttl}." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
if [ -f "$__object/parameter/script" -a ! -f "$__object/parameter/interval" ]; then
|
if [ ! -f "$__object/parameter/interval" ]; then
|
||||||
echo "When using --script you must also define --interval" >&2
|
for requires_interval in 'docker-id' 'http' 'script' 'tcp'; do
|
||||||
|
if [ -f "$__object/parameter/${requires_interval}" ]; then
|
||||||
|
echo "When using --${requires_interval} you must also define --interval." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
if [ -f "$__object/parameter/docker-container-id" -a ! -f "$__object/parameter/script" ]; then
|
||||||
|
echo "When using --docker-container-id you must also define --script." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -40,11 +52,7 @@ printf ' "check": {\n'
|
||||||
printf ' "name": "%s"\n' "$name"
|
printf ' "name": "%s"\n' "$name"
|
||||||
for param in $(ls "$__object/parameter/"); do
|
for param in $(ls "$__object/parameter/"); do
|
||||||
case "$param" in
|
case "$param" in
|
||||||
state|name|interval) continue ;;
|
state|name) continue ;;
|
||||||
script)
|
|
||||||
printf ' ,"script": "%s"\n' "$(cat "$__object/parameter/script")"
|
|
||||||
printf ' ,"interval": "%s"\n' "$(cat "$__object/parameter/interval")"
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
key="$(echo "$param" | tr '-' '_')"
|
key="$(echo "$param" | tr '-' '_')"
|
||||||
printf ' ,"%s": "%s"\n' "$key" "$(cat "$__object/parameter/$param")"
|
printf ' ,"%s": "%s"\n' "$key" "$(cat "$__object/parameter/$param")"
|
||||||
|
|
|
@ -1,7 +1,15 @@
|
||||||
|
docker-container-id
|
||||||
|
http
|
||||||
id
|
id
|
||||||
interval
|
interval
|
||||||
name
|
name
|
||||||
notes
|
notes
|
||||||
script
|
script
|
||||||
|
service-id
|
||||||
|
shell
|
||||||
state
|
state
|
||||||
|
status
|
||||||
|
tcp
|
||||||
|
timeout
|
||||||
|
token
|
||||||
ttl
|
ttl
|
||||||
|
|
Loading…
Reference in a new issue