public IActionResult Get()
        {
            _logger.LogInformation(LoggingEvents.Healthcheck, "Healthcheck Requested");
            var hc = new Healthcheck();

            //hc.Status = "Unhealthy";
            hc.Status = "Healthy";
            return(Ok(hc));
        }
Beispiel #2
0
        public IActionResult Heartbeat()
        {
            Healthcheck hCheck = new Healthcheck();

            hCheck.IsAppHealthy = true;
            var con     = JobStorage.Current.GetConnection();
            var servers = JobStorage.Current.GetMonitoringApi().Servers();

            var dateTimeExpire = DateTime.UtcNow.AddMinutes((-1 * appsettings.JobSchedules.HeartBeatExpireMinute));

            if (servers.All(x => x.Heartbeat.HasValue && x.Heartbeat < dateTimeExpire))
            {
                hCheck.IsAppHealthy = false;  //server stop alert
            }
            // deporter Job
            var DeporterJob = con.GetAllEntriesFromHash($"recurring-job:{"Deporter"}");

            hCheck.DeporterAgentsHealth = GetJobState(con, DeporterJob);

            // Queues Job
            List <string> QueueJobsStatus = new List <string>();
            var           activeQueues    = queueService.GetByStatus(true);

            foreach (var activeQueue in activeQueues)
            {
                var QueueJob = con.GetAllEntriesFromHash($"recurring-job:{string.Format("Publisher-{0}", activeQueue.Name)}");
                QueueJobsStatus.Add(GetJobState(con, QueueJob));
            }
            if (QueueJobsStatus.All(x => x == "Recurring job not started"))
            {
                hCheck.PublisherAgentsHealth = "Recurring job not started";
            }
            else
            {
                int    succeedQueueJob = QueueJobsStatus.Where(x => x == "excellent").Count();
                double postOfficePCT   = ((Double)succeedQueueJob / activeQueues.Count()) * 100;
                if (postOfficePCT == 100.0)
                {
                    hCheck.PublisherAgentsHealth = "excellent";
                }
                if (postOfficePCT < 100.0 && postOfficePCT >= 50.0)
                {
                    hCheck.PublisherAgentsHealth = "moderate";
                }
                if (postOfficePCT < 50.0)
                {
                    hCheck.PublisherAgentsHealth = "critical";
                }
            }

            // TitleSync Job
            var TitleSyncJob = con.GetAllEntriesFromHash($"recurring-job:{"TitleSync"}");

            hCheck.TitleSyncAgentsHealth = GetJobState(con, TitleSyncJob);

            return(Json(hCheck));
        }
Beispiel #3
0
 public HealthcheckController(Healthcheck healthcheck)
 {
     this.healthcheck = healthcheck;
 }