def update_rolematchers(self): if (time.time() - self.last_update_time) > self.day_in_seconds: self.matchers = rolematcher.init() self.last_update_time = time.time() if self.matchers == []: # downloading the roles did not go well apparently # fall back to hardcoded roles. rolematcher.manual_init()
def __init__(self): '''This function should initialize any data structures or variables needed for the internal state of the line parser.''' self.last_update_time = time.time() self.day_in_seconds = 24 * 60 * 60 self.reset_state() self.lock = threading.RLock() # a list of rolematchers which are simple object to determine the role of a particular server # this list is obtained from crawling config-master.wikimedia.org/pybal and parse the available configurations self.matchers = rolematcher.init() # this is what will match the packet loss lines # packet loss format : # %[%Y-%m-%dT%H:%M:%S]t %server lost: (%percentloss +/- %margin) # [2011-10-26T21:20:25] sq86.wikimedia.org lost: (3.61446 +/- 19.67462)% # match keys: date, server, percentloss, margin self.reg = re.compile( '^\[(?P<date>[^]]+)\] (?P<server>[^ ]+) lost: \((?P<percentloss>[^ ]+) \+\/- (?P<margin>[^)]+)\)%' ) # assume we're in daemon mode unless set_check_duration gets called self.dur_override = False