def reload_nagios(): code, stdout, stderr = exec_script('/etc/init.d/nagios reload') if code != 0: logger.warning("%s" % stderr) else: logger.info("reload_nagios successfully") return code, stdout, stderr
def command(request, command): commands = os.listdir("/opt/nagios/lib/plugins/") if command in commands: code, stdout, stderr = exec_script("/opt/nagios/lib/plugins/%s" % command) return HttpResponse(stdout, content_type="text/plain") else: logger.debug("Command Unauthorized") return build_response_with_message("Command Unauthorized", 401)
def downtime_disable(host): utcnow = calendar.timegm(datetime.utcnow().utctimetuple()) downtime_id = get_downtime_id(host) if downtime_id == "id_not_found": return downtime_id else: code, stdout, stderr = exec_script('/usr/bin/printf "[%%lu] DEL_HOST_DOWNTIME;%s\n" %s > /var/nagios/rw/nagios.cmd' % (downtime_id,utcnow)) return code
def command(request, command): commands = os.listdir("/opt/nagios/lib/plugins/") if command in commands: code, stdout, stderr = exec_script("/opt/nagios/lib/plugins/%s" % command) return HttpResponse(stdout, content_type="text/plain") else: logger.debug("Command Unauthorized") return build_response_with_message('Command Unauthorized', 401)
def downtime_disable(host): utcnow = calendar.timegm(datetime.utcnow().utctimetuple()) downtime_id = get_downtime_id(host) if downtime_id == "id_not_found": return downtime_id else: code, stdout, stderr = exec_script( '/usr/bin/printf "[%%lu] DEL_HOST_DOWNTIME;%s\n" %s > /var/nagios/rw/nagios.cmd' % (downtime_id, utcnow)) return code
def downtime_enable(host, author, comment): utcnow = calendar.timegm(datetime.utcnow().utctimetuple()) code, stdout, stderr = exec_script('/usr/bin/printf "[%%lu] SCHEDULE_HOST_DOWNTIME;%s;%s;1893456000;1;0;0;%s;%s\n" > /var/nagios/rw/nagios.cmd' %(host, utcnow, author, comment)) return code
def downtime_enable(host, author, comment): utcnow = calendar.timegm(datetime.utcnow().utctimetuple()) code, stdout, stderr = exec_script( '/usr/bin/printf "[%%lu] SCHEDULE_HOST_DOWNTIME;%s;%s;1893456000;1;0;0;%s;%s\n" > /var/nagios/rw/nagios.cmd' % (host, utcnow, author, comment)) return code