stevepedwards.com/DebianAdmin linux mint IT admin tips info

Cool Command Number…?? pssh containing cssh and more

Have you ever wondered if you can access multiple PCs via one terminal at the same time...?

Execute commands simultaneously on multiple servers Using PSSH/Cluster SSH/Multixterm

This is great should you want to say, shutdown many PCs immediately, or just compare command output for different PCs etc.

sudo apt install pssh clusterssh

stevee@T3400Quad ~ $ !?nb
nbtscan 192.168.1.0/24
Doing NBT name scan for addresses from 192.168.1.0/24

IP address NetBIOS Name Server User MAC address
------------------------------------------------------------------------------
192.168.1.0 Sendto failed: Permission denied
192.168.1.2 DELLMINT <server> DELLMINT 00:00:00:00:00:00
192.168.1.8 T3400QUAD <server> T3400QUAD 00:00:00:00:00:00
192.168.1.4 PIREAR <server> PIREAR 00:00:00:00:00:00
192.168.1.7 PIFRONT <server> PIFRONT 00:00:00:00:00:00
192.168.1.3 PIGARAGE <server> PIGARAGE 00:00:00:00:00:00
192.168.1.9 PIGARDEN <server> PIGARDEN 00:00:00:00:00:00

cssh PIREAR PIFRONT PIGARAGE
Opening to: PIREAR PIFRONT PIGARAGE
Opening to: dellmint

Using the menu in the control terminal, you can add others to the session too! Dellmint in this case:

The beauty is that you can still access individual terminals directly by clicking in them to run separate commands for them alone, then go back to the main mini terminal to issue duplicates to all - how cool is that?!

This is great if you run identical PCs but want to run benchmarks, or read stats like usage, free memory, cpu load etc. and be able to see the differences by issuing one command only.

This would also give an indication of the response times of each device due to net conditions or hardware differences.

For instance, running updates on 3 Raspberry Picams shows the processing time lag for one of my cams that only has a dual core and 512M RAM compared to the other 2 Quads with 1GB so is slower at processing the package lists.

Running a command line that has some addition to do shows this lag in the video - a search for all .txt files on the Pis:

time sudo find / -name *.txt -exec du -h {} \; | awk '{sum +=$1} {print $1, sum}'

Time differences show the difference that 1GB of RAM and 4 cores makes compared 512MB of RAM and 2 cores in the older Pi - 4 times slower - in line with the hardware; 1/2 CPUs x 1/2 memory. (It still works as a great Picam with Motion though!):

real 0m33.366s

real 0m7.850s

real 0m10.798

The thing I was thinking about initially, before stumbling on these commands is rsyncing TO multiple servers simultaneously from a single PC, which I'll check out later using ...

man parallel-scp

NAME
parallel-scp - parallel versions of scp

SYNOPSIS
parallel-scp [OPTIONS] -h hosts.txt local remote

DESCRIPTION
pssh provides a number of commands for executing against a group of
computers, using SSH. It´s most useful for operating on clusters of
homogenously-configured hosts.

parallel-scp copy files in parallel to a set of machines.

Comments are closed.

Post Navigation