Skip to content

Commit

Permalink
Merge pull request #79 from brknkfr/script_timeout
Browse files Browse the repository at this point in the history
Add timeout option for script command
  • Loading branch information
Cyclenerd authored May 14, 2024
2 parents fca0826 + 41ca295 commit 369c4b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions config-example
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ MY_TIMEOUT="2"
MY_PING_TIMEOUT="4"
MY_PING_COUNT="2"

# Duration we wait for response (only script).
MY_SCRIPT_TIMEOUT="20"

# Route to host
MY_TRACEROUTE_HOST="1.1.1.1" # Cloudflare DNS
# Sets the number of probe packets per hop
Expand Down
6 changes: 5 additions & 1 deletion status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ MY_TIMEOUT=${MY_TIMEOUT:-"2"}
MY_PING_TIMEOUT=${MY_PING_TIMEOUT:-"4"}
MY_PING_COUNT=${MY_PING_COUNT:-"2"}

# Duration we wait for response (only script)
MY_SCRIPT_TIMEOUT=${MY_SCRIPT_TIMEOUT:-20}

# Route to host
MY_TRACEROUTE_HOST=${MY_TRACEROUTE_HOST:-"1.1.1.1"} # Cloudflare DNS
# Sets the number of probe packets per hop
Expand Down Expand Up @@ -210,6 +213,7 @@ debug_variables() {
echo "MY_TIMEOUT: $MY_TIMEOUT"
echo "MY_PING_TIMEOUT: $MY_PING_TIMEOUT"
echo "MY_PING_COUNT: $MY_PING_COUNT"
echo "MY_SCRIPT_TIMEOUT: $MY_SCRIPT_TIMEOUT"
echo "MY_TRACEROUTE_HOST: $MY_TRACEROUTE_HOST"
echo "MY_TRACEROUTE_NQUERIES: $MY_TRACEROUTE_NQUERIES"
echo
Expand Down Expand Up @@ -911,7 +915,7 @@ while IFS=';' read -r MY_COMMAND MY_HOSTNAME_STRING MY_PORT || [[ -n "$MY_COMMAN
else
cmd="$MY_HOSTNAME"
fi
($cmd &> /dev/null)
(timeout "$MY_SCRIPT_TIMEOUT" "$cmd" &> /dev/null)
case "$?" in
"0")
check_downtime "$MY_COMMAND" "$MY_HOSTNAME_STRING" "$MY_PORT"
Expand Down

0 comments on commit 369c4b6

Please sign in to comment.