Well, in this chance, I’d like to share you about a specific case happened to me while I had trouble to manage tens of internal servers around me. What I need is a small tool which able to give information whether the servers are alive or not from everywhere. Everywhere means that I can check it from anywhere at anytime, in my house or with my PDA far away from the office or simply using (wifi) public internet access with laptop. So I can take an action quickly if the problem appears (except for electricity or failure hardware problems). Even that I can get in one of the public IP and check it out the box one by one over SSH tunnel, but it will took lots of time.
To solve this, here’s a simple logic a bit of PHP code containing exec with ping command. exec command purposed to execute an external system command, which is ping. This small application prepared with two submit button, one for single IP ping action and one for all listed IP’s server machine. This is just a variation of the program so that it purpose to any use. Take a look at the core code below:
exec("ping -c $max_count $host",$list);
for ($i = 0; $i < count($list); $i++) echo $i . $list[$i]."<br>";
Note that the use of ping –c parameter only works when the application hosted on Linux server. If you have it on Windows server, you may use ping –n. The using of this count parameter are purposed to limit the output result (from $max_count variable). Now, here below is the response if I take a test to yahoo.com server with Ping Custom button:
The others button, contain list of all internal IP machines database. Once the button hit, it will process whole of IP’s sequentially. Even though that there’s a small numbers of latency, but it’s worthy. Take a look at below result:
This kit is a pure web based application, but browser is not a must have to run it on the client. Get a Linux box near you, and supply it a text based browser (such lynx or elinks) and you can use it under terminal. Here’s below what it will look like within the console box (it’s a Fedora Core 4 Server accessed from public RedHat Enterprise Linux AS server 4 with elinks and remotes from Windows XP as client over puTTy):
The example above is a basic model script utilizing PHP program execution function. There are lot of ways you can take control a machine remotely appropriate to your necessity. But one sure thing is; create a system with safe environment. Saving the time, saving the money and saving the system. Aarghh… you know what I’m talking about.
PS: If you've benefit from this blog,
you can support it by making a small contribution.