PyCounters seems to count occurences per second. I´d like to increase the duration the counter gets counted up to one minute, so i get occurences per minute in the munin graphs. I use the @frequency decorator to count occurences. Any hints ?
1 Answers
I'm not sure if this is still a problem. But for the sake of completeness - here is an answer.
There are a couple things at play here. First, PyCounters calculates a running on a window of 5 minutes (default setting). If you want per minute averages you need to change that. Then there is the question of the frequency of outputting the counters to a file. This is different because you want to have a 5-minute average outputted every minute. Last, you have munin data collection which runs by default every 5 minute as well.
I'm not sure what you want to achieve but here is how you can change the PyCounters part (for more details see http://pycounters.readthedocs.org/en/latest/tutorial.html#step-5-more-about-events-and-counters )
Hope this helps, Boaz
Changing output frequency of PyCounters
When you tell PyCounters to start auto reporting you can set the interval (as mentioned by Joran):
pycounters.start_auto_reporting(seconds=60)
Changing the size of the averaging window
This is slightly more tricky as you you will need to define a Frequency counter your self (if this is not clear checkout the tutorial for more info: http://pycounters.readthedocs.org/en/latest/tutorial.html
Step 1- define a frequency settings with an averaging window of 1 minute:
req_per_sec = counters.FrequencyCounter("requests_frequency", window_size=60)
register_counter(req_per_sec)
Step 2 - use the report_start_end decorator (although frequency will do just fine too)
@pycounters.report_start_end("requests_frequency")
def func():
pass

- 25,331
- 21
- 69
- 77