mirror of
https://github.com/clearlinux/WALinuxAgent.git
synced 2026-09-02 20:01:33 +00:00
* Report prolonged report status failures The agent report transient failures, but this is not very indicative of customer failures. The transient failures generally resolve themselves, so the transients are not very useful for a dashboard. This change tracks failures that repeat for 15 minutes, and then report them. If an operation fails and succeeds within 15 minutes, the timer resets. It must be a continual stream of errors for 15 minutes for this telemetry event to trigger. * default ErrorState's min_timedelta to a const
32 lines
691 B
Python
32 lines
691 B
Python
from datetime import datetime, timedelta
|
|
|
|
ERROR_STATE_DELTA = timedelta(minutes=15)
|
|
|
|
|
|
class ErrorState(object):
|
|
def __init__(self, min_timedelta = ERROR_STATE_DELTA):
|
|
self.min_timedelta = min_timedelta
|
|
|
|
self.count = 0
|
|
self.timestamp = None
|
|
|
|
def incr(self):
|
|
if self.count == 0:
|
|
self.timestamp = datetime.utcnow()
|
|
|
|
self.count += 1
|
|
|
|
def reset(self):
|
|
self.count = 0
|
|
self.timestamp = None
|
|
|
|
def is_triggered(self):
|
|
if self.timestamp is None:
|
|
return False
|
|
|
|
delta = datetime.utcnow() - self.timestamp
|
|
if delta >= self.min_timedelta:
|
|
return True
|
|
|
|
return False
|