翻译:使用文本收集器生成快速感应指标

来源:互联网 发布:windows old有什么用 编辑:程序博客网 时间:2024/06/14 00:12

原文:Quick Sensor Metrics with the Textfile Collector | Robust Perception

Quick Sensor Metrics with the Textfile Collector
使用文本收集器生成快速感应指标(Quick Sensor Metrics)
Brian Brazil August 8, 2015

Sometimes you need a machine metric that’s not exported yet by the node exporter. The textfile collector can be used to quickly get such metrics graphed in Prometheus.
有时你需要收集机器上没有被node exporter收集的指标(metric),那么可以使用文本收集器快速收集这类信息。 

One of my computers was randomly getting turned off. Looking through the logs wasn’t fruitful, and as it has always run a bit hot I suspected thermal issues. The node exporter doesn’t yet export metrics related to temperature, fans and voltage so that’s not something Prometheus can provide out of the box. In addition every motherboard tends to have a different layout, but in this case I only care about one machine so I can do a hack for just this one machine. Using the sensors command I can get:

我的一台电脑总是时不时的关机,而日志中并没有提供详细的信息,我就怀疑是不是电脑发热导致的。Node exporter并没有提供与温度、风扇和电压相关的标量(metrics),同样的普罗米修斯没有提供立即可用的标量(metrics)。此外,每个主板都有不同的布局,但我只关心那台出问题的机器,所以我可以为这台机器收集额外的信息。使用sensors命令可以获得额外的信息

注:sensors的介绍,lm-sensors与样例的结果不一样。借鉴下Textfile Collector的做法即可。

Linux Read CPU Temperature Sensor Chip Data Including Voltage and Fan Speed With lm-sensors – nixCraft

yum install -y lm_sensors
atk0110-acpi-0Adapter: ACPI interfaceVcore Voltage: +1.12 V (min = +0.85 V, max = +1.60 V) +3.3 Voltage: +3.29 V (min = +2.97 V, max = +3.63 V) +5 Voltage: +4.92 V (min = +4.50 V, max = +5.50 V) +12 Voltage: +12.05 V (min = +10.20 V, max = +13.80 V)CPU FAN Speed: 0 RPM (min = 600 RPM)CHASSIS FAN Speed: 0 RPM (min = 600 RPM)CPU Temperature: +94.0°C (high = +60.0°C, crit = +95.0°C)GPU Temperature: +89.0°C (high = +60.0°C, crit = +95.0°C)


A little bit of sed produces output that’s compatible with the Prometheus text output format:

使用sed输出与普罗米修斯兼容的文本

$ sensors | sed -ne 's/\..*//; s/ /_/; s/: *+/ /; /Temp/p'


CPU_Temperature 94
GPU_Temperature 89
Finally this can be put in a crontab to run every minute, with a little code to ensure atomicity:

最后,在crontab中运行每分钟运行这段小代码以确保原子性

* * * * * sensors | sed -ne 's/\..*//; s/ /_/; s/: *+/ /; /Temp/p' > /var/lib/node_exporter/textfile_collector/lmsensors.prom.$$ && mv /var/lib/node_exporter/textfile_collector/lmsensors.prom.$$ /var/lib/node_exporter/textfile_collector/lmsensors.prom


/var/lib/node_exporter/textfile_collector/ is the default location for the textfile collector to look at for node exporter Debian packages from deb.robustperception.io.

/var/lib/node_exporter/textfile_collector/是文本收集器的默认位置。访问deb.robustperception.io可以获取node exporter的Debian发行包。

原创粉丝点击