|
|
|
@ -73,13 +73,8 @@ namespace CncService.Impl
|
|
|
|
public object GetCollectorStatus()
|
|
|
|
public object GetCollectorStatus()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var latest = _collectorHeartbeatRepository.GetLatest("collector-service");
|
|
|
|
var latest = _collectorHeartbeatRepository.GetLatest("collector-service");
|
|
|
|
bool isRunning = latest != null && latest.LastCollectTime.HasValue &&
|
|
|
|
bool isRunning = latest != null && latest.Status == "running";
|
|
|
|
(DateTime.Now - latest.LastCollectTime.Value).TotalMinutes < 5;
|
|
|
|
long uptimeSeconds = isRunning ? (latest.UptimeSeconds ?? 0) : 0;
|
|
|
|
long uptimeSeconds = 0;
|
|
|
|
|
|
|
|
if (isRunning && latest != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
uptimeSeconds = latest.UptimeSeconds ?? 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return new { status = isRunning ? "running" : "stopped", uptimeSeconds, lastCollectTime = latest?.LastCollectTime };
|
|
|
|
return new { status = isRunning ? "running" : "stopped", uptimeSeconds, lastCollectTime = latest?.LastCollectTime };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|