f5-common-python icon indicating copy to clipboard operation
f5-common-python copied to clipboard

RFE: Ability to reset statistics

Open jbnance opened this issue 6 years ago • 4 comments

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()).

jbnance avatar Jun 06 '18 15:06 jbnance

@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

wojtek0806 avatar Jun 07 '18 22:06 wojtek0806

@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 avatar Jun 21 '18 20:06 jasonrahm

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?

jasonrahm avatar Jul 06 '18 20:07 jasonrahm

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

wojtek0806 avatar Aug 08 '18 09:08 wojtek0806