0

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 ?

georam
  • 494
  • 2
  • 5
  • 14
  • cant you do something like adding occurences and just `pycounters.start_auto_reporting(seconds=60)` then the occurences would contain your answer? not sure... I havent used this moduele – Joran Beasley Sep 10 '12 at 22:06

1 Answers1

0

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
Boaz
  • 25,331
  • 21
  • 69
  • 77