Commit 19edc3c4 authored by 余昆's avatar 余昆
Browse files

MS-647 [monitor] grafana display average cpu-temp


Former-commit-id: 5c86a0ad129f77a1f59ee8927b5d132395c60d81
parent 60b1edcb
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ Please mark all change in change log and use the ticket from JIRA.
- MS-640 - Cache object size calculate incorrect
- MS-641 - Segment fault(signal 11) in PickToLoad
- MS-639 - SQ8H index created failed and server hang
- MS-647 - [monitor] grafana display average cpu-temp

## Improvement
- MS-552 - Add and change the easylogging library
+11 −2
Original line number Diff line number Diff line
@@ -222,10 +222,19 @@ PrometheusMetrics::CPUTemperature() {

    std::vector<float> CPU_temperatures = server::SystemInfo::GetInstance().CPUTemperature();

    float avg_cpu_temp = 0;
    for (int i = 0; i < CPU_temperatures.size(); ++i) {
        prometheus::Gauge& cpu_temp = CPU_temperature_.Add({{"CPU", std::to_string(i)}});
        cpu_temp.Set(CPU_temperatures[i]);
        avg_cpu_temp += CPU_temperatures[i];
    }
    avg_cpu_temp /= CPU_temperatures.size();

    prometheus::Gauge& cpu_temp = CPU_temperature_.Add({{"CPU", std::to_string(0)}});
    cpu_temp.Set(avg_cpu_temp);

//    for (int i = 0; i < CPU_temperatures.size(); ++i) {
//        prometheus::Gauge& cpu_temp = CPU_temperature_.Add({{"CPU", std::to_string(i)}});
//        cpu_temp.Set(CPU_temperatures[i]);
//    }
}

void