Skip to content

Instantly share code, notes, and snippets.

@ayufan
Created March 27, 2017 18:54
Show Gist options
  • Save ayufan/41a05fb6f5840a1f2b4335f01498ff1a to your computer and use it in GitHub Desktop.
Save ayufan/41a05fb6f5840a1f2b4335f01498ff1a to your computer and use it in GitHub Desktop.
#!/bin/bash
join_by() {
local IFS=","
echo "$*"
}
get_data() {
local QUERIES=$(join_by "$@")
while read -d "," VALUE REST; do
echo "$1,hostname=$HOSTNAME value=$VALUE"
shift
done < <(nvidia-smi --query-gpu="${QUERIES[@]}" --format=csv | tail -n 1)
}
DB=pc
CREDS=user:password
METRICS="power.draw power.limit temperature.gpu
clocks.current.graphics clocks.current.sm clocks.current.memory clocks.current.video
utilization.gpu utilization.memory memory.used memory.total fan.speed"
curl -v -u "$CREDS" -X POST "https://influxdb.ayufan.eu/write?db=$DB" --data-binary "$(get_data $METRICS)"
@Dirt-Nasty
Copy link

how exactly does this work? Im trying to run it on my debian box and I am failing to get any data into influx

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