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

Former-commit-id: e63179b6d3d27a8f9c3cd0103d8b1f6eeba238dd
pull/191/head
Yu Kun 2019-10-14 13:02:19 +08:00
parent d482246191
commit 8a49d11d0d
2 changed files with 12 additions and 2 deletions

View File

@ -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

View File

@ -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