An interactive Python agent that connects directly to F5 BIG-IP via iControl REST API for real-time monitoring and querying.
┌─────────────────┐ HTTPS/443 ┌─────────────────┐
│ F5 Agent │ ◄─────────────► │ F5 BIG-IP │
│ │ iControl REST │ 172.16.10.10 │
│ ┌─────────────┐ │ API │ │
│ │ Interactive │ │ │ ┌─────────────┐ │
│ │ CLI Thread │ │ │ │ Pools │ │
│ └─────────────┘ │ │ │ Members │ │
│ │ │ │ Virtuals │ │
│ ┌─────────────┐ │ │ │ Logs │ │
│ │ Background │ │ │ └─────────────┘ │
│ │ Monitor │ │ │ │
│ │ (30s poll) │ │ │ │
│ └─────────────┘ │ │ │
└─────────────────┘ └─────────────────┘
│
▼
┌─────────────────┐
│ Network Engineer│
│ Command Prompt │
│ │
│ > status │
│ > pools │
│ > summary │
│ > quit │
└─────────────────┘
- Interactive CLI Interface - Real-time command prompt for querying F5 state
- Background Monitoring - Continuous 30-second polling with state change alerts
- Token-based Authentication - Secure iControl REST API access
- Multi-threaded Design - Monitor and interact simultaneously
- Real-time State Detection - Instant alerts when pool members change state
- Comprehensive Querying - Pools, virtual servers, logs, and health summaries
- Create and activate a virtual environment:
# Create virtual environment
python3 -m venv f5-agent-env
# Activate virtual environment (macOS/Linux)
source f5-agent-env/bin/activate
# Activate virtual environment (Windows)
f5-agent-env\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Configure your F5 credentials in
f5_agent.py:
F5_HOST = "172.16.10.10"
F5_USERNAME = "admin"
F5_PASSWORD = "W3lcome098!"Run the agent:
python f5_agent.pyThe agent will:
- Connect to F5 management interface at https://172.16.10.10
- Authenticate using token-based auth
- Start interactive command interface
- Monitor pool member states in background
- Allow real-time queries and state inspection
Once running, you can use these commands:
help- Show available commandsstatus- Show overall F5 connection statuspools- List all pools and member statespool <name>- Show detailed info for specific poolvirtual- Show virtual servers and their statuslogs- Show recent system logssummary- Show health summary with percentagesquit- Exit the agent
The agent continuously monitors in the background and will alert you to any pool member state changes.
$ python f5_agent.py
[2025-08-20 10:30:15] Starting F5 Interactive Agent
[2025-08-20 10:30:15] Target: 172.16.10.10
Type 'help' for commands or 'quit' to exit
------------------------------------------------------------
[2025-08-20 10:30:15] Authentication successful
> status
F5 Status for 172.16.10.10:
Connected: Yes
Last updated: 2025-08-20 10:30:20
Pool members: 8 total, 6 up, 2 down
> pools
Pool Status:
web_pool: 3/4 members up
✓ web1 (10.1.1.10) - up
✓ web2 (10.1.1.11) - up
✓ web3 (10.1.1.12) - up
✗ web4 (10.1.1.13) - down
api_pool: 3/4 members up
✓ api1 (10.1.2.10) - up
✓ api2 (10.1.2.11) - up
✓ api3 (10.1.2.12) - up
✗ api4 (10.1.2.13) - down
> summary
F5 Health Summary for 172.16.10.10:
Overall Health: 75.0%
Pool Members: 6/8 operational
Members DOWN:
✗ web_pool/web4 (10.1.1.13)
✗ api_pool/api4 (10.1.2.13)
Virtual Servers: 4/4 enabled
Last Check: 2025-08-20 10:30:25
> pool web_pool
Pool 'web_pool' Details:
Member: web1
Address: 10.1.1.10
State: up
Session: enabled
Connection Limit: 1000
Member: web2
Address: 10.1.1.11
State: up
Session: enabled
Connection Limit: 1000
[2025-08-20 10:31:22] STATE CHANGE: web_pool/web4 down -> up
>
Pool 'web_pool' now 4/4 members up!
> quit
Goodbye!- Authentication - Agent authenticates with F5 using admin credentials
- Background Thread - Starts continuous monitoring (30s intervals)
- Interactive Thread - Waits for user commands at prompt
- API Calls - Each command triggers specific iControl REST endpoints:
status→/mgmt/tm/ltm/pool(member counts)pools→/mgmt/tm/ltm/pool+/mgmt/tm/ltm/pool/{name}/membersvirtual→/mgmt/tm/ltm/virtuallogs→/mgmt/tm/sys/log
- State Tracking - Background thread compares states and alerts on changes
- Real-time Updates - State changes interrupt user prompt immediately
- Real-time data access
- Can get more than just logs (stats, config, etc.)
- Can take actions (disable pool members, etc.)
- Direct API access without intermediate systems