예제 #1
0
 def post(self):
     if not setup_occurred():
         Status.load_defaults()
         Image.load_defaults()
         api.invalidate_cache()
         finish_setup()
     self.redirect("/admin")
예제 #2
0
 def post(self):
     if not setup_occurred():
         Status.load_defaults()
         Image.load_defaults()
         api.invalidate_cache()
         finish_setup()
     self.redirect("/admin")
예제 #3
0
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()
예제 #4
0
    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()
예제 #5
0
    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)
예제 #6
0
 def get(self):
     api.invalidate_cache()
     self.response.out.write("Success")
예제 #7
0
 def post(self):
     Status.load_defaults()
     Image.load_defaults()
     api.invalidate_cache()
     self.redirect("/admin")
예제 #8
0
 def get(self):
     api.invalidate_cache()
     self.response.out.write("Success")
예제 #9
0
 def post(self):
     Status.load_defaults()
     Image.load_defaults()
     api.invalidate_cache()
     self.redirect("/admin")