Forum Discussion
Nikolay_Matveev
Mar 23, 2016Nimbostratus
APM: terminate active session via API
Is it possible to obtain a list of active APM session and then terminate one of them using an API?
I assumed this could be done using iControl REST API but failed to find any relevant informati...
Vladimir_Akhmarov
Apr 26, 2020Cirrus
Hello all!
Recently deployed such a solution:
- Created iCall script with session termination logic (thanks Yann)
- Created iCall handler with type perpetual
- Used iControlREST to execute iCall handler
See Yann's article
Create your own iCall script and handler:
sys icall script ApmSessionPurge_script { ... }
sys icall handler perpetual ApmSessionPurge_handler { script ApmSessionPurge_script }
In the end of "definition" section of your iCall script add below commands. This command must be used because once perpetual handler will be started someone must stop it.
# Stop iCall handler after execution
catch {[exec -- /bin/tmsh stop sys icall handler perpetual ApmSessionPurge_handler]}
Shell example to use iControlREST:
BIGIP_ADDR='192.0.2.1'
BIGIP_USER='admin'
BIGIP_PSWD='admin123'
BIGIP_HDLR='ApmSessionPurge_handler'
BIGIP_AUTH=$(curl -sk -H 'Content-Type: application/json' -X POST -d "{'username':'"$BIGIP_USER"', 'password':'"$BIGIP_PSWD"', 'loginProviderName':'tmos'}" https://${BIGIP_ADDR}/mgmt/shared/authn/login)
# Use sed -nE below for regular Linux/MacOS
BIGIP_TOKEN=$(echo $BIGIP_AUTH | sed -nr 's/.*\"token\":\"([A-Z0-9]+)\".*/\1/p')
curl -sk -H 'Content-Type: application/json' -H "X-F5-Auth-Token: $BIGIP_TOKEN" -X POST -d "{\"command\":\"start\", \"name\":\"$BIGIP_HDLR\"}" https://${BIGIP_ADDR}/mgmt/tm/sys/icall/handler/perpetual
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects