I am trying to locate virtual server configs in my F5 environment that are configured to log all traffic requests. Obviously, this has a detrimental impact to F5 logging performance. Is there a way to use the TMSH shell or REST API to interrogate the F5 appliance via a script and get a listing of all virtuals that use a “log all traffic” policy so I can change the policy and give our logging servers a bit of respite?
Whipped up a sample python script using the bigrest module to iterate through multiple hosts and virtuals…only tested against my one host and virtual, but should be a start as an idea of what you can do:
from bigrest.bigip import BIGIP
with open('hosts.txt', 'r') as hostfile:
hosts = [line.strip() for line in hostfile]
for host in hosts:
b = BIGIP(host, 'admin', 'admin', session_verify=False)
try:
vips = b.load('/mgmt/tm/ltm/virtual')
for vip in vips:
if 'securityLogProfiles' in vip.properties.keys():
if '"/Common/Log all requests"' in vip.properties.get('securityLogProfiles'):
print(f'Host: {host}, Virtual: {vip.properties.get("name")}')
except Exception as e:
print(e)