Here is something to get you started and you can build on it. You can use ping -c4 $ip_address where $ip_address is the ip of your remote server and parse the output to capture the successful packets and/or failed packets and use mail -s to send the log via email. (examples illustrate connecting to port 22 ssh over a good and bad host example, use the $? to determine if it reached the host with the sleep time of 3 seconds)įor Mac Users (mainly) etc, you can use the command in the script like so : # - use NMAP, if not avail. (see workaround) nc -v -z -w 3 127.0.0.1 22 &> /dev/null & echo "Online" || echo "Offline" Nc: nc is usually installed already, however on some systems such as Mac OS X, the command hangs on unreachable systems. Preferred method NMAP (ex host ip 127.0.0.1) : nmap 127.0.0.1 -PN -p ssh | grep open Nmap: This is very quick, very reliable but requires nmap to be installed (2) Ping is unreliable as icmp echo is blocked in many situations. Ping: Why should you not use ping ? (1) It is better to check the system and the port at the same time. Some more food for thought : Use nmap or nc, never ping.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |