Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
New Member

How do I monitor two service ports in a server ?

The web service is alive when tcp port 80 and 8080 are both alive. How do I use script to monitor both ports at the same time ? Any example for this case ? Thanks.

2 REPLIES
New Member

Re: How do I monitor two service ports in a server ?

Here is a script I have written for this - you can test as many ports as you want on one server with this script.

To run just add under the service as:

service test

keepalive type script socket-test.txt "172.17.10.10 8080 80 443"

Hope this helps,

Regards,

Darren.

-------------- Begin Script -----------------------------

!======================================================

! Filename: socket-test.txt

! Parameters: Host port1 port2 port3

!

! This script does the following:

! Connects to a remote host on a specified tcp sockets,

! waits for X seconds and then disconnects.

!

! Failure Upon:

! Not establishing a connection with the host. If one connection

! fails, the script fails.

!

!

! Usage to run manually:

! script play socket-test.txt

!

! Useage to run automaticlly:

! cmd-sched

! cmd-sched record 1 * * * * * "script play socket-test.txt"

!

!

! Written by Darren Page, Dimension Data

!

!======================================================

!

!no echo

!

! Make sure the user has a qualified number of arguments

if ${ARGS}[#] "LT" "2"

echo "Usage: socket-test.txt \'host socket1 socket2 socket3 ...'"

exit script 1

endbranch

set host "${ARGS}[1]"

! get the first tcp port ready from the ARGS array

var-shift ARGS

while ${ARGS}[#] "GT" "0"

set EXIT_MSG "Connect: Failed to connect to ${host}"

! Connect to remote host on specified port

socket connect host ${host} port ${ARGS}[1] tcp 2000

! Wait one second

pause 1

! disconnect from remote host with a TCP FIN

socket disconnect ${SOCKET} graceful

! Wait one second

pause 1

!get the next port from the array

var-shift ARGS

no set EXIT_MSG

! Demarcation of the end of the loop

endbranch

exit script 0

-------------End of Script ------------------

New Member

Re: How do I monitor two service ports in a server ?

Hello Darren, thank a lots.

136
Views
0
Helpful
2
Replies
CreatePlease to create content