sudo apt install nvme-cli
Use an editor to create a file named nvme_metrics.sh
in your home directory, containing
#!/bin/sh
TEMP=$(/usr/sbin/nvme smart-log /dev/nvme0 | /usr/bin/grep temperature | /usr/bin/head -1 | /usr/bin/awk '{print $3}')
echo "# HELP nvme_temperature Temperature of the first nvme reported by nvme-cli"
echo "# TYPE nvme_temperature gauge"
echo "nvme_temperature $TEMP"
chmod u+x nvme_metrics.sh
Run sudo crontab -e
to edit your cron tab.
Select an editor, if requested to.
Add a line to the bottom:
* * * * * /home/[your username]/nvme_metrics.sh > /var/lib/node_exporter/textfile_collector/nvme.prom
Be sure to replace [your username]
.
After a few minutes, you should be able to query the new metric in grafana