Retrieving Hit Count and Last Hit Date Using Python

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements

Retrieving Hit Count and Last Hit Date Using Python

L0 Member

We have several firewall managed via Panorama. I want to pull the rulebase from each firewall to get the Hit Count and Last Hit date. I've got partial script, but I'm lost on accessing dict.

 

Here are the two links that I've been using:

 

https://pan-os-python.readthedocs.io/en/latest/module-policies.html#panos.policies.RulebaseHitCount

 

https://pan-os-python.readthedocs.io/en/latest/_modules/panos/policies.html#RulebaseHitCount

 

#!/usr/bin/env python

 

import sys

import panos
from panos.firewall import Firewall
from panos.policies import Rulebase, SecurityRule, RulebaseHitCount


HOSTNAME = ""
USERNAME = " "
PASSWORD = " "

 

fw = panos.firewall.Firewall(HOSTNAME, USERNAME, PASSWORD)

 

rulebase = RulebaseHitCount('security', rules=None, all_rules=False)

2 REPLIES 2

L0 Member

Hi,

have you resolved this issue?

L5 Sessionator

Use the opstate namespace hanging off of the panos.policies.SecurityRule instance.  There's a whole section of the documentation devoted to opstate stuff, you can see it here:

 

https://pan-os-python.readthedocs.io/en/latest/getting-started.html#the-opstate-namespace

  • 2523 Views
  • 2 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!