F5Networks / f5-common-python

Python SDK for configuration and monitoring of F5® BIG-IP® devices via the iControl® REST API.
https://f5-sdk.readthedocs.org
Apache License 2.0
262 stars 133 forks source link

RFE: Ability to reset statistics #1454

Open jbnance opened 6 years ago

jbnance commented 6 years ago

Issue #293 added support for pulling virtual server / pool / etc statistics but it appears that support for resetting statistics was not included. I'd like to request the addition of this functionality.

It may make sense to add a "delete" function which resets the statistics (e.g., virtual.stats.delete()).

wojtek0806 commented 6 years ago

@jbnance hello , the way you reset stats is by issuing reset command via TMSH, from what I recall we can do this by adding ability to send command payloads to stats endpoints. I need to look at it at some point

jasonrahm commented 6 years ago

@wojtek0806 FYI, the way this is done via rest is (for example, a pool):

POST /mgmt/tm/ltm/pool {"command": "reset-stats", "name": "testpool"}

Effectively we'll need to enable exec_cmd on collections as well.

jasonrahm commented 6 years ago

this should be a simple addition of the CommandExecutionMixin to the collections of interest for stats. Any objections @wojtek0806 to selecting the obvious objects this would apply and starting there?

wojtek0806 commented 6 years ago

you can enable that on all of the stats endpoints here: https://github.com/F5Networks/f5-common-python/blob/6a612fcd801507f8d91f0d8e22d670379249bbf3/f5/bigip/resource.py#L1232

Modify this class to inherit from command mixin:

https://github.com/F5Networks/f5-common-python/blob/development/f5/bigip/mixins.py

Or do this per endpoint if it is less messy