From 34ff03cbe80bff1e93b0b7b54ab2b5920ad209f0 Mon Sep 17 00:00:00 2001 From: Recolic Keghart <root@recolic.net> Date: Wed, 13 Nov 2019 18:18:36 +0800 Subject: [PATCH] add a new status: service closed --- datafile.py.gen.d.py | 12 +++++++++++- do.bash | 10 ++++++++++ status.html.gen.py | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/datafile.py.gen.d.py b/datafile.py.gen.d.py index f61f191..2e2ac48 100755 --- a/datafile.py.gen.d.py +++ b/datafile.py.gen.d.py @@ -9,6 +9,8 @@ import subprocess events = [] # [ [tag, UTC_time_string, information, month,day,year] ] curr_status = {} # tag -> returncode +RETURN_CODE_SERVICE_CLOSE = 91 + def on_problem_fixed(tag, desc): # ... fixed_prefix = '<strong>Resolved</strong> - ' @@ -32,7 +34,15 @@ def save_status(): elements = [] for tag, desc in tests: - color = 'green' if curr_status[tag] == 0 else 'red' + if curr_status[tag] == 0: + # OK + color = 'green' + elif curr_status[tag] == RETURN_CODE_SERVICE_CLOSE: + # Service closed as expected + color = 'blue' + else: + # Service down + color = 'red' elements.append('("{}","{}")'.format(desc, color)) current_status_str = 'current_status = [ ' + ','.join(elements) + ' ]' file_content += current_status_str + '\n' diff --git a/do.bash b/do.bash index 2d4af73..f4e59ee 100755 --- a/do.bash +++ b/do.bash @@ -4,6 +4,8 @@ [[ $(id -u) = 0 ]] && ping_fld="-f" +RETURN_CODE_SERVICE_CLOSE=91 + function confirm_alive () { local host="$1" timeout 4s ping "$host" -c 1 @@ -36,6 +38,7 @@ function do_test () { echo "Testing >> $1" > /dev/fd/2 case "$1" in rproxy ) + return $RETURN_CODE_SERVICE_CLOSE confirm_alive proxy.recolic.net && test_tcp proxy.recolic.net 22 | grep -a SSH || return $? ;; @@ -53,12 +56,15 @@ function do_test () { test_tcp base.hk1.recolic.net 30999 || return $? ;; ss-us1 ) + return $RETURN_CODE_SERVICE_CLOSE test_ss base.us1.recolic.net || return $? ;; ss-us5 ) + return $RETURN_CODE_SERVICE_CLOSE test_ss base.us5.recolic.net || return $? ;; ss-us6 ) + return $RETURN_CODE_SERVICE_CLOSE test_ss base.us6.recolic.net || return $? ;; ovpn-tw ) @@ -111,15 +117,18 @@ function do_test () { curl -s http://git.recolic.net/ -L | grep 'users/sign_in' || return $? ;; zhixiang ) + return $RETURN_CODE_SERVICE_CLOSE grep 'api.anjie-elec.cn' /etc/hosts || echo '123.206.117.183 api.anjie-elec.cn' >> /etc/hosts [[ $? != 0 ]] && echo 'Failed to edit hosts file! Unable to perform this test.' > /dev/fd/2 && return 0 curl -k -X POST -s 'https://api.anjie-elec.cn/api/usewater/Add?accessToken=FUCKYOU' | grep '104871845A503324' || return $? ;; mc ) + return $RETURN_CODE_SERVICE_CLOSE confirm_alive mc.recolic.net && test_tcp mc.recolic.net 25565 || return $? ;; push-httpdb-agent ) + return $RETURN_CODE_SERVICE_CLOSE local r="$RANDOM" confirm_alive git.recolic.net && curl -s "https://git.recolic.net/_r_testing/set/_status_test|$r" && @@ -146,6 +155,7 @@ function do_test () { curl -s 'https://recolic.net/go/index.php' --data 'target=https%3A%2F%2Fwww.google.com&name=google&super=' | grep Success || return $? ;; rocket ) + return $RETURN_CODE_SERVICE_CLOSE confirm_alive rocket.recolic.net && curl -s https://rocket.recolic.net:444/api/info | grep 'success":true' || return $? ;; diff --git a/status.html.gen.py b/status.html.gen.py index 05b9141..9860596 100755 --- a/status.html.gen.py +++ b/status.html.gen.py @@ -73,7 +73,7 @@ def _color2stat(color): if color == 'green': return 'Operational' if color == 'blue': - return 'Maintenance' + return 'Service closed' if color == 'red': return 'Major Outage' if color == 'orange': -- GitLab