SHARE
TWEET

Untitled

a guest Jul 16th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SERVER=22.0.37.200
  2. TMP_FILE=/tmp/test_nfs_ports
  3. SPOOL_FILE=/etc/check_mk/spool/test_nfs_ports.log
  4.  
  5. TEST_PORT() {
  6.   echo "quit" | telnet $1 $2 | grep "Escape character is" >/dev/null  2>/dev/null
  7. }
  8.  
  9. FAILED_PORTS=()
  10. touch $TMP_FILE
  11.  
  12. for PORT in 111 2049
  13. do
  14.   TEST_PORT $SERVER $PORT >/dev/null  2>/dev/null
  15.   if [ "$?" -ne 0 ]
  16.   then
  17.     #echo "$PORT failed!"
  18.     FAILED_PORTS+=($PORT)
  19.   fi
  20. done
  21.  
  22. if [ ${#FAILED_PORTS[@]} -ne 0 ]#if massive length non-equal zero
  23. then
  24.   echo Telnet connection to $HOST to ports: ${FAILED_PORTS[@]} was failed at `date +"%T"` >> $TMP_FILE
  25. fi
  26.  
  27. if [ -s $TMP_FILE ] #if file non-empty
  28. then
  29.   echo 2 test_nfs_ports - Some telnet connections to $SERVER to NFS ports failed, check $TMP_FILE for timestamps > $SPOOL_FILE
  30.   exit 1
  31. fi
  32.  
  33. echo 0 test_nfs_ports - Telnet connections to $SERVER to NFS ports OK > $SPOOL_FILE
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top