Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jshufro

jshufro/howto.md Secret

Last active January 29, 2023 18:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jshufro/65160a680076224d0294d1d6f1a0fa97 to your computer and use it in GitHub Desktop.
Save jshufro/65160a680076224d0294d1d6f1a0fa97 to your computer and use it in GitHub Desktop.
nvme-cli temp in grafana

Install dependencies:

sudo apt install nvme-cli

Create script

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"

Make the script executable

chmod u+x nvme_metrics.sh

Add the script to your cron tab

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].

Add metrics to grafana

After a few minutes, you should be able to query the new metric in grafana

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment