====== Health Monitor use TCL ====== A10 support [[http://zh.wikipedia.org/wiki/Tcl|TCL]] (Tool Command Language) to scripting health check with youself. ===== THE NOTICE FOR TCL ===== - In A10, make sure you filaname have extension that is ".tcl"! - If you are just searching for a fixed sequence of characters, use string operations. - If you are searching for a pattern, then use [[http://en.wikipedia.org/wiki/Regular_expression|regexp]](regular expressions). ===== Config Guide Example ===== Here is copy from config guide. It open a socket connect to HTTP, and get /1.html then paeser a string. # Init server status to "DOWN" set ax_env(Result) 1 # Open a socket if {[catch {socket $ax_env(ServerHost) $ax_env(ServerPort)} sock]} { puts stderr "$ax_env(ServerHost): $sock" } else { fconfigure $sock -buffering none -eofchar {} # Send the request puts $sock "GET /1.html HTTP/1.0\n" # Wait for the response from http server set line [read $sock] if { [ regexp "HTTP/1.. (\[0-9\]+) " $line match status] } { puts "server $ax_env(ServerHost) response : $status" # Check exit code if { $status == 200 } { # Set server to be "UP" set ax_env(Result) 0 } } close $sock } ===== Check for TCP socket ===== # Init server status to "DOWN" set ax_env(Result) 1 # Open a socket if {[catch {socket $ax_env(ServerHost) $ax_env(ServerPort)} sock]} { puts stderr "$ax_env(ServerHost): $sock" } else { fconfigure $sock -buffering none -eofchar {} # Send the request "some_string" and return puts $sock "talk\n" # Wait for the response from TCP service set line [read $sock] if { [ regexp "Works" $line ] } { # Set server to be "UP" set ax_env(Result) 0 } close $sock }