About user_alert's method of automatically closing nodes
I'm writing a user_alert script and need to implement:
When a member in pool_check is down, the corresponding node is automatically closed;
When a member in pool_check is up, the corresponding node is automatically opened.
Below is my user_alert.conf configuration:
alert node100_down "Pool /Common/pool_check member /Common/10.1.20.100:80 monitor status down" {
exec command="tmsh modify ltm node 10.1.20.100 session user-disabled" }
alert node100_up "Pool /Common/pool_check member /Common/10.1.20.100:80 monitor status up" {
exec command="tmsh modify ltm pool pool_check members modify { 10.1.20.100:80 { session user-enabled } }";
exec command="tmsh modify ltm node 10.1.20.100 session user-enabled" }
But I want to optimize the configuration, because there are many members in my pool_check, and I want to identify these members through a method like "${IP}", such as:
alert node100_down "Pool /Common/pool_check member /Common/${IP}:80 monitor status down" {
exec command="tmsh modify ltm node ${IP} session user-disabled" }
But if I write the script like this, it will cause the alertd process to restart indefinitely, which may be a syntax error.
But now I can only configure each member like this:
alert node100_down "Pool /Common/pool_check member /Common/10.1.20.100:80 monitor status down" {
exec command="tmsh modify ltm node 10.1.20.100 session user-disabled" }
alert node100_down "Pool /Common/pool_check member /Common/10.1.20.200:80 monitor status down" {
exec command="tmsh modify ltm node 10.1.20.200 session user-disabled" }
How do I achieve this? Please teach me, thank you!