From: Sergey Matveev Date: Fri, 18 Nov 2022 11:48:49 +0000 (+0300) Subject: Cycle through all addresses X-Git-Url: http://www.git.stargrave.org/?p=sgmon.git;a=commitdiff_plain;h=3a68d59baf24c4acd0a68d93933905e869f4474b Cycle through all addresses --- diff --git a/helper/all-addrs b/helper/all-addrs new file mode 100755 index 0000000..4e47bdf --- /dev/null +++ b/helper/all-addrs @@ -0,0 +1,5 @@ +#!/bin/sh -e + +for t in A AAAA ; do + host -t $t $1 | perl -lane 'print $F[$#F]' +done diff --git a/helper/http b/helper/http index 1c5377a..cb3ad6c 100755 --- a/helper/http +++ b/helper/http @@ -1,9 +1,16 @@ #!/bin/sh -e -bad=0 -curl --range 0-100 --max-time 60 --verbose "$1" >state/curl-out 2>&1 || bad=1 -grep -q "$togrep" state/curl-out || bad=1 -if [ "$bad" -eq 1 ] ; then - cat state/curl-out - exit 1 -fi +domain=`echo "$1" | cut -d/ -f3 | cut -d: -f1` +"$SGMONDIR"/helper/all-addrs $domain | while read addr ; do + bad=0 + curl \ + --connect-to "::$addr:" \ + --range 0-100 \ + --max-time 60 \ + --verbose "$1" >state/curl-out 2>&1 || bad=1 + grep -q "$togrep" state/curl-out || bad=1 + if [ "$bad" -eq 1 ] ; then + cat state/curl-out + exit 1 + fi +done