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'
class LiveStatus(object): """A class that represents the status of all objects in the broker """ def __init__(self, datamgr, query_cache, db, pnp_path, return_queue): self.datamgr = datamgr self.query_cache = query_cache self.db = db self.pnp_path = pnp_path self.return_queue = return_queue self.counters = LiveStatusCounters() def handle_request(self, data): try: return self.handle_request_and_fail(data) except LiveStatusQueryError, exp: # LiveStatusQueryError(404, table) # LiveStatusQueryError(450, column) code, detail = exp.args response = LiveStatusResponse() response.output = LiveStatusQueryError.messages[code] % detail response.statuscode = code if 'fixed16' in data: response.responseheader = 'fixed16' return response.respond() except Exception, exp: print "exception!!!", exp response = LiveStatusResponse() response.output = LiveStatusQueryError.messages[452] % data response.statuscode = 452 if 'fixed16' in data: response.responseheader = 'fixed16' return response.respond()
def handle_request(self, data): try: return self.handle_request_and_fail(data) except LiveStatusQueryError, exp: # LiveStatusQueryError(404, table) # LiveStatusQueryError(450, column) code, detail = exp.args response = LiveStatusResponse() response.output = LiveStatusQueryError.messages[code] % detail response.statuscode = code if 'fixed16' in data: response.responseheader = 'fixed16' return response.respond()
class LiveStatus(object): """A class that represents the status of all objects in the broker """ def __init__(self, datamgr, query_cache, db, pnp_path, return_queue): self.datamgr = datamgr self.query_cache = query_cache self.db = db self.pnp_path = pnp_path self.return_queue = return_queue self.counters = LiveStatusCounters() def handle_request(self, data): try: return self.handle_request_and_fail(data) except LiveStatusQueryError, exp: # LiveStatusQueryError(404, table) # LiveStatusQueryError(450, column) code, detail = exp.args response = LiveStatusResponse() response.output = LiveStatusQueryError.messages[code] % detail response.statuscode = code if 'fixed16' in data: response.responseheader = 'fixed16' return response.respond() except Exception, exp: logger.error("[Livestatus] Exception! %s" % exp) # Also show the exception output = cStringIO.StringIO() traceback.print_exc(file=output) logger.error("[Livestatus] Back trace of this exception: %s" % (output.getvalue())) output.close() # Ok now we can return something response = LiveStatusResponse() response.output = LiveStatusQueryError.messages[452] % data response.statuscode = 452 if 'fixed16' in data: response.responseheader = 'fixed16' return response.respond()
def __init__(self, datamgr, query_cache, db, pnp_path, return_queue, counters): # Runtime data form the global LiveStatus object self.datamgr = datamgr self.query_cache = query_cache self.db = db self.pnp_path = pnp_path self.return_queue = return_queue self.counters = counters # Private attributes for this specific request self.response = LiveStatusResponse() self.authuser = None self.table = None self.columns = [] self.filtercolumns = [] self.prefiltercolumns = [] self.outputcolumns = [] self.stats_group_by = [] self.stats_columns = [] self.aliases = [] self.limit = None self.extcmd = False # Initialize the stacks which are needed for the Filter: and Stats: # filter- and count-operations self.filter_stack = LiveStatusStack() self.stats_filter_stack = LiveStatusStack() self.stats_postprocess_stack = LiveStatusStack() self.stats_query = False # When was this query launched? self.tic = time.time() # Clients can also send their local time with the request self.client_localtime = self.tic # This is mostly used in the Response.format... which needs to know # the class behind a queries table self.table_class_map = table_class_map
def __init__(self, *args, **kwargs): super(LiveStatusWaitQuery, self).__init__(*args, **kwargs) self.response = LiveStatusResponse() self.wait_start = time.time() self.wait_timeout = 0 self.wait_trigger = 'all'