def post(self): if not setup_occurred(): Status.load_defaults() Image.load_defaults() api.invalidate_cache() finish_setup() self.redirect("/admin")
def update_status(service_slug, status_type, message): service = Service.get_by_slug(service_slug) status = Status.get_by_slug(status_type) cur_event = service.events.order('-start').fetch(1) if cur_event and cur_event[0].status.slug != status.slug: e = Event(service=service, status=status, message=message) e.put() invalidate_cache()
def _save_result(self, site, level, message): service = Service.gql('WHERE name = :1', site).get() if not service: return status = Status.get_by_slug(level) if not status: self.response.out.write("Status %s not found" % site) return e = Event(status=status, service=service, message=message) e.informational = False e.put() api.invalidate_cache()
def check_service(self, service, tries_count=0, last_status_slug="", options=None, schedule=True): if not options: options = {} self.log("Checking %(service_name)s" % {"service_name": service.name}) check = self.check_host(options) if check["is_ok"]: tries_count = 0 status_slug = "up" countdown = settings.CHECK_SERVICES_NORMAL_CHECK_INTERVAL else: countdown = settings.CHECK_SERVICES_ERROR_CHECK_INTERVAL tries_count = int(tries_count) + 1 self.log( "Check count: %(count)s, limit is %(limit)s" % {"count": tries_count, "limit": settings.CHECK_SERVICES_MAX_TRIES} ) if check["is_unknown"]: status_slug = "unknown" else: status_slug = "down" if tries_count >= settings.CHECK_SERVICES_MAX_TRIES or check["is_ok"]: if not last_status_slug: last_event = service.current_event() if last_event: last_status_slug = last_event.status.slug else: last_status_slug = Status.get_default().slug if last_status_slug != status_slug: status = Status.get_by_slug(status_slug) logging.info( "%(service_name)s is : %(status)s (was %(last_status)s)" % {"service_name": service.name, "status": status_slug, "last_status": last_status_slug} ) self.update_service(service, status, check["message"]) self.log("invalidate_cache") api.invalidate_cache() self.notify_admin(service, status, check["notification_message"]) last_status_slug = status_slug if schedule: self.schedule_check(service.slug, countdown, tries_count, last_status_slug)
def get(self): api.invalidate_cache() self.response.out.write("Success")
def post(self): Status.load_defaults() Image.load_defaults() api.invalidate_cache() self.redirect("/admin")