?
Solved

need the script to test the ping response for 30 solaris servers and need to redirect the output to a file.

Posted on 2011-10-21
6
Medium Priority
?
1,536 Views
Last Modified: 2013-11-17
We would need the script to test the ping response for 30 solaris servers and need to redirect the output to a file. The working shell is Ksh.
0
Comment
Question by:rammaghenthar
6 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 37006496
Assuming that you have a list of servernames in a file servers.lst, one servername per line:

while read server
 do
   ping -c1 -w1 $server >> pingresults.txt
 done < servers.lst

wmp

0
 
LVL 19

Accepted Solution

by:
xterm earned 1336 total points
ID: 37006541
This assumes a file with a list of either IPs or hostnames, one per line called myhosts.txt:

$  cat myhosts.txt
10.10.0.1
foo.bar.com
baz.foo.net

$ cat myscript.sh
#!/bin/sh
OUTFILE="mypingdebug.txt"
for SERVER in `cat myhosts.txt`;
do
        # if pinging machine is Solaris
        ping -s $SERVER 56 4 >> $OUTFILE
        # if you only want the summary of the output, Solaris
        ping -s $SERVER 56 4 | tail -3 >> $OUTFILE
        # if pinging machine is Linux
        ping -c4 $SERVER >> $OUTFILE
        # if you only want the summary of the output, Linux
        ping -c4 $SERVER | tail -3 >> $OUTFILE
done

In myscript.sh, there are several ping options depending on what you want to log, so put a # sign in front of the 3 that don't apply.
0
 
LVL 19

Assisted Solution

by:xterm
xterm earned 1336 total points
ID: 37006560
And this one will let you customize how many pings you want to send to each box:

$ cat myscript.sh
#!/bin/sh
OUTFILE="mypingdebug.txt"
PINGCOUNT="4"
for SERVER in `cat myhosts.txt`;
do
        # if pinging machine is Solaris
        ping -s $SERVER 56 $PINGCOUNT >> $OUTFILE
        # if you only want the summary of the output, Solaris
        ping -s $SERVER 56 $PINGCOUNT | tail -3 >> $OUTFILE
        # if pinging machine is Linux
        ping -c$PINGCOUNT $SERVER >> $OUTFILE
        # if you only want the summary of the output, Linux
        ping -c$PINGCOUNT $SERVER | tail -3 >> $OUTFILE
done
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 7

Assisted Solution

by:icenick
icenick earned 664 total points
ID: 37011167
Hello,

Based on the comments from the other experts, you can send each ping command to the background (using &) so your script can run faster (and not wait for each ping to finish), i.e.:

ping ... >> $OUTFILE &

Open in new window


Good Luck!
0
 
LVL 25

Expert Comment

by:madunix
ID: 37014945
or fping -c 10 <dest1> <dest2> ... <destN>
0
 
LVL 62

Expert Comment

by:gheist
ID: 37016811
smokeping is a good option to automate the task (outputs tp database and displays graph from there)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question