TNY_122436
Feb 01, 2016Nimbostratus
Cisco Ace ldap probe script to F5 equivalent health probe
Does anyone know how I can convert this script from Cisco Ace to an equivalent F5 script? Thanks in advance.
Code !name = LDAP_PROBE
Description:
Script sends a 'bind request' to ldap server and expect server return 'success'
status code in the bind response. Probe success only if server return a bind responde
with status code 0x0a0100
ACE version :
1.0+
Parameters:
[DEBUG]
DEBUG - optional key word 'DEBUG'. default is off
Example config :
probe ldapProbe script
script LDAP_PROBE
probe ldapProbe script
script LDAP_PROBE DEBUG
Copyright (c) 2005-2006 by cisco Systems, Inc.
-------------------------------------------
debug procedure
set the EXIT_MSG environment varaible to help debug
also print the debug message when debug flag is on
-------------------------------------------
proc ace_debug { msg } {
global debug ip port EXIT_MSG
set EXIT_MSG $msg
if { [ info exists ip ] && [ info exists port ] } {
set EXIT_MSG "[ info script ]:$ip:$port: $EXIT_MSG "
}
if { [ info exists debug ] && $debug } {
puts $EXIT_MSG
}
}
-------------------------------------------
main
-------------------------------------------
parse cmd line args and initialize variables
set debug value
set debug 1
if { [ regsub -nocase "DEBUG" $argv "" argv] } {
set debug 1
}
ace_debug "initializing varaible"
set EXIT_MSG "Error config: script LDAP_PROBE \[DEBUG\]"
set ip "dsq1ldap"
set port "3890"
set ip $scriptprobe_env(realIP)
set port $scriptprobe_env(realPort)
if port is zero the use well known ldap port 389
if { $port == 0 } {
set port 3890
}
PROBE START
open connection
ace_debug "opening socket"
set sock [ socket $ip $port ]
fconfigure $sock -buffering line -translation binary
send a standard anonymous bind request
ace_debug "sending ldap bind request"
puts -nonewline $sock [ binary format "H*" 3031020101602c0201030419636e3d6c6f616462616c616e6365722c636e3d636f6e666967800c6c6f616462616c616e636572 ]
flush $sock
read string back from server
ace_debug "receiving ldap bind result"
set line [read $sock 14]
binary scan $line H* res
binary scan $line @7H6 code
ace_debug "recived $res with code $code"
ace_debug "sending unbind"
puts -nonewline $sock [ binary format "H*" 30050201034200 ]
flush $sock
close connection
ace_debug "closing socket"
close $sock
make probe fail by exit with 30002 if ldap reply code != success code 0x0a0100
if { $code != "0a0100" } {
ace_debug " probe failed : expect response code \'0a0100\' but received \'$code\'"
exit 30002
}
make probe success by exit with 30001
ace_debug "probe success"
exit 30001