Search in sources :

Example 11 with HostStatsEntry

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();
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) HostStatsEntry(com.cloud.agent.api.HostStatsEntry)

Example 12 with HostStatsEntry

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);
}
Also used : GetHostStatsAnswer(com.cloud.agent.api.GetHostStatsAnswer) CPUStat(org.apache.cloudstack.utils.linux.CPUStat) HostStatsEntry(com.cloud.agent.api.HostStatsEntry) MemStat(org.apache.cloudstack.utils.linux.MemStat)

Aggregations

HostStatsEntry (com.cloud.agent.api.HostStatsEntry)12 GetHostStatsAnswer (com.cloud.agent.api.GetHostStatsAnswer)8 Answer (com.cloud.agent.api.Answer)4 CheckVirtualMachineAnswer (com.cloud.agent.api.CheckVirtualMachineAnswer)4 MaintainAnswer (com.cloud.agent.api.MaintainAnswer)4 ReadyAnswer (com.cloud.agent.api.ReadyAnswer)4 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)4 ConfigurationException (javax.naming.ConfigurationException)4 CheckHealthAnswer (com.cloud.agent.api.CheckHealthAnswer)3 CheckNetworkAnswer (com.cloud.agent.api.CheckNetworkAnswer)3 FenceAnswer (com.cloud.agent.api.FenceAnswer)3 GetStorageStatsAnswer (com.cloud.agent.api.GetStorageStatsAnswer)3 GetVmStatsAnswer (com.cloud.agent.api.GetVmStatsAnswer)3 GetVncPortAnswer (com.cloud.agent.api.GetVncPortAnswer)3 MigrateAnswer (com.cloud.agent.api.MigrateAnswer)3 ModifyStoragePoolAnswer (com.cloud.agent.api.ModifyStoragePoolAnswer)3 PrepareForMigrationAnswer (com.cloud.agent.api.PrepareForMigrationAnswer)3 RebootAnswer (com.cloud.agent.api.RebootAnswer)3 StartAnswer (com.cloud.agent.api.StartAnswer)3 StopAnswer (com.cloud.agent.api.StopAnswer)3