|
How can my shell script test server status?i am in big problem so please help on it. below i write the scripts, i don't know it is correct or not, but i want write the shell script for. In particular machine need to check all process are running or not, and we need result to display in the web page like server name = running, not only single server we have so many servers so, result like in the web page: server1 = running like that so many server we have and one more thing is need show in web page with colors and fonts. please help on it! Since it's apparent that you are at a polytechnic in India (the submission had a ".in" email address suffix) and that you're baffled by what's a fairly rudimentary homework assignment, it would probably be better if I just ignored this question and let you figure it out yourself, but instead I cunningly waited a month or so to get here. That way, it couldn't possibly be helpful to you. :-) Nonetheless, this really is a straightforward project, so straightforward that I will write up a simple script. First off, how do you test to see if a server is running? Use the ping command! For example, let me ping two servers, one I know is running and one I know isn't by virtue of the fact it's an unknown domain: $ ping -o yahoo.com
PING yahoo.com (206.190.60.37): 56 data bytes 64 bytes from 206.190.60.37: icmp_seq=0 ttl=46 time=69.601 ms --- yahoo.com ping statistics --- 1 packets transmitted, 1 packets received, 0% packet loss round-trip min/avg/max/stddev = 69.601/69.601/69.601/0.000 ms $ echo $? 0 $ ping -o xyz.yahoo.com ping: cannot resolve xyz.yahoo.com: Unknown host $ echo $? 68 Really, that should be enough to show you how to proceed, but let's put it in script form: for server in $(cat serverlist)
do ping -o $server > /dev/null 2>&1 if [ $? -eq 0 ] ; then echo "$server = running" else echo "$server = not running" fi done Now that should be enough, shouldn't it? The only slight tweak: if the shell script is going to be called directly within a browser (which requires some modifications to the Apache server configuration) then it needs the following as the very first two lines of output generated by the script: echo "Content-Type: text/html" ; echo ""
Now that should help you quickly gain an "A" in this assignment!
Categorized:
Shell Script Programming
(Article 8418,
Written by Dave Taylor)
Tagged: shell script programming, shell scripting Previous: Does Google AdSense work better on text-based pages? Next: How do I "sculpt pagerank" on my site? Subscribe!
what is the wep key Posted by: marco at September 21, 2008 7:38 AMHey! I'm hosting a game server on my PC is there a way to put on my website if the server is online or offline? Please e-mail me if you know the answer. Posted by: Sebby05 at October 9, 2008 6:31 AMHi, great job helping others. There will 100's of server and their 1000 VPSs Is there any script that will immediately changes the VPs status in the control panel without throwing heavy server load? Posted by: Tushar at August 9, 2010 7:02 AMI tried the above script it does not work for me.. Posted by: Nick at June 9, 2011 11:53 PMI have something to say, now that you mention it, but ...
I do have a comment, now that you mention it!
|
Recommended
Recent Entries
Search
I Need Help!
Apple iPad Help
Articles and Reviews Auctions and Online Shopping Blogs and RSS Feeds Building Web Site Traffic Business and Management CGI Scripts and Web Site Programming Computer and Internet Basics d) None of the Above Facebook Help Google Plus Help HTML and CSS Industry News and Trade Shows iPhone and Cell Phone Help iPod, Sony PSP and MP3 Player Help Mac OS X Help Pay Per Click (PPC) Advertising Search Engine Optimization (SEO) Shell Script Programming Tech Support Video Help The Writing Business Twitter, LinkedIn and Social Network Help Unix and Linux Help Video Game Tips and Help Windows PC Help WordPress Help |