Problem this snippet solves:
Needed to record the resource impact of iRules on the F5 system, this script was written to convert the iRule stats output from TMSH into CSV format.
If you clear the stats down and get the stats post testing or after a set interval e.g. 1 hour of production traffic. You should be able to work out the resource hungry iRules and as we did optimise them.
How to use this snippet:
Usage:
statformating.py -i <iRule Stats input txt file> -o <output CSV file>
This script takes the output of F5 iRule stats from the commend `tmsh show ltm rule` and formats into a CSV file
to allow for easy analysis of iRule resource impact.
Recommend clearing all iRule stats between running.
The following commands are examples used to clear and capture the iRule stats for a traffic test:
Clear all iRules from Bash:
tmsh reset-stats ltm rule "/*/*"
Run test traffic
Capture iRule stats and save to file from Bash:
tmsh show ltm rule "/*/*" > irulestats.txt
Copy off irulesstas.txt file and run against this script using:
statformating.py -i irulestats.txt -o irulestats.csv
Code :
#!/usr/bin/python
'''
Usage:
statformating.py -i -o
Tested this on version:
12.1