Health Monitor use TCL

A10 support TCL (Tool Command Language) to scripting health check with youself.

THE NOTICE FOR TCL

  1. In A10, make sure you filaname have extension that is “.tcl”!
  2. If you are just searching for a fixed sequence of characters, use string operations.
  3. If you are searching for a pattern, then use 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.

http_check.tcl
# 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

tcp_check.tcl
# 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
}
a10/slb/healthmonitor/tcl.txt · 上一次變更: 2012/06/18 11:44 由 jal
上一頁 | 下一頁 | 回首頁 | RSS Feed | Facebook