better handling of intervals
* reducing the actual processing time from the interval, so it runs in more accurate intervals independent of the processing time. * if processing time takes longer than the interval, we run it instantly
This commit is contained in:
parent
9c0cc58ab6
commit
aec4f100ee
@ -35,12 +35,14 @@ class Munin():
|
|||||||
"""Bootstrap method to start processing hosts's Munin stats."""
|
"""Bootstrap method to start processing hosts's Munin stats."""
|
||||||
self.connect()
|
self.connect()
|
||||||
self.update_hostname()
|
self.update_hostname()
|
||||||
self.process_host_stats()
|
processing_time = self.process_host_stats()
|
||||||
|
interval = self.args.interval
|
||||||
|
|
||||||
while True and self.args.interval != 0:
|
while True and interval != 0:
|
||||||
time.sleep(self.args.interval)
|
sleep_time = max(interval - processing_time, 0)
|
||||||
|
time.sleep(sleep_time)
|
||||||
self.connect()
|
self.connect()
|
||||||
self.process_host_stats()
|
processing_time = self.process_host_stats()
|
||||||
|
|
||||||
def update_hostname(self):
|
def update_hostname(self):
|
||||||
"""Updating hostname from connection hello string."""
|
"""Updating hostname from connection hello string."""
|
||||||
@ -183,6 +185,7 @@ class Munin():
|
|||||||
self.close_connection()
|
self.close_connection()
|
||||||
logging.info("Finished querying host %s (Execution Time: %.2f sec).",
|
logging.info("Finished querying host %s (Execution Time: %.2f sec).",
|
||||||
self.hostname, end_timestamp)
|
self.hostname, end_timestamp)
|
||||||
|
return end_timestamp
|
||||||
|
|
||||||
def send_to_carbon(self, timestamp, plugin_name, plugin_config, plugin_data):
|
def send_to_carbon(self, timestamp, plugin_name, plugin_config, plugin_data):
|
||||||
"""Send plugin data to Carbon over Pickle format."""
|
"""Send plugin data to Carbon over Pickle format."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user