-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for hit count in Panorama Object #388
Comments
🎉 Thanks for opening your first issue here! Welcome to the community! |
This is present already, docs need to be clarified about opstate stuff. Say you want hit count info for all pre-rulebase security rules in device group "myDg": from panos.panorama import Panorama, DeviceGroup
from panos.policies import PreRulebase, SecurityRule
pano = Panorama(....)
dg = DeviceGroup("myDg")
pano.add(dg)
base = PreRulebase()
dg.add(base)
info = dg.opstate.hit_count.refresh("security", all_rules=True) If you just want hit count info for a specific rule, then use the |
Hello @shinmog
Here is my full code:
using pan-os-python==1.6.0 |
My bad. Looks like device groups don't have a hit count op state; individual rules do, and the rulebases do (policies.PreRulebase, policies.Rulebase, policies.PostRulebase). |
Same here, would really help to be able to get hit counts for rules from Panorama. |
I tried the following and received an error:
|
## [1.7.0](v1.6.0...v1.7.0) (2022-03-29) ### Features * Add Prisma Access support ([#419](#419)) ([f93416e](f93416e)), closes [#406](#406) [#413](#413) [#396](#396) * Add decryption rule target and negate_target ([#404](#404)) ([88a2903](88a2903)) * Add hierarchy retrieval info ([#366](#366)) ([a290b31](a290b31)) * Add hit count support for Panorama / device group rulebases ([#429](#429)) ([057822a](057822a)), closes [#388](#388) * **panos.panorama.Panorama:** Add `refresh_shared_objects()` ([#436](#436)) ([11327a4](11327a4)), closes [#428](#428) * Add alternative quoting for `op()` ([#367](#367)) ([b8d0379](b8d0379)), closes [#234](#234) * Add Cloud Services plugin support ([683f3b5](683f3b5)) * Add Local User Database objects ([#385](#385)) ([d39b6de](d39b6de)) * Add objects.ApplicationOverride ([#405](#405)) ([98db86a](98db86a)) * Add policies.AuthenticationRule ([#415](#415)) ([0d70d3f](0d70d3f)) * ApplicationTag - tag predefined applications ([#414](#414)) ([cfee6e3](cfee6e3)) * Make opstate more discoverable for users ([#413](#413)) ([f4f08d0](f4f08d0)), closes [#396](#396) ### Bug Fixes * **panos.objects.ApplicationFilter:** Fix tag path ([#381](#381)) ([a0991f8](a0991f8)) * `delete_similar()` now breaks delete calls into chunks ([#435](#435)) ([4333377](4333377)) * Fixes `refresh()` for attrib style params ([#395](#395)) ([0b47a3a](0b47a3a)), closes [#392](#392) * Modify show_highavailability_state method xpath for Panorama ([#430](#430)) ([37ed2ca](37ed2ca)) * **AggregateInterface:** Correct lacp_passive_pre_negotiation xpath ([6a67320](6a67320)), closes [#406](#406)
🎉 This issue has been resolved in version 1.7.0 🎉 The release is available on PyPI and GitHub release
|
Hi @shinmog, just following up on this. It appears I'm unable to get the hitcounts (updated version to 1.7.2). I tried the following but it returns an empty dictionary: `from panos.panorama import Panorama, DeviceGroup us = "xxx" dg = DeviceGroup("my-DG") rb = PostRulebase() hc = rb.opstate.hit_count.refresh("security", all_rules=True) |
@ajmartins replace the following :
by
And it should help. However, please not that you'll get the "rule_creation_timestamp" and "rule_modification_timestamp", but not the "hit_count", "last_hit_timestamp", or "last_reset_timestamp" are those are not tracked by Panorama. |
hello @AnthoBalitrand the hit count seems to be track in rule usage in panorama. |
I'm resuming this old issue because I encountered the same problem. As a workaround I found that is possibile to perform this action to get hitcount for rule. For example if I want to extract the hitcount for a rule in post-rulebase section for a device-group-name I can perform:
It will return an xml ElementTree that can be iterated. I'm not a guru in python so please correct my example:
I hope that this will help other users with the same issue. |
Is your feature request related to a problem?
I would like to gather hit_count for security rules from Panorama. I've seen this feature implemented with the Firawall object and I was wondering if we could do the same for the Panoram object. Unless I missed something it seems that there is nothing similar for panorama.
Describe the solution you'd like
Something similar to this commit: 7a2e95b
Describe alternatives you've considered
I could pass an xml to
Panorama.op
but I rather work with object.I see a
panos.policies.RulebaseOpState
imbricated in SecurityRule response and I trying to leverage this with no success.I want to be able to retrieve security rules and their associated hit_count. If a process already exist please let me know how to do it.
The text was updated successfully, but these errors were encountered: