in src/Microsoft.Azure.WebJobs.Host/Scale/DefaultHostProcessMonitor.cs [85:139]
public HostProcessStatus GetStatus(ILogger logger = null)
{
var healthResult = new HostProcessStatus
{
State = HostHealthState.Unknown
};
// get the current stats for the host process
ProcessStats hostProcessStats = _hostProcessMonitor.GetStats();
// get the current stats for any child processes
RemoveExitedChildProcesses();
ProcessMonitor[] currChildProcessMonitors;
lock (_syncLock)
{
// snapshot the current set of child monitors
currChildProcessMonitors = _childProcessMonitors.ToArray();
}
IEnumerable<ProcessStats> childProcessStats = currChildProcessMonitors.Select(p => p.GetStats()).ToList();
var exceededLimits = new List<string>();
HostHealthState cpuStatus = GetCpuStatus(hostProcessStats, childProcessStats, logger);
var statuses = new List<HostHealthState>
{
cpuStatus
};
if (cpuStatus == HostHealthState.Overloaded)
{
exceededLimits.Add(CpuLimitName);
}
HostHealthState memoryStatus = GetMemoryStatus(hostProcessStats, childProcessStats, logger);
statuses.Add(memoryStatus);
if (memoryStatus == HostHealthState.Overloaded)
{
exceededLimits.Add(MemoryLimitName);
}
if (statuses.All(p => p == HostHealthState.Unknown))
{
healthResult.State = HostHealthState.Unknown;
}
else if (statuses.Any(p => p == HostHealthState.Overloaded))
{
healthResult.State = HostHealthState.Overloaded;
}
else
{
healthResult.State = HostHealthState.Ok;
}
healthResult.ExceededLimits = exceededLimits.AsReadOnly();
return healthResult;
}