Generate qkview or ucs on failover
Problem this snippet solves:
This iCall script collects a qkview and a UCS after a failover event. It is hardcoded for traffic-group-1.
How to use this snippet:
Implementation Details
This iCall script requires v11.4 or higher. The script can be loaded via:
load sys config merge file /var/tmp/handle-failover.conf
Code :
sys icall script detect-failover { app-service none definition { # prime the iApp to assume it's standby so that it doesn't generate # a qkview+ucs on the initial run (which wouldn't be a state # transition) set old_status standby while { 1 } { # this will block until another event is present. As we only # subscribe to HA events, that means that whenever an event is # raised it represents a new message from SOD EVENT::get_next set new_status $EVENT::context(/Common/traffic-group-1) # detect if we just went standby if { $new_status eq "standby" && $old_status ne "standby" } { puts "failover detected - i am standby now!" set date [clock format [clock seconds] -format "%Y%m%d%H%M%S"] set settings [tmsh::get_config sys global-settings] set host [tmsh::get_field_value [lindex $settings 0] hostname] puts "generating qkview /var/tmp/$host-$date.qkview" exec /usr/bin/qkview -f /var/tmp/$host-$date.qkview 2> /dev/null & puts "generating UCS /var/local/ucs/$host-$date.ucs" tmsh::save sys ucs /var/local/ucs/$host-$date.ucs } # save the state set old_status $new_status } } description none events none } sys icall handler perpetual handle-failover { script detect-failover subscriptions { failover { event-name FAILOVER_STATE } } }
Updated Jun 06, 2023
Version 2.0Brent_Blood_102
Historic F5 Account
Joined July 06, 2006
- Jonathan_124522Nimbostratus
How do you stop this once you have loaded it?
- JC_BWNimbostratus
To prevent execution should just require removing the handler: delete sys icall handler perpetual handle-failover