Author: jw Date: 2006-06-02 19:31:08 +0200 (Fri, 02 Jun 2006) New Revision: 1484 Modified: tools/scripts/check_urls Log: check_urls: unique state files (per file, not per port) Modified: tools/scripts/check_urls =================================================================== --- tools/scripts/check_urls 2006-06-02 17:10:17 UTC (rev 1483) +++ tools/scripts/check_urls 2006-06-02 17:31:08 UTC (rev 1484) @@ -42,43 +42,42 @@ check_notify() { local portpath=$1 local port=$(echo $portpath|sed -e 's|/|_|g') + local file=$port.$(basename $2) local url=$2 local cause=$3 - if [ -f $PORT_STATES/$port.created ]; then -# debug "Known problem '$port', first detected on \ -# $(cat $PORT_STATES/$port.created|awk '{print strftime("%c",$1)}')" + if [ -f $PORT_STATES/$file.created ]; then - log "$(cat $PORT_STATES/$port.created)" \ - "$portpath" "$(cat $PORT_STATES/$port.cause)" \ + log "$(cat $PORT_STATES/$file.created)" \ + "$portpath" $url "$(cat $PORT_STATES/$file.cause)" \ "KNOWN" - notify_date=$(cat $PORT_STATES/$port.notified) + notify_date=$(cat $PORT_STATES/$file.notified) now=$(date +%s) delta=$((now - notify_date)) # debug "Delta: $delta" - if [ ! "$(cat $PORT_STATES/$port.cause)" = "$cause" ]; then + if [ ! "$(cat $PORT_STATES/$file.cause)" = "$cause" ]; then notify "$portpath" $url "$cause" "Changed reason" - echo $now > $PORT_STATES/$port.notified - echo $cause > $PORT_STATES/$port.cause + echo $now > $PORT_STATES/$file.notified + echo $cause > $PORT_STATES/$file.cause elif [ $delta -gt $NOTIFY_DELTA ]; then notify "$portpath" $url "$cause" "Reminder" - echo $now > $PORT_STATES/$port.notified + echo $now > $PORT_STATES/$file.notified fi - date +%s > $PORT_STATES/$port.revisited + date +%s > $PORT_STATES/$file.revisited else datestr=$(date +%s) notify "$portpath" $url "$cause" "New" - log $datestr $portpath "$cause" "NEW" + log $datestr $portpath $url "$cause" "NEW" - echo $datestr > $PORT_STATES/$port.created - echo $datestr > $PORT_STATES/$port.revisited - echo $datestr > $PORT_STATES/$port.notified - echo $cause > $PORT_STATES/$port.cause + echo $datestr > $PORT_STATES/$file.created + echo $datestr > $PORT_STATES/$file.revisited + echo $datestr > $PORT_STATES/$file.notified + echo $cause > $PORT_STATES/$file.cause fi } @@ -120,7 +119,8 @@ name=$(echo $base|sed -e 's|_|/|g') if [ $delta -gt $REMOVE_DELTA ]; then - log $now $name "$(cat $PORT_STATES/$base.cause) [solved]" "RESOLVED" + log $now $name "" \ + "$(cat $PORT_STATES/$base.cause) [solved]" "RESOLVED" rm -r $PORT_STATES/$base.* fi done @@ -139,8 +139,9 @@ echo "<h1>check_urls report for $(date)</h1>" >> $HTMLLOG cat $LOGFILE|sort --field-separator="|" -n|\ awk -F\| '/.*/ { print "<p ><h3 class=\""$4"\">"$2"</h3>" \ - "<b>Status:</b> "$4"<br>" \ - "<b>Reason:</b> "$3"<br>" \ + "<b>URL:</b> "$3"<br>" \ + "<b>Status:</b> "$5"<br>" \ + "<b>Reason:</b> "$4"<br>" \ "<b>Open since:</b>" strftime("%c",$1) "</p>";}' >> $HTMLLOG echo "</body></html>" >> $HTMLLOG }
participants (1)
-
crux@crux.nu