cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
432
Views
0
Helpful
1
Replies

CSS - Executing a Keepalive Script

ritchieb
Level 1
Level 1

Hi,

I am trying to execute the following script, this script is testing connectivity on multiple hosts and TCP ports to define a service as 'up'

#!name = CHECKPORT_STD_SCRIPT

########################################################################################

#

# Scriptname : CheckPortsTask.tcl

# Pamapaters : <list of hosts ip >

# <list of ports >

# [verbose] optional verbose debug flag.

#

# Description :

# This is an example of standalone script. The script is given a list of hosts

# and a list of posrts for each host. The script then checks to see if the host:port

# is available and listening.

#

# Example execution:

# script task 1 "10.2.0.12 10.2.0.14 10.5.0.15" " 21 23 80 2048"

#

#

#

########################################################################################

proc ck_puts { msg } {

puts "[ info script ] : $msg"

}

#-------------------------------------------

# main

#-------------------------------------------

# parse cmd line args and setup ip , port

if { $argc != 2 } {

ck_puts "paramaters: script task <id> [ info script ] <hostList> <portList>"

exit -1

}

set hostList [ lindex $argv 0 ]

set portList [ lindex $argv 1 ]

ck_puts "================= test start========================="

foreach ip $hostList {

ck_puts "----------------- host $ip-------------------------"

foreach port $portList {

ck_puts "testing $ip:$port"

if { [catch { socket $ip $port } sock ] } {

ck_puts "\t$ip:$port ERR : $sock"

if { [ regexp "connection timed out" $sock ] } {

## erro due to connection timeout, skip to next ip

break;

}

## other error, don't break, keep test next port for the same ip

} else {

ck_puts "\t$ip:$port OK"

close $sock

}

}

}

ck_puts "================= test end========================="

My issue is that the comments suggest the arguements are put into 2 sections of quotations but the CSS will not allow this input....

CSS11503(config-service[TEST-SERVICE])# keepalive type script checkportstask ?

<cr> Execute command

use-output Allow tools such as grep to parse script output

<Quoted text> Script Arguments (Len: 0-128)

CSS11503(config-service[TEST-SERVICE])# keepalive type script checkportstask

CSS11503(config-service[TEST-SERVICE])# keepalive type script checkportstask "10.1.1.1 10.2.2.2" "80 443"

^

%% Invalid input detected at '^' marker.

CSS11503(config-service[TEST-SERVICE])#

Can anyone shed some light on how this script is executed.

Thanks,

Brian

1 Reply 1

Gilles Dufour
Cisco Employee
Cisco Employee