Virtual_ Server_ Monitoring_(iRule)
Problem this snippet solves:
Hi Community,
The goal is to get a html page with the status of the virtual servers. For this we need the following: 1) "VirtualServers_Monitorizados.txt" (this file contains the name of the virtual servers that you want to monitor)
2) "virtualserver_list.sh" (This script reads the contents of the file "VirtualServers_Monitorizados.txt" and generates a class file called "lista_vs_poolmembers.class")
3) "lista_vs_poolmembers.class" (is generated by script "virtualserver_list.sh" and this file contains the virtual servers names, ips, pools and members pools with a particular structure) STRUCTURE: VirtualServerName/VirtualServerIP:VirtualServerPort/PoolName/PoolMember1:PoolMemberPort1,PoolMember2:PoolMemberPort2,
4) "iRule_Monitorizacion.tcl" (this iRule reads the content of the file "lista_vs_poolmembers.class" and generate a dynamic html page with the virtual servers and members status)
The "virtualserver_list.sh" script can be run with crontab: - Create a file in the following path /etc/cron.daily/virtualserver_list.cron - Change the permissions by entering chmod +755 /etc/cron.daily/virtualserver_status_list.cron
For iRule can read from a external file: - Create a external datagroup Main >> Local Traffic >> iRules Select Data Group List Click create enter name: lista_vs_poolmembers enter Type: External Path / Filename: /var/class/lista_vs_poolmembers.class File Content: String
The last steps are: - Create a new iRule - Create a new Virtual Server and assign the iRule. Through this service we obtain monitoring
In my scenario I get the Virtual Servers Status connecting to "http://IP_Virtual_Server_Monitor/status"
I've attachmented a ZIP file with: - virtualserver_list.sh - iRule_Monitorizacion.tcl - file example for "VirtualServers_Monitorizados.txt"
Thanks David Díez
Code :
###################################################################################### ###################################################################################### ### ### ### Nombre: Monitorizacion_Virtual_Servers ### ### Autor: David Diez @ Siemens Enterprise Communications ### ### Fecha: 05/11/2010 ### ### Descripcion: Genera una pagina HTML al vuelo con el estado actual de los ### ### Virtual Servers y Nodos. Lee los datos de un Data Group (.class) ### ### generado por un bash script que se ejecuta 1 o 2 veces/dia ### ### ### ###################################################################################### ###################################################################################### when HTTP_REQUEST { if { [HTTP::uri] eq "/status" } { set html_status_gral "" set general_status "UP" set response_init "BIGIP Monitorizacion Servicios Virtuales - \ [clock format [clock seconds]] " set response_total "
BIGIP Virtual Server Status - \ [clock format [clock seconds]]
Virtual Server | \VS IP | VS Status | \Nodos | \Nodos Status |
---|---|---|---|---|
$addr:$port | \UP | |||
$addr:$port | \DOWN | |||
$addr:$port | \ENABLED | |||
$addr:$port | \DISABLED | |||
$addr:$port | \INVALID | |||
$addr:$port | \UP | |||
$addr:$port | \DOWN | |||
$addr:$port | \ENABLED | |||
$addr:$port | \DISABLED | |||
$addr:$port | \INVALID | |||
\ $vs_name | \$vs_addr_port | \$vs_status | " } else { set response "||
\ $vs_name | \$vs_addr_port | \$vs_status | " } append response $aux_response # En cuanto uno de los VS est? DOWN cambiamos el valor de la variable ya # status general ya que hay q marcar down elstatus general append response_total $response } errmsg] } { # no hacemos nada.. Ya que el VS es erroneo o no tiene pool asignado continue #append response_total "||
PRUEBA2 | \ #INVALID |
ESTADO GENERAL |
---|
UP |
ESTADO GENERAL |
---|
DOWN |