def get_page(): # We get all value we want time_stamp = request.forms.get('time_stamp', int(time.time())) host_name = request.forms.get('host_name', None) service_description = request.forms.get('service_description', None) return_code = request.forms.get('return_code', -1) output = request.forms.get('output', None) # We check for auth if it's not anonymously allowed if app.username != 'anonymous': basic = parse_auth(request.environ.get('HTTP_AUTHORIZATION', '')) # Maybe the user not even ask for user/pass. If so, bail out if not basic: abort(401, 'Authentication required') # Maybe he do not give the good credential? if basic[0] != app.username or basic[1] != app.password: abort(403, 'Authentication denied') # Ok, here it's an anonymouscall, or a registred one, but mayeb teh query is false if time_stamp == 0 or not host_name or not output or return_code == -1: abort(400, "Incorrect syntax") # Maybe we got an host, maybe a service :) if not service_description: cmd = '[%s] PROCESS_HOST_CHECK_RESULT;%s;%s;%s' % (time_stamp, host_name, return_code, output) else: cmd = '[%s] PROCESS_SERVICE_CHECK_RESULT;%s;%s;%s;%s' % (time_stamp, host_name, service_description, return_code, output) # Now create the external command and put it in our main queue() # so the arbiter will read it :) ext = ExternalCommand(cmd) app.from_q.put(ext)
host_name_list = request.forms.getall(key='host_name') logger.debug("[Ws_arbiter] host_name_list: %s" % (host_name_list)) service_description_list = request.forms.getall(key='service_description') logger.debug("[Ws_arbiter] service_description_list: %s" % (service_description_list)) return_code_list = request.forms.getall(key='return_code') logger.debug("[Ws_arbiter] return_code_list: %s" % (return_code_list)) output_list = request.forms.getall(key='output') logger.debug("[Ws_arbiter] output_list: %s" % (output_list)) commands_list = get_commands(time_stamp_list, host_name_list, service_description_list, return_code_list, output_list) except Exception, e: logger.error("[Ws_arbiter] failed to get the lists: %s" % str(e)) commands_list = [] # We check for auth if it's not anonymously allowed if app.username != 'anonymous': basic = parse_auth(request.environ.get('HTTP_AUTHORIZATION', '')) # Maybe the user not even ask for user/pass. If so, bail out if not basic: abort(401, 'Authentication required') # Maybe he do not give the good credential? if basic[0] != app.username or basic[1] != app.password: abort(403, 'Authentication denied') # Adding commands to the main queue() logger.debug("[Ws_arbiter] commands = %s" % str(sorted(commands_list))) for c in sorted(commands_list): ext = ExternalCommand(c) app.from_q.put(ext) # OK here it's ok, it will return a 200 code
logger.debug("[Ws_arbiter] service_description_list: %s" % (service_description_list)) return_code_list = request.forms.getall(key='return_code') logger.debug("[Ws_arbiter] return_code_list: %s" % (return_code_list)) output_list = request.forms.getall(key='output') logger.debug("[Ws_arbiter] output_list: %s" % (output_list)) commands_list = get_commands(time_stamp_list, host_name_list, service_description_list, return_code_list, output_list) except Exception, e: logger.error("[Ws_arbiter] failed to get the lists: %s" % str(e)) commands_list = [] # We check for auth if it's not anonymously allowed if app.username != 'anonymous': basic = parse_auth(request.environ.get('HTTP_AUTHORIZATION', '')) # Maybe the user not even ask for user/pass. If so, bail out if not basic: abort(401, 'Authentication required') # Maybe he do not give the good credential? if basic[0] != app.username or basic[1] != app.password: abort(403, 'Authentication denied') # Adding commands to the main queue() logger.debug("[Ws_arbiter] commands = %s" % str(sorted(commands_list))) for c in sorted(commands_list): ext = ExternalCommand(c) app.from_q.put(ext) # OK here it's ok, it will return a 200 code