mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-02-12 10:31:51 +00:00
Add option enable/disable check of server is reachable by the connection
This commit is contained in:
parent
863425d622
commit
93ec83c111
5 changed files with 22 additions and 7 deletions
|
@ -95,7 +95,12 @@ return view.extend({
|
|||
}
|
||||
*/
|
||||
o = s.option(form.Flag, 'server_http_test', _('Server http test'),
|
||||
_('Check if connection work with http by sending a request to server'));
|
||||
_('Check if connection work with http by sending a request to server API'));
|
||||
o.rmempty = false;
|
||||
o.modalonly = true;
|
||||
|
||||
o = s.option(form.Flag, 'server_test', _('Server test'),
|
||||
_('Check if connection work by sending a ping or http request to server over all interfaces, failed if only current interface is not able to.'));
|
||||
o.rmempty = false;
|
||||
o.modalonly = true;
|
||||
|
||||
|
|
|
@ -510,7 +510,7 @@ while true; do
|
|||
OMR_TRACKER_STATUS="OK"
|
||||
break
|
||||
fi
|
||||
elif [ "$serverip_ping" = false ] && [ "$OMR_TRACKER_STATUS" = "OK" ]; then
|
||||
elif [ "$serverip_ping" = false ] && [ "$OMR_TRACKER_STATUS" = "OK" ] && [ "$OMR_TRACKER_SERVER_TEST" = "1" ]; then
|
||||
if [ "$OMR_TRACKER_TYPE" = "ping" ]; then
|
||||
_ping_server_all
|
||||
fi
|
||||
|
@ -627,7 +627,7 @@ while true; do
|
|||
OMR_TRACKER_STATUS="OK"
|
||||
break
|
||||
fi
|
||||
elif [ "$serverip_ping" = false ] && [ "$OMR_TRACKER_STATUS" = "OK" ]; then
|
||||
elif [ "$serverip_ping" = false ] && [ "$OMR_TRACKER_STATUS" = "OK" ] && [ "$OMR_TRACKER_SERVER_TEST" = "1" ]; then
|
||||
if [ "$OMR_TRACKER_TYPE" = "ping" ]; then
|
||||
_ping_server_all
|
||||
fi
|
||||
|
@ -637,7 +637,7 @@ while true; do
|
|||
if [ "$server_ping" != false ] && [ "$servers" = true ]; then
|
||||
OMR_TRACKER_STATUS_MSG="$OMR_TRACKER_STATUS_MSG No answer from server"
|
||||
OMR_TRACKER_STATUS="ERROR"
|
||||
break
|
||||
#break
|
||||
fi
|
||||
fi
|
||||
[ "$OMR_TRACKER_STATUS" = "OK" ] && break
|
||||
|
|
|
@ -29,6 +29,7 @@ config defaults 'defaults'
|
|||
option type 'ping'
|
||||
option wait_test '0'
|
||||
option server_http_test '0'
|
||||
option server_test '0'
|
||||
option restart_down '0'
|
||||
option mail_alert '0'
|
||||
option initial_state 'online'
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
# shellcheck disable=SC2039
|
||||
# vim: set noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 :
|
||||
# Copyright (C) 2018-2021 Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
|
||||
# Copyright (C) 2018-2025 Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
|
||||
# Released under GPL 3. See LICENSE for the full terms.
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
{
|
||||
START=90
|
||||
STOP=10
|
||||
USE_PROCD=1
|
||||
EXTRA_COMMANDS="start_interface"
|
||||
}
|
||||
|
@ -17,7 +16,7 @@
|
|||
|
||||
_validate_section() {
|
||||
local tmp_hosts=$hosts tmp_hosts6=$hosts6 tmp_timeout=$timeout tmp_count=$count tmp_tries=$tries tmp_size=$size tmp_max_ttl=$max_ttl tmp_failure_loss=$failure_loss tmp_failure_latency=$failure_latency tmp_recovery_loss=$recovery_loss tmp_recovery_latency=$recovery_latency tmp_reliability=$reliability
|
||||
local tmp_interval=$interval tmp_interval_tries=$interval_tries tmp_options=$options tmp_type=$type tmp_enabled=$enabled tmp_wait_test=$wait_test tmp_server_http_test=$server_http_test tmp_check_quality=$check_quality tmp_failure_interval=$failure_interval tmp_tries_up=$tries_up tmp_family=$family
|
||||
local tmp_interval=$interval tmp_interval_tries=$interval_tries tmp_options=$options tmp_type=$type tmp_enabled=$enabled tmp_wait_test=$wait_test tmp_server_http_test=$server_http_test tmp_server_test=$server_test tmp_check_quality=$check_quality tmp_failure_interval=$failure_interval tmp_tries_up=$tries_up tmp_family=$family
|
||||
|
||||
uci_validate_section omr-tracker "$1" "$2" \
|
||||
'hosts:list(host)' \
|
||||
|
@ -41,6 +40,7 @@ _validate_section() {
|
|||
'type:string:undef' \
|
||||
'enabled:bool:1' \
|
||||
'server_http_test:bool:0' \
|
||||
'server_test:bool:0' \
|
||||
'family:string' \
|
||||
'options:string'
|
||||
|
||||
|
@ -65,6 +65,7 @@ _validate_section() {
|
|||
[ -z "$options" ] && options=$tmp_options
|
||||
[ "$type" = "undef" ] && type=${tmp_type:-ping}
|
||||
[ -z "$server_http_test" ] && server_http_test=$tmp_server_http_test
|
||||
[ -z "$server_test" ] && server_test=$tmp_server_test
|
||||
[ -z "$family" ] && family=$tmp_family
|
||||
[ -z "$enabled" ] && enabled=$tmp_enabled
|
||||
}
|
||||
|
@ -145,6 +146,7 @@ _launch_tracker() {
|
|||
procd_append_param env "OMR_TRACKER_PROTO=$proto"
|
||||
procd_append_param env "OMR_TRACKER_WAIT_TEST=$wait_test"
|
||||
procd_append_param env "OMR_TRACKER_SERVER_HTTP_TEST=$server_http_test"
|
||||
procd_append_param env "OMR_TRACKER_SERVER_TEST=$server_test"
|
||||
procd_set_param limits nofile="51200 51200"
|
||||
procd_set_param respawn 0 10 0
|
||||
procd_set_param stderr 1
|
||||
|
|
|
@ -115,6 +115,13 @@ if [ "$(uci -q get omr-tracker.defaults.server_http_test)" = "" ]; then
|
|||
EOF
|
||||
fi
|
||||
|
||||
if [ "$(uci -q get omr-tracker.defaults.server_test)" = "" ]; then
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
set omr-tracker.defaults.server_test=0
|
||||
commit omr-tracker
|
||||
EOF
|
||||
fi
|
||||
|
||||
if [ -z "$(uci -q get omr-tracker.defaults.failure_interval)" ] || [ "$(uci -q get omr-tracker.defaults.failure_interval)" = "5" ]; then
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
set omr-tracker.defaults.failure_interval=20
|
||||
|
|
Loading…
Reference in a new issue