Script to test my network connectivities


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to test my network connectivities
# 1  
Old 04-13-2010
Computer Script to test my network connectivities

Hello folks;
I have about 20 servers in my environment here as well as some applications such as MySql, Oracle, etc..
I need help writing a shell script that can go out and test the Internet connection by pinging servers as well as testing the Oracle & MySql connections.

Is there a way to do that or it has to be done manually?

Thanks in advance for your help
# 2  
Old 04-14-2010
to test the conectevity you can use the ping . if the $? is zero then everything is ok.If all the server have similar oracle/mysql config then you can check the ports on which the application is listening.

Code:
MACHINE=10.0.0.1 # Change to what ever you need
exec 3>/dev/tcp/${MACHINE}/1521
if [ $? -eq 0 ]
then
    echo "oracle accepting connections"
else
    echo "oracle connections not possible"
fi

# 3  
Old 04-14-2010
You can write a perl script using this module: Net::Ping - search.cpan.org
# 4  
Old 04-14-2010
MySQL

for exa our hostfile is
Code:
[root@sistem1lnx ~]# cat hostfile
10.100.110.100
10.100.110.101
10.100.110.102
10.100.110.103
10.100.110.104
.........
10.100.110.120

when ping loss over the %50 let the script send a mail
Code:
while read hostname
do
PL=`ping -c 10 $hostname |grep "% packet"|cut -d"%" -f1|awk '{print $8}'`
 if [ $PL -gt 50 ]
  then
   mail -s "There is a problem with access to $hostname -- ping loss % $PL" mailtoyour@domain.com < /dev/null 
   exit 1
 fi
done < hostfile

# 5  
Old 04-14-2010
Thanks folks.
for amitranjansahu:
I didn't have any luck with the script. I'd like to be able to scan all servers inside /etc/hosts one at a time for ping connection and some servers for a specific connection such as Oracle or MySql

For ygemici:
I did try using your script but it wasn't able to read the hostname ( i made change as well because field 8 is empty and it had to be changed to field 6)
Also my hostfile is under /etc/hosts (the script complained about not knowing the hostfile)
# 6  
Old 05-26-2010
If you need ping test you can get the ping test here http://www.whoisxy.com/ it provides domain,host information,ip address....
# 7  
Old 05-26-2010
Thanks Jeeva7
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Network stress test.

Hi there. First things first, this is nothing to do with the internet or ISP speed, I know what that is, I know what it's doing. I have a cluster of 128 single board computers running a branch of Debian. I want to run some kind of stress test to ensure they can transfer data (a) to each... (2 Replies)
Discussion started by: MuntyScrunt
2 Replies

2. Hardware

How to test the speed of your WIFI network?

Dear all, Would you know how to measure the max speed of a WIFI connection between a router and a laptop for instance? Many thanks for your help! Regards, (3 Replies)
Discussion started by: freddie50
3 Replies

3. IP Networking

Test Network Routing Issues (FREEBSD and RHEL)

Hello, I'm attempting to setup a test network with a client-server based architecture using a proprietary application. The client works by communicating with the server on separate links (typically cellular connections) and then initiates a tunnel over each active link. However, in place of the... (0 Replies)
Discussion started by: shadyuk
0 Replies

4. Shell Programming and Scripting

Backup script / Test if script is already running

Hello everyone, I have 2 questions : 1) I have a backup shell script, let's call it backup.sh, that is called every hour as a cron job. As a matter of fact a backup could last more than one hour. It mounts a NAS and then do some rsync on important directories, so really I don't want to... (2 Replies)
Discussion started by: freddie50
2 Replies

5. IP Networking

Test network routing algourithm

hi, I've wrote my own network routing algorithm in java, now i wanna test it and see if it works correctly, also i wanna test it's performance in comparison with other network routing algorithms like RIP. can anyone tell me how can i do this? is there any simulator or something for network routing... (0 Replies)
Discussion started by: gongotar
0 Replies

6. Shell Programming and Scripting

How to check weather a string is like test* or test* ot *test* in if condition

How to check weather a string is like test* or test* ot *test* in if condition (5 Replies)
Discussion started by: johnjerome
5 Replies

7. Shell Programming and Scripting

Test on string containing spacewhile test 1 -eq 1 do read a $a if test $a = quitC then break fi d

This is the code: while test 1 -eq 1 do read a $a if test $a = stop then break fi done I read a command on every loop an execute it. I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test. For example echo hello. Now the... (1 Reply)
Discussion started by: Max89
1 Replies

8. Shell Programming and Scripting

bash script to test network connection - please help

I want to test if my host can connect to any of the following 10 hosts (192.168.1.0 to 192.168.1.9) I didnt know which command i should use, so i chose ping. (i wonder if i should use tracepath or sth else) my code is the following: #!/bin/bash clear firstPart="192.168.1" maxNum="9" ... (2 Replies)
Discussion started by: shadow_boi
2 Replies

9. UNIX for Advanced & Expert Users

Network Shell Script & Blade Logic & Network Security

I am going to take up a position in Data & Network Security. I would need to write network shell scripts doing the following task: Going to around 2000 servers and findout which groups has access to each servers and which ids are there in each group that has access. I need to implement... (1 Reply)
Discussion started by: pinnacle
1 Replies
Login or Register to Ask a Question