myocella
Jan 22, 2009Nimbostratus
iRule to inspect MySQL statements
Greeting,
I would like to create iRule to apply a VS to redirect MySQL traffic
to a pool based on the SQL statement. Here is my iRule:
---------------8<------------------------------
when CLIENT_ACCEPTED {
if { ( [IP::addr [IP::client_addr] equals a.a.b.b] ) or ( [IP::addr [IP::client_addr] equals c.c.d.d] ) } {
log local0.none "true"
snat xx.xx.xx.xx
log local0.none "SNAT completed"
TCP::collect
log local0.none "Data collected"
}
}
when CLIENT_DATA {
log local0.none "CLIENT_DATA"
if { [TCP::payload] contains "select" } {
pool mysql_read_pool
} else {
pool mysql_write_pool
}
TCP::release
}
-------------->8-----------------------------------
The CLIENT_ACCEPTED works as it is instructed. However, I couldn't
see the source IP was SNAT(ed) to xx.xx.xx.xx, and CLIENT_DATA
wasn't executed at all.
This VS is for accepting MySQL connections from 2 web servers (a.a.b.b and
c.c.d.d).
Can anyone shed some light on this?
Thanks
myOcella