use of com.emc.vipr.model.sys.healthmonitor.ServiceHealth in project coprhd-controller by CoprHD.
the class HealthMonitorService method getNodeHealth.
/**
* Method that returns node and it services health.
*
* @return NodeHealth
*/
protected NodeHealth getNodeHealth(String nodeId, String nodeName, String nodeIP, List<String> availableServices) {
try {
_log.info("List of available services: {}", availableServices);
String nodeStatus = Status.GOOD.toString();
List<ServiceHealth> serviceHealthList = NodeHealthExtractor.getServiceHealth(NodeStatsExtractor.getServiceStats(availableServices), _coordinatorClientExt.getCoordinatorClient(), nodeId);
for (ServiceHealth serviceHealth : serviceHealthList) {
if (Status.UNAVAILABLE.toString().equals(serviceHealth.getStatus()) || Status.DEGRADED.toString().equals(serviceHealth.getStatus())) {
nodeStatus = Status.DEGRADED.toString();
break;
}
}
return new NodeHealth(nodeId, nodeName, nodeIP, nodeStatus, serviceHealthList);
} catch (Exception e) {
_log.error("Internal error occurred while getting node health. {}", e);
_log.debug(ExceptionUtils.getStackTrace(e));
throw APIException.internalServerErrors.getObjectError("health for node " + nodeId, e);
}
}
use of com.emc.vipr.model.sys.healthmonitor.ServiceHealth in project coprhd-controller by CoprHD.
the class SystemHealth method services.
public static void services(String nodeId) {
NodeHealth nodeHealth = MonitorUtils.getNodeHealth(nodeId);
if (nodeHealth != null) {
List<ServiceHealth> serviceHealthList = nodeHealth.getServiceHealthList();
if (!serviceHealthList.isEmpty()) {
renderArgs.put("dataTable", new NodeServicesDataTable());
angularRenderArgs().put("nodeStatus", nodeHealth.getStatus());
angularRenderArgs().put("serviceCount", serviceHealthList.size());
angularRenderArgs().put("statusCount", getStatusCount(serviceHealthList));
angularRenderArgs().put("nodeId", nodeId);
angularRenderArgs().put("nodeName", nodeHealth.getNodeName());
render(nodeId);
} else {
flash.error(Messages.get("system.node.services.error", nodeHealth.getNodeName()));
}
} else {
Logger.warn("Could not determine node name.");
flash.error(Messages.get("system.node.error", nodeId));
}
systemHealth();
}
use of com.emc.vipr.model.sys.healthmonitor.ServiceHealth in project coprhd-controller by CoprHD.
the class SystemHealth method listServicesJson.
public static void listServicesJson(String nodeId) {
List<ServiceStats> serviceStatsList = MonitorUtils.getNodeStats(nodeId).getServiceStatsList();
List<ServiceHealth> serviceHealthList = MonitorUtils.getNodeHealth(nodeId).getServiceHealthList();
List<NodeServicesDataTable.Services> servicesList = Lists.newArrayList();
for (ServiceStats service : serviceStatsList) {
for (ServiceHealth health : serviceHealthList) {
if (service.getServiceName().equals(health.getServiceName())) {
servicesList.add(new NodeServicesDataTable.Services(nodeId, health, service));
}
}
}
renderJSON(DataTablesSupport.createSource(servicesList, params));
}
use of com.emc.vipr.model.sys.healthmonitor.ServiceHealth in project coprhd-controller by CoprHD.
the class SystemHealth method getStatusCount.
private static Map<String, Integer> getStatusCount(List<ServiceHealth> serviceList) {
Map<String, Integer> statusCount = Maps.newHashMap();
// Initialize Map so with a "Good" status to have 0 services so when we display, if no other service is "Good" it will still display
// that in UI.
statusCount.put(Status.GOOD.toString(), 0);
for (ServiceHealth service : serviceList) {
Integer count = statusCount.get(service.getStatus());
statusCount.put(service.getStatus(), (count == null) ? 1 : ++count);
}
return statusCount;
}
use of com.emc.vipr.model.sys.healthmonitor.ServiceHealth in project coprhd-controller by CoprHD.
the class SystemHealth method healthDetails.
private static Map<String, Object> healthDetails(NodeStats nodeStats, NodeHealth nodeHealth) {
MemoryStats memoryStats = nodeStats.getMemoryStats();
DataDiskStats dataDiskStats = nodeStats.getDataDiskStats();
Capacity rootCapacity = new Capacity();
Capacity dataCapacity = new Capacity();
Capacity memoryCapacity = new Capacity();
if (memoryStats != null) {
long freeMem = memoryStats.getMemFree() + memoryStats.getMemBuffers() + memoryStats.getMemCached();
memoryCapacity = new Capacity((memoryStats.getMemTotal() - freeMem), memoryStats.getMemTotal());
}
if (dataDiskStats != null) {
rootCapacity = new Capacity(dataDiskStats.getRootUsedKB(), dataDiskStats.getRootUsedKB() + dataDiskStats.getRootAvailKB());
dataCapacity = new Capacity(dataDiskStats.getDataUsedKB(), dataDiskStats.getDataUsedKB() + dataDiskStats.getDataAvailKB());
}
List<ServiceHealth> serviceHealthList = nodeHealth.getServiceHealthList();
Map<String, Integer> statusCount = getStatusCount(serviceHealthList);
Map<String, Object> nodeDetails = Maps.newHashMap();
nodeDetails.put("serviceCount", serviceHealthList.size());
nodeDetails.put("cpuLoad", nodeStats.getLoadAvgStats());
nodeDetails.put("memoryCapacity", memoryCapacity);
nodeDetails.put("rootCapacity", rootCapacity);
nodeDetails.put("dataCapacity", dataCapacity);
nodeDetails.put("statusCount", statusCount);
return nodeDetails;
}
Aggregations