Skip to content

Commit

Permalink
Add timeout option for script command
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian L. committed May 14, 2024
1 parent fca0826 commit 86546c3
Show file tree
Hide file tree
Showing 2 changed files with 7 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
5 changes: 4 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 @@ -911,7 +914,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 86546c3

Please sign in to comment.