Automated Hosts Pinging with Notification of Failure
In every shop there is a critical need to keep the servers serving. For system availability, the quicker you know that a system is unreachable, the quicker you can act to resolve the problem and reduce company losses. At the lowest level of system access, we can ping each machine in the “critical machine” list. If the ping works, it will tell you if the network adapter is working, but it does not guarantee that the machine is booted and applications are working. For this level of checks you need to actually access the application or operating system.
In this chapter we are going to create a shell script that will ping hosts using a list of machines, which is stored in a separate file that is easily edited. Other options to this scenario include pinging all the machines in the /etc/hosts file, using ftp to transfer a file, querying a database, or interacting with an application, to name a few. Our interest in this chapter is to work at the lowest level and use the ping command to ensure that the machines are reachable from the network. When a machine is found unreachable, we send notification to alert staff that the machine is down. Due to the fact that in some shops the network can become saturated with network traffic, we are going to add an extra level of testing on a failed ping test, which we will get into later in this chapter. But before we go any further let's look at the command syntax for each of our operating ...