Retrieving Hit Count and Last Hit Date Using Python

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

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:


#!/usr/bin/env python


import sys

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



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


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


L0 Member


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:

  • 2 replies
  • 71 Subscriptions
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!