summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2019-12-11 21:14:03 +0100
committerSuren A. Chilingaryan <csa@suren.me>2019-12-11 21:14:03 +0100
commit2760dba480083977d179f095f47f28ec1913b9ec (patch)
tree569481702d6fa58845fc5e4c04f72993520f9492
parent2df6c231a41cae525f77a46e98ddf805f667ce5b (diff)
downloadconky-2760dba480083977d179f095f47f28ec1913b9ec.tar.gz
conky-2760dba480083977d179f095f47f28ec1913b9ec.tar.bz2
conky-2760dba480083977d179f095f47f28ec1913b9ec.tar.xz
conky-2760dba480083977d179f095f47f28ec1913b9ec.zip
Properly detect MySQL/slave desynchronization
-rwxr-xr-xadei/check_adei.sh6
-rwxr-xr-xadei/check_adei_source.sh4
-rw-r--r--lib/adei/adei.sh11
3 files changed, 11 insertions, 10 deletions
diff --git a/adei/check_adei.sh b/adei/check_adei.sh
index 58ce49c..06047b6 100755
--- a/adei/check_adei.sh
+++ b/adei/check_adei.sh
@@ -40,9 +40,9 @@ fi
# Verify offset (for selected database)
if [ -n "$adei10" -a $healthy -ne 0 -a -n "$adei_source" ]; then
now=$(date +%s)
- sdate="$(adei_text_query "getdata.php?db_mask=0&format=csv&window=-1&rt=1&cache=1&time_format=U&mysql=slave")"; err_slave=$?
+ sdate="$(adei_text_query "getdata.php?db_mask=0&format=csv&window=-1&rt=1&cache=1&time_format=U" slave)"; err_slave=$?
[ $err_slave -eq 0 ] && sdate="$(echo "$sdate" | cut -d ',' -f 1 | cut -d '.' -f 1)"
- mdate="$(adei_text_query "getdata.php?db_mask=0&format=csv&window=-1&rt=1&cache=1&time_format=U&mysql=master")"; err_master=$?
+ mdate="$(adei_text_query "getdata.php?db_mask=0&format=csv&window=-1&rt=1&cache=1&time_format=U" master)"; err_master=$?
[ $err_master -eq 0 ] && mdate="$(echo "$mdate" | cut -d ',' -f 1 | cut -d '.' -f 1)"
src="$adei_source"
@@ -62,7 +62,7 @@ if [ -n "$adei10" -a $healthy -ne 0 -a -n "$adei_source" ]; then
slave_offset=$(($mdate - $sdate))
if [ $master_offset -gt $MAX_SOURCE_OFFSET ]; then
- rdate=$(adei_text_query "getdata.php?db_mask=0&format=csv&window=-1&rt=1&time_format=U&mysql=master"); err=$?
+ rdate=$(adei_text_query "getdata.php?db_mask=0&format=csv&window=-1&rt=1&time_format=U" master); err=$?
if [ $err -eq 0 ]; then
rdate="$(echo "$rdate" | cut -d ',' -f 1 | cut -d '.' -f 1)"
cache_offset=$(($rdate - $mdate))
diff --git a/adei/check_adei_source.sh b/adei/check_adei_source.sh
index 04b7257..b194ae5 100755
--- a/adei/check_adei_source.sh
+++ b/adei/check_adei_source.sh
@@ -20,9 +20,9 @@ cur=`date -u +%s`
group_mode=0
#groups=`curl -s -m 3 --proxy "" "$adei_url/services/list.php?target=groups&info=1&setup=$2&db_server=$3&db_name=$db_name" | xmllint --format - | grep "Value" | sed -e "s/^.*db_group=\"\([^\"]*\)\".*$/\\1/" | sed -e "s/ /::space::/"`
-groups=$(adei_value_query "list.php?target=groups&info=1" 12); err=$?
+groups=$(adei_value_query "list.php?target=groups&info=1" master 12); err=$?
if [ $err -ge 1 -a $err -le 3 ]; then
- groups=$(adei_value_query "list.php?target=groups" 5); err=$?
+ groups=$(adei_value_query "list.php?target=groups" master 5); err=$?
adei_process_error $err "$groups" "GroupList"
echo "Data queries are too slow, check database indexes"
diff --git a/lib/adei/adei.sh b/lib/adei/adei.sh
index 8519af7..fa9dfc3 100644
--- a/lib/adei/adei.sh
+++ b/lib/adei/adei.sh
@@ -35,7 +35,6 @@ function adei_query {
url="$1&mysql=master"
fi
-
resp=$(curl --proxy "" --location-trusted -sf -m "$timeout" "$url"); err=$?
if [ $err -ne 0 ]; then
resp=$(adei_query "$1" "ecode" "$timeout")
@@ -56,9 +55,10 @@ function adei_query {
function adei_format_query {
local with_auth="${1:-1}"
local query="$2"
- local timeout=${3:-$adei_default_timeout}
- local source=${4:-"$adei_source"}
- local url="${5:-$adei_url}"
+ local database=${3:-master} # ignoring here, it will be handled separately by adei_query
+ local timeout=${4:-$adei_default_timeout}
+ local source=${5:-"$adei_source"}
+ local url="${6:-$adei_url}"
auth=""
[ $with_auth -gt 0 ] && auth="$adei_auth"
@@ -71,7 +71,8 @@ function adei_format_query {
function adei_simple_query {
local req=$(adei_format_query 1 "$@")
- adei_query "$req" "master" "$timeout"; err=$?
+ local database=${2:-master}
+ adei_query "$req" $database "$timeout"; err=$?
return $err
}