Loading doc/operational 0 → 100644 +40 −0 Original line number Diff line number Diff line Date: 2012-07-20 Time-stamp: <2012-07-20> * DONE use nagios3 to do notification. do not flood local email. see bug 221. :wontfix: ** 2012-07-20 write ddclient-http-status script. If FATAL_ERROR_FILE exists, return CRITICAL. check whether tplinkip returns the same IP as ip in LAST_IP_FILE. If not: if tplinkip is 0.0.0.0, return CRITICAL. else return WARNING. OK WARNING if error file exists. UNKNOWN CRITICAL if fatal_error file exists. - how to get LAST_IP_FILE and FATAL_ERROR_FILE pathname? nagios3 run check script as root. - notification. do not use general service template. use that title but in body, also send tail -n 20 /var/log/ddclient-http.log ** 2012-07-20 nagios3 run ddclient-http-status every 5 minute to check whether it's running correctly. notify user when it went down. send notification once per hour. notify user when it goes up immediately. * DONE it seems using nagios3 is overkill. :implemented: I can roll it myself. create a last_error_report file. when error happen, read that file. - if file does not exist, continue report and create that file with current ts. - if file exists. - if timestamp in it is 1 hour ago or earlier, continue report and update the ts. - otherwise, do not report. src/bin/ddclient-http +23 −3 Original line number Diff line number Diff line Loading @@ -27,6 +27,9 @@ HTTP_RESPONSE=/tmp/ddclient-http-api.html RUNTIME_DIR="$HOME/.config/ddclient-http/" LAST_IP_FILE="$RUNTIME_DIR/last_ip" FATAL_ERROR_FILE="$RUNTIME_DIR/fatal_error" LAST_ERROR_REPORT_TIMESTAMP="$RUNTIME_DIR/last_error_report_timestamp" # ddclient-http sends at most one report email every REPORT_GAP seconds. REPORT_GAP=3600 if [ ! -d "$RUNTIME_DIR" ]; then mkdir -p "$RUNTIME_DIR" Loading @@ -37,12 +40,29 @@ log() { logger -t ddclient_http "$@" } # Usage: err [MESSAGE..] err() { logger -t ddclient_http -p user.err "$@" # update last report timestamp and report to local root. # this is used by err(). do_report() { date +'%s' > "$LAST_ERROR_REPORT_TIMESTAMP" # Note: echo (the built-in command in dash) does not support -e. # using external /bin/echo command. /bin/echo -e "$@" | mail -s "ddclient-http Error" ${EMAIL:-root@localhost} logger -t ddclient_http -p user.err "Error reported to root@localhost" } # Usage: err [MESSAGE..] err() { logger -t ddclient_http -p user.err "$@" if [ ! -f "$LAST_ERROR_REPORT_TIMESTAMP" ]; then do_report "$@" else last_ts=`cat "$LAST_ERROR_REPORT_TIMESTAMP"` seconds_from_last_report = expr `date +'%s'` - "$last_ts" if [ "$seconds_from_last_report" -gt "$REPORT_GAP" ]; then do_report "$@" fi fi } # Usage: fatal_err [MESSAGE..] Loading Loading
doc/operational 0 → 100644 +40 −0 Original line number Diff line number Diff line Date: 2012-07-20 Time-stamp: <2012-07-20> * DONE use nagios3 to do notification. do not flood local email. see bug 221. :wontfix: ** 2012-07-20 write ddclient-http-status script. If FATAL_ERROR_FILE exists, return CRITICAL. check whether tplinkip returns the same IP as ip in LAST_IP_FILE. If not: if tplinkip is 0.0.0.0, return CRITICAL. else return WARNING. OK WARNING if error file exists. UNKNOWN CRITICAL if fatal_error file exists. - how to get LAST_IP_FILE and FATAL_ERROR_FILE pathname? nagios3 run check script as root. - notification. do not use general service template. use that title but in body, also send tail -n 20 /var/log/ddclient-http.log ** 2012-07-20 nagios3 run ddclient-http-status every 5 minute to check whether it's running correctly. notify user when it went down. send notification once per hour. notify user when it goes up immediately. * DONE it seems using nagios3 is overkill. :implemented: I can roll it myself. create a last_error_report file. when error happen, read that file. - if file does not exist, continue report and create that file with current ts. - if file exists. - if timestamp in it is 1 hour ago or earlier, continue report and update the ts. - otherwise, do not report.
src/bin/ddclient-http +23 −3 Original line number Diff line number Diff line Loading @@ -27,6 +27,9 @@ HTTP_RESPONSE=/tmp/ddclient-http-api.html RUNTIME_DIR="$HOME/.config/ddclient-http/" LAST_IP_FILE="$RUNTIME_DIR/last_ip" FATAL_ERROR_FILE="$RUNTIME_DIR/fatal_error" LAST_ERROR_REPORT_TIMESTAMP="$RUNTIME_DIR/last_error_report_timestamp" # ddclient-http sends at most one report email every REPORT_GAP seconds. REPORT_GAP=3600 if [ ! -d "$RUNTIME_DIR" ]; then mkdir -p "$RUNTIME_DIR" Loading @@ -37,12 +40,29 @@ log() { logger -t ddclient_http "$@" } # Usage: err [MESSAGE..] err() { logger -t ddclient_http -p user.err "$@" # update last report timestamp and report to local root. # this is used by err(). do_report() { date +'%s' > "$LAST_ERROR_REPORT_TIMESTAMP" # Note: echo (the built-in command in dash) does not support -e. # using external /bin/echo command. /bin/echo -e "$@" | mail -s "ddclient-http Error" ${EMAIL:-root@localhost} logger -t ddclient_http -p user.err "Error reported to root@localhost" } # Usage: err [MESSAGE..] err() { logger -t ddclient_http -p user.err "$@" if [ ! -f "$LAST_ERROR_REPORT_TIMESTAMP" ]; then do_report "$@" else last_ts=`cat "$LAST_ERROR_REPORT_TIMESTAMP"` seconds_from_last_report = expr `date +'%s'` - "$last_ts" if [ "$seconds_from_last_report" -gt "$REPORT_GAP" ]; then do_report "$@" fi fi } # Usage: fatal_err [MESSAGE..] Loading