NCBI C Toolkit Cross Reference

C/doc/fwd_check.sh


  1 #! /bin/sh
  2 # $Id: fwd_check.sh,v 1.44 2009/11/05 18:46:28 lavr Exp $
  3 # Author:   Denis Vakatov (vakatov@ncbi,nlm.nih.gov)
  4 # Modified: Anton Lavrentiev (lavr@ncbi.nlm.nih.gov)
  5 #
  6 # Check for the status of FWDAEMON on the dispatching NCBI servers
  7 
  8 delay_sec="$1"
  9 delay_sec=${delay_sec:="10"}
 10 netcat="`which netcat 2>/dev/null`"
 11 test -z "$netcat"  &&  netcat="`whereis netcat | sed 's/^[^:]*://;s/ //g'`"
 12 
 13 cat <<EOF
 14 http://www.ncbi.nlm.nih.gov/IEB/ToolBox/NETWORK/firewall.html
 15 
 16 Checking connections to NCBI Firewall Daemons as of `date -u +'%b %d %Y %R GMT'`:
 17 EOF
 18 
 19 {
 20 cat <<EOF
 21 ;130.14.25.13   5555    RETIRED
 22 10.10.150.7     5555    INTERNAL
 23 130.14.29.112   5860    RESERVED
 24 130.14.29.112   5861    RESERVED
 25 130.14.29.112   5862    RESERVED
 26 130.14.29.112   5863    RESERVED
 27 130.14.29.112   5864    OK
 28 130.14.29.112   5865    OK
 29 130.14.29.112   5866    RESERVED
 30 130.14.29.112   5867    OK
 31 130.14.29.112   5868    OK
 32 130.14.29.112   5869    OK
 33 130.14.29.112   5870    RESERVED
 34 130.14.29.112   4444    RETIRED
 35 130.14.29.112   4445    RESERVED
 36 130.14.29.112   4446    RESERVED
 37 130.14.29.112   4447    RESERVED
 38 130.14.29.112   4448    OK
 39 130.14.29.112   4449    OK
 40 130.14.29.112   4450    RESERVED
 41 130.14.29.112   4451    OK
 42 130.14.29.112   4452    OK
 43 130.14.29.112   4453    OK
 44 130.14.29.112   4454    RESERVED
 45 165.112.7.12    5860    RESERVED
 46 165.112.7.12    5861    RESERVED
 47 165.112.7.12    5862    RESERVED
 48 165.112.7.12    5863    RESERVED
 49 165.112.7.12    5864    RESERVED
 50 165.112.7.12    5865    RESERVED
 51 165.112.7.12    5866    RESERVED
 52 165.112.7.12    5867    RESERVED
 53 165.112.7.12    5868    RESERVED
 54 165.112.7.12    5869    RESERVED
 55 165.112.7.12    5870    OK
 56 165.112.7.12    4444    RETIRED
 57 165.112.7.12    4445    RESERVED
 58 165.112.7.12    4446    RESERVED
 59 165.112.7.12    4447    RESERVED
 60 165.112.7.12    4448    RESERVED
 61 165.112.7.12    4449    RESERVED
 62 165.112.7.12    4450    RESERVED
 63 165.112.7.12    4451    RESERVED
 64 165.112.7.12    4452    RESERVED
 65 165.112.7.12    4453    RESERVED
 66 165.112.7.12    4454    OK
 67 EOF
 68 } |
 69 while read x_host x_port x_status ; do
 70     test "`echo $x_host | grep -c '^[;]'`" != "0"  &&  continue
 71     if [ "$x_port" -lt "5860" -o "$x_port" -gt "5870" ]; then
 72         test -z "$HTTP_CAF" -o -n "$HTTP_CAF_EXTERNAL"  &&  continue
 73     fi
 74     if [ "$x_status" = "RETIRED"  -o \
 75          "$x_status" = "RESERVED" ]; then
 76         echo "${x_host}:${x_port}       $x_status"
 77         continue
 78     fi
 79     test "$x_status" = "READYING"  &&  unset x_status
 80     ( echo ; test -z "$netcat" && sleep ${delay_sec} ) | ${netcat:-telnet} $x_host $x_port >/tmp/$$ 2>&1 &
 81     pid=$!
 82     trap 'rm -f /tmp/$$; kill $pid >/dev/null 2>&1' 1 2 15
 83     ( sleep `expr $delay_sec + 2`  &&  kill $pid ) >/dev/null 2>&1 &
 84     guard=$!
 85     wait $pid >/dev/null 2>&1
 86     kill $guard >/dev/null 2>&1
 87     test -n "$HTTP_CAF_EXTERNAL"  || \
 88         cp="`tail +3 /tmp/$$ 2>/dev/null | grep -s '^[0-9]\{1,3\}[.][0-9]\{1,3\}[.][0-9]\{1,3\}[.][0-9]\{1,3\}:[0-9]\{1,5\}'`"
 89     grep -qs 'NCBI Firewall Daemon:  Invalid ticket\.  *Connection closed\.' /tmp/$$ >/dev/null 2>&1
 90     if   [ $? -eq 0 ]; then
 91         echo "${x_host}:${x_port}       ${x_status:-OKAY}${cp:+ }${cp}"
 92     elif [ -z "$x_status" ]; then
 93         echo "${x_host}:${x_port}       READYING"
 94     else
 95         echo "${x_host}:${x_port}       FAILED  ( telnet $x_host $x_port )"
 96     fi
 97     rm -f /tmp/$$
 98 done 2>&1 | grep -v 'Terminated'

source navigation ]   [ diff markup ]   [ identifier search ]   [ freetext search ]   [ file search ]  

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.