Chapter 8 Using the CSS Scripting Language
Script Keepalive Examples
8-60
Cisco Content Services Switch Administration Guide
OL-5647-02
! This may require a little explanation. Since we just want to see
! if the DNS server is alive we will send a simple DNS Query. This
! query is hard coded in hexadecimal and sent raw to the DNS server.
! The DNS request has a 12 byte header (as seen for the first 12 bytes
! of hex) and then a DNS name (ie. www.cisco.com). Lastly it follows
! with some null termination and a few bytes representing query type.
! See RFC-1035 for more.
set EXIT_MSG “Send: failure”
socket send ${SOCKET}
“0002010000010000000000000377777705636973636f03636f6d0000010001” raw
! Receive some unexplained response. We don't care what it is because
! an unstable DNS server or a non-existent one would probably not send
! us any data back at all.
set EXIT_MSG “Receive: Failed to receive data”
socket receive ${SOCKET}
no set EXIT_MSG
socket disconnect ${SOCKET}
exit script 0
Echo Keepalive
!no echo
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Filename: ap-kal-echo
! Parameters: HostName [ udp | tcp ]
!
! Description:
! This script will send a TCP or UDP echo (depending on what the
! user has passed to us) that will echo “Hello Cisco” to the
! remote host, and expect it to come back. The default protocol
! is TCP.
!
! Failure Upon:
! 1. Not establishing a connection with the host (TCP Only).
! 2. Not being able to retrieve an echoed message back
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Make sure the user has a qualified number of arguments
if ${ARGS}[#] “NEQ” “2”
if ${ARGS}[#] “NEQ” “1”
echo “Usage: ap-kal-echo \'Hostname [ udp | tcp ]\'”
exit script 1
endbranch
endbranch