Shell-script - Check the response of multiple server, Netcat - Test servers response time
Check the response of multiple server
Below is a simple script to test multiple servers responce. Here we are testing whether the port 22 is open or not.for a in $(seq -f "mylin%04g" 411 1 414) do nc -zvw 2 $a 22 doneOutput:
nc: connect to mylin0411 port 22 (tcp) timed out: Operation now in progress
nc: connect to mylin412 port 22 (tcp) timed out: Operation now in progress
nc: connect to mylin0413 port 22 (tcp) timed out: Operation now in progress
nc: connect to mylin0414 port 22 (tcp) timed out: Operation now in progress
Netcat command to test the port 22.
nc -zvw 2 mylin0411 22Output:
nc: connect to el0411 port 22 (tcp) timed out: Operation now in progress
nc -zvw 2 mylin0411 22Output:
nc: timeout cannot be negative
nc -zvw 2 ourlinux 22
OUTPUT:
Connection to ourlinux 22 port [tcp/ssh] succeeded!
where,
z - Specifies that nc should just scan for listening daemons, without sending any data to them. It is an error to use this option in conjunction with the -l option.
v - Have nc give more verbose output.
w : timeout - If a connection and stdin are idle for more than timeout seconds, then the connection is silently closed. The -w flag has no effect on the -l option, i.e. nc will listen forever for a connection, with or without the -w flag. The default is no timeout.
The topic on Shell-script - Check the response of multiple server is posted by - Math
Hope you have enjoyed, Shell-script - Check the response of multiple serverThanks for your time