PSSH (parallel ssh)

PSSH How To

wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/parallel-ssh/pssh-2.3.1.tar.gz
tar -xzf pssh-2.3.1.tar.gz
python setup.py install

host list als File erstellen
vi hosts.txt ->
	server168.bb.bbmsg
	server169.bb.bbmsg

am besten überall den SSH RSA Key aktivieren.
ssh-keygen -v -b 8192 -t rsa
cat ~/.ssh/*.pub | ssh user@server169.bb.bbmsg 'cat>>.ssh/authorized_keys'
	cat /home/user/.ssh/id_rsa.pub | ssh user@server.domain.com 'sudo -u root sh -c "mkdir -p /home/user/.ssh; cat>>/home/user/.ssh/authorized_keys; chmod 0700 /home/user/.ssh/; chmod 0600 /home/user/.ssh/authorized_keys ; chown -R user:users /home/user/.ssh/"'

#Für Bourne Shell
eval `ssh-agent -s -t 120`
ssh-add -t 60 /home/user/.ssh/id_rsa

pssh -h hosts.txt -l user -i "ls -al"
	pssh -h server_liste.txt --timeout 1 --extra-args -oStrictHostKeyChecking=no -oCheckHostIP=no -oConnectTimeout=9 -oNumberOfPasswordPrompts=1 -l user -i "hostname"
	pssh -h server_liste.txt --timeout 1 --extra-args -oStrictHostKeyChecking=no -oCheckHostIP=no -oConnectTimeout=9 -oNumberOfPasswordPrompts=1 -l user -i 'sudo -u root sh -c "whoami"'
	pssh -h server_liste.txt --timeout 1 --extra-args -oStrictHostKeyChecking=no -oCheckHostIP=no -oConnectTimeout=9 -oNumberOfPasswordPrompts=1 -l user -i 'sudo -u root sh -c "hostname;whoami;date;uptime"'
	pssh -h hosts_salt_prd.txt --timeout 30 --extra-args -oStrictHostKeyChecking=no -oCheckHostIP=no -oConnectTimeout=9 -oNumberOfPasswordPrompts=1 -l user -i 'sudo -u root sh -c "ps -ef | grep -i salt"' 		
	

#mit AWK (Berechnung in GB der RAM Auslastung (VSZ) eines Prozesses)
pssh -h server_liste.txt --timeout 30 --extra-args -oStrictHostKeyChecking=no -oCheckHostIP=no -oConnectTimeout=9 -oNumberOfPasswordPrompts=1 -l user -i 'ps aux | awk "{print \$5,\$11}" | grep -i jstart | grep -i smd |  awk "{print \$1/(1024*1024),\"GB jstart_SMD\"}" '
#############################
PSCP

" pscp -v -r -h server_list_xen.txt -l root /etc/hosts /tmp/ " = Paralell kopieren

##############################
#SSH extra Args für PSSH
--extra-args 
	-oRequestTTY=force = verhindert diese Meldung "tderr: tput: No value for $TERM and no -T specified tput: No value for $TERM and no -T specified"
	-oStrictHostKeyChecking=no 	= Keine Key Verifikations
	-oCheckHostIP=no = Keine IP zu Host verifikation
	-oConnectTimeout=9 = Timeout für die reine SSH verbindung
	-oNumberOfPasswordPrompts=1 = Nur ein versuch das Passwort einzugeben.
##############################
	

#Command Sammlung############################################################
" pssh -h server_list_all.txt --inline-stdout --extra-args -oRequestTTY=force -l root "hostname; date" "
" 'sudo -u root sh -c "hostname;whoami;date;uptime"' "
" pssh -h server_list_vi.txt --inline-stdout --extra-args -oRequestTTY=force -l root 'xl list; docker ps -a' "	= XEN und Docker VMs Info
" pssh -h server_list_all.txt --inline-stdout --extra-args -oRequestTTY=force -l root 'btrfs filesystem show | grep -i devid | awk -F " " "{print \$8}" | xargs  -I % btrfs scrub cancel %' "	= BTRFS Scrub Cancel
" pssh -h server_list_all.txt --inline-stdout --extra-args -oRequestTTY=force -l root 'mount | grep -i btrfs | awk -F " " "{print \$3}" | xargs  -I % btrfs balance status %' "		= BTRFS balance cancel
" pssh -h server_liste.txt --timeout 30 --extra-args -oStrictHostKeyChecking=no -oCheckHostIP=no -oConnectTimeout=9 -oNumberOfPasswordPrompts=1 -l root -i 'free -m | grep Swap | awk -F " " "{print \$3*100/\$2 , \" % swap used\",\$4*100/\$2, \" % swap free\", ENVIRON[\"HOSTNAME\"]  }" '   " = SWAP Auslastung in Prozent
" pssh -h server_liste.txt --timeout 30 --extra-args -oStrictHostKeyChecking=no -oCheckHostIP=no -oConnectTimeout=9 -oNumberOfPasswordPrompts=1 -l root -i 'ps aux | awk "{print \$5,\$11}" | grep -i jstart | grep -i smd |  awk "{print \$1/(1024*1024),\"GB jstart_SMD\", ENVIRON[\"HOSTNAME\"] }" ' " = RAM + SWAP Auslastung eines Processes
##########################################################################################

Post Revisions:

Tags:  ,