use of com.cloud.agent.api.HostStatsEntry in project cloudstack by apache.
the class StatsCollector method createInfluxDbPointForHostMetrics.
/**
* Sends host metrics to a configured InfluxDB host. The metrics respects the following specification.</br>
* <b>Tags:</b>vm_id, uuid, instance_name, data_center_id, host_id</br>
* <b>Fields:</b>memory_total_kb, memory_internal_free_kbs, memory_target_kbs, cpu_utilization, cpus, network_write_kb, disk_read_iops, disk_read_kbs, disk_write_iops, disk_write_kbs
*/
protected Point createInfluxDbPointForHostMetrics(Object metricsObject) {
HostStatsEntry hostStatsEntry = (HostStatsEntry) metricsObject;
Map<String, String> tagsToAdd = new HashMap<>();
tagsToAdd.put(UUID_TAG, hostStatsEntry.getHostVo().getUuid());
Map<String, Object> fieldsToAdd = new HashMap<>();
fieldsToAdd.put(TOTAL_MEMORY_KBS_FIELD, hostStatsEntry.getTotalMemoryKBs());
fieldsToAdd.put(FREE_MEMORY_KBS_FIELD, hostStatsEntry.getFreeMemoryKBs());
fieldsToAdd.put(CPU_UTILIZATION_FIELD, hostStatsEntry.getCpuUtilization());
fieldsToAdd.put(CPUS_FIELD, hostStatsEntry.getHostVo().getCpus());
fieldsToAdd.put(CPU_SOCKETS_FIELD, hostStatsEntry.getHostVo().getCpuSockets());
fieldsToAdd.put(NETWORK_READ_KBS_FIELD, hostStatsEntry.getNetworkReadKBs());
fieldsToAdd.put(NETWORK_WRITE_KBS_FIELD, hostStatsEntry.getNetworkWriteKBs());
return Point.measurement(INFLUXDB_HOST_MEASUREMENT).tag(tagsToAdd).time(System.currentTimeMillis(), TimeUnit.MILLISECONDS).fields(fieldsToAdd).build();
}
use of com.cloud.agent.api.HostStatsEntry in project cloudstack by apache.
the class LibvirtGetHostStatsCommandWrapper method execute.
@Override
public Answer execute(final GetHostStatsCommand command, final LibvirtComputingResource libvirtComputingResource) {
CPUStat cpuStat = libvirtComputingResource.getCPUStat();
MemStat memStat = libvirtComputingResource.getMemStat();
final double cpuUtil = cpuStat.getCpuUsedPercent();
final double loadAvg = cpuStat.getCpuLoadAverage();
final Pair<Double, Double> nicStats = libvirtComputingResource.getNicStats(libvirtComputingResource.getPublicBridgeName());
final HostStatsEntry hostStats = new HostStatsEntry(command.getHostId(), cpuUtil, nicStats.first() / 1024, nicStats.second() / 1024, "host", memStat.getTotal() / 1024, memStat.getAvailable() / 1024, 0, loadAvg);
return new GetHostStatsAnswer(command, hostStats);
}
Aggregations