Monday, July 14, 2014

Linux commands

for F in `cat hosts`; do echo "::$F::";ssh -q -o "ConnectTimeout=2" $F 'hostname -s'; ssh -q -o "ConnectTimeout=2" $F '/sbin/ifconfig'|perl -ne '$eth=$1 if(/^(\S+)\s+Link en/); if(/inet addr:(\S+)/){print "$eth: $1\n"}'; done | tee /tmp/allips


/usr/sbin/ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== 142.201.48.241 142.201.48.242 4 u 833 1024 377 0.321 -0.132 0.206 *142.201.48.242 132.246.11.229 3 u 291 1024 377 0.973 -0.248 0.047


alias grep='grep --color=auto'
alias egrep='egrep --color=auto'


egrep "^[[:cntrl:]]" xlif.sym


grep -E "\S+*\.AT" bb.sym #42 Holy Rosary St

################################# script #################################

#!/bin/bash

#

# Script to test ssh login via ssh keys

#

 

 

HOSTS="$(cat $1 | grep -v ^# | grep -v ^$ | cut -d: -f1)"

 

for host in $HOSTS;

do

 

hostname=$host

CURRENT_DATE=`date +%s`

REMOTE_DATE=`ssh -oConnectTimeout\=5 -oPasswordAuthentication\=no $hostname "date +%s" 2> /dev/null`

 

diff=$((REMOTE_DATE - CURRENT_DATE))

if [ "$REMOTE_DATE" = "" ]

then

echo "$hostname: !!! FAILURE !!!"

else

echo "$hostname: Success : ssh start time: $CURRENT_DATE end time: $REMOTE_DATE diff = $(($diff / 60)) mins $(($diff % 60)) secs"

 

fi

 

done

################################# script #################################

No comments:

Post a Comment