def __init__(self, *args, **kwargs): #super(LiveStatusWaitQuery, self).__init__(*args, **kwargs) LiveStatusQuery.__init__(self, *args, **kwargs) self.response = LiveStatusResponse(responseheader = 'off', outputformat = 'csv', keepalive = 'off', columnheaders = 'off', separators = LiveStatusResponse.separators) self.wait_start = time.time() self.wait_timeout = 0 self.wait_trigger = 'all'
def __init__(self, *args, **kwargs): #super(LiveStatusWaitQuery, self).__init__(*args, **kwargs) LiveStatusQuery.__init__(self, *args, **kwargs) self.response = LiveStatusResponse(responseheader='off', outputformat='csv', keepalive='off', columnheaders='undef', separators=LiveStatusResponse.separators) self.response = LiveStatusResponse() self.wait_start = time.time() self.wait_timeout = 0 self.wait_trigger = 'all'
def parse_input(self, data): """Parse the lines of a livestatus request. This function looks for keywords in input lines and sets the attributes of the request object """ external_cmds = [] query_cmds = [] wait_cmds = [] for line in data.splitlines(): line = line.strip() # Tools like NagVis send KEYWORK:option, and we prefer to have # a space following the: if ':' in line and ' ' not in line: line = line.replace(':', ': ') keyword = line.split(' ')[0].rstrip(':') if len(line) == 0: pass elif keyword in ('GET', ): query_cmds.append(line) wait_cmds.append(line) elif keyword in ('WaitObject', 'WaitCondition', 'WaitConditionOr', 'WaitConditionAnd', 'WaitTrigger', 'WaitTimeout'): wait_cmds.append(line) elif keyword in ('COMMAND', ): external_cmds.append(line) else: query_cmds.append(line) if len(external_cmds) > 0: for external_cmd in external_cmds: query = LiveStatusCommandQuery(self.datamgr, self.query_cache, self.db, self.pnp_path, self.return_queue, self.counters) query.parse_input(external_cmd) self.queries.append(query) if len(wait_cmds) > 1: query = LiveStatusWaitQuery(self.datamgr, self.query_cache, self.db, self.pnp_path, self.return_queue, self.counters) query.parse_input('\n'.join(wait_cmds)) self.queries.append(query) if len(query_cmds) > 0: query = LiveStatusQuery(self.datamgr, self.query_cache, self.db, self.pnp_path, self.return_queue, self.counters) query.parse_input('\n'.join(query_cmds)) self.queries.append(query)