Files
bin/node-collector-hddtemp

24 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
# THIS IS LAME, disks moved around with /backup included, so note sde_temp is
# with /dev/sdc for now
sdd_temp=`sudo hddtemp /dev/sdd | awk '{printf "%d\n", $4 }'`
sde_temp=`sudo hddtemp /dev/sdc | awk '{printf "%d\n", $4 }'`
cpu_temp=`sensors | grep Tctl | awk '{printf("%.1f\n", $2)}'`
n_temp=`sudo nvme smart-log /dev/nvme0n1 | grep '^temperature' | awk '{printf("%.1f", $3)}'`
tmp_file=/tmp/hddtemps.prom.$$
real_file=/srv/docker/container/node-exporter/textfile_collector/hddtemps.prom
echo "# HELP node_hwmon_temp_celsius Hardware monitor for temperature (input)" > $tmp_file
echo "# TYPE node_hwmon_temp_celsius gauge" >> $tmp_file
echo "node_hwmon_temp_celsius{chip=\"cpu\",sensor=\"Tctl\"} $cpu_temp" >> $tmp_file
echo "node_hwmon_temp_celsius{chip=\"hddtemp\",sensor=\"sdd\"} $sdd_temp" >> $tmp_file
echo "node_hwmon_temp_celsius{chip=\"hddtemp\",sensor=\"sde\"} $sde_temp" >> $tmp_file
echo "node_hwmon_temp_celsius{chip=\"hddtemp\",sensor=\"nvme0n1\"} $n_temp" >> $tmp_file
mv $tmp_file $real_file