Created
June 2, 2021 21:52
-
-
Save erikson1970/0a09f328ab2380797afe2695cf77639d to your computer and use it in GitHub Desktop.
Walks through a list of servers and checks their ping time, uptime and DT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| LOCALmachine=$(hostname -f) | |
| nownow=$(date +"%s") | |
| #insert list of machines which you can SSH to: | |
| reversePingMachines="hostname1.local hostname2.local" | |
| #insert list of machine you can't SSH to - eg router,switches | |
| forwardPingMachines="192.168.13.1 192.168.13.40" | |
| #Time Spec is common for all entries - rounds to nearest 5 minutes | |
| TSPEC=$(( $(( $(date +"%s") / 300)) * 300 )) | |
| #Record Local Machine Uptime | |
| echo ${TSPEC},$(date +"%s"),UPTIME,$LOCALmachine,\"$(uptime)\" | |
| #Record forward Pings: | |
| for dest in $forwardPingMachines | |
| do | |
| ping -c 3 ${dest} | tail -2 | while read iii | |
| do | |
| echo ${TSPEC},$(date +"%s"),PING,$LOCALmachine,\"PING ${dest}: $iii\" | |
| done | |
| done | |
| # | |
| # Reverse Pings --> SSH to machine and ping to local machine, also reports uptime, and | |
| # very shoddy unix time difference plus or minus a couple seconds | |
| # | |
| # Edit this base64,compressed script by pasting to: | |
| # echo [insert base64 here] | base64 -d | gunzip > temp.sh | |
| # | |
| # re-encode with: | |
| # cat temp.sh | gzip -9 -c | base64 | |
| RPbase64=H4sIAF/6t2ACA32NwWrCQBCG7/MUf9MtZGkWqd4KHopRCWgbaHrzsiZrd8HsipviwebdnbSXFsFhDsP8M993fzfaOj/a6mjJhxP3VKSN7gwek4eYSFq9zV5Wra6t84YjG2LndWugdpKq93I+m4oJ5RVHKcQvAQpiDCnJ1DZAnH/O+uwfN6uK9VzlxWKRib+KbJOIc171iKaO0NboBmEH8bRJbuI+ygF4zUq/Dp1rjeT3g/OfUDUmTMM3Ou32UGOeTtbtDY6DylETCFy3XGXxurwyDUsGP/OT69nWBG+ILpyuW7lfAQAA | |
| for dest in $reversePingMachines | |
| do | |
| echo $RPbase64 | ssh $dest "base64 -d | gunzip | bash -s ${LOCALmachine} $(date +'%s') ${TSPEC}" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment