0

we are using the following great pssh command in order to see if time differences is more then 3 second between machines

 pssh -i -o /tmp/out/ -e /tmp/err/ -H "master01 master02 master03 worker01 worker02" -l root -x '-q -o StrictHostKeyChecking=no -o GSSAPIAuthentication=no -o PreferredAuthentications=publickey -o PubkeyAuthentication=yes' date
[1] 12:15:43 [SUCCESS] worker02
Fri Jul 12 12:15:43 UTC 2019
[2] 12:15:43 [SUCCESS] master03
Fri Jul 12 12:15:43 UTC 2019
[3] 12:15:43 [SUCCESS] worker01
Fri Jul 12 12:15:43 UTC 2019
[4] 12:15:43 [SUCCESS] master01
Fri Jul 12 12:15:43 UTC 2019
[5] 12:15:43 [SUCCESS] master02
Fri Jul 12 12:15:43 UTC 2019

now we want to set pssh in the bash script

and we want to check that time isn't more then 3 second between machines

how to use awk/perl one liner /bash/ , in order to verify time isn't more then 3 sec?

Or in order to show only the date results:

pssh -i -H "master01 master02 master03 worker01 worker02" 2>/dev/null -l root -x '-q -o StrictHostKeyChecking=no -o GSSAPIAuthentication=no -o PreferredAuthentications=publickey -o PubkeyAuthentication=yes' date | grep -v "^\["
Fri Jul 12 12:37:35 UTC 2019
Fri Jul 12 12:37:35 UTC 2019
Fri Jul 12 12:37:35 UTC 2019
Fri Jul 12 12:37:35 UTC 2019
Fri Jul 12 12:37:35 UTC 2019

Note - we have more then 452 redhat 7.2 machines in our cluster ( the below is example )

  • Well presumably the first step would be to change the date format to epoch seconds +%s (or perhaps nanoseconds) - then you can pipe the results to any simple min/max routine (search here for awk min max for examples) - or even something like datamash range 1 – steeldriver Jul 12 at 13:05
  • can you give an answer with the solution , so all folks will enjoy – yael Jul 12 at 13:15
  • would it be reasonable to compare all the target system dates to the date on the system you're running pssh from? (considering the possibility of passing the date out to the remote systems and asking if their date is more than 3 seconds off) -- just a simpler alternative, if it fits your situation. – Jeff Schaller Jul 12 at 14:07
  • yes is simple and good idea , to compare the current ,machine date with all others remote and see if remote machine are more then 3 second , so in that case can you suggest code for that example? – yael Jul 12 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.