Palo Alto | Get security rule hit counts using XML API call on a Python script
# GET HIT COUNTS FROM ALL SECURITY RULES #
import requests
params = {
'key': '{INSERT XML API KEY HERE}',
'type': 'op',
}
data = {
'cmd': "<show><rule-hit-count><vsys><vsys-name><entry name='vsys1'><rule-base><entry name='security'><rules><all></all></rules></entry></rule-base></entry></vsys-name></vsys></rule-hit-count></show>",
}
response = requests.post('https://{FIREWALL MGMT IP}/api/', params=params, data=data, verify=False)
print (response.text)
# GET HIT COUNT FROM SPECIFIC SECURITY RULE #
import requests
params = {
'key': '{INSERT XML API KEY HERE}',
'type': 'op',
}
data = {
'cmd': "<show><rule-hit-count><vsys><vsys-name><entry name='vsys1'><rule-base><entry name='security'><rules><list><member>{FIREWALL RULE NAME}</member></list></rules></entry></rule-base></entry></vsys-name></vsys></rule-hit-count></show>",
}
response = requests.post('https://{FIREWALL MGMT IP}/api/', params=params, data=data, verify=False)
print (response.text)
Comentarios
Publicar un comentario