I have 5 Solaris servers present across different locations. Sometimes some of these servers are not reachable from my location due to various reasons (either because of network problems or the server itself goes down suddenly).
So I would like to write a Bash shell script to check wether they are reachable. What I have tried is:
ssh ipaddress "uname -a"
Password less authentication is set. If I don't get any any output I will generate a mail.
- Are there any otherways to check server reachability?
- Which one is the best way?
- Is what I have tried correct?
You can use
ping -c4 $ip_addresswhere$ip_addressis the ip of your remote server and parse the output to capture the successful packets and/or failed packets and usemail -sto send the log via email.Here is something to get you started and you can build on it.
This will give an output like this -
I checked the Solaris
man-pageforping. Output frompingon Solaris box is different. Also, on Linux you limit the packets by stating-cand number of packets. On Solaris you would have to do -Unfortunately I don't have a solaris box handy to help you out with.