Created
June 11, 2011 15:40
-
-
Save Jessidhia/1020686 to your computer and use it in GitHub Desktop.
NVidia temperature sensor for munin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env perl | |
use v5.10; | |
use strict; | |
use warnings; | |
use feature ':5.10'; | |
use Munin::Plugin; | |
use XML::Fast; | |
use Encode; | |
#%# family=auto | |
#%# capabilities=autoconf | |
my $smi = xml2hash `nvidia-smi -q -g 0 -x`; | |
my $gpu = $$smi{nvidia_smi_log}{gpu}; | |
sub no_suffix($) { | |
$_ = shift; | |
/(.*?) /; | |
defined $1 and $1 or $_ | |
} | |
my %info = ( | |
model => $$gpu{product_name}, | |
gpu => no_suffix $$gpu{utilization}{gpu_util}, | |
fan => no_suffix $$gpu{fan_speed}, | |
mem => int(no_suffix $$gpu{memory_usage}{used}) * 100 / int(no_suffix $$gpu{memory_usage}{total}), | |
temp => no_suffix $$gpu{temperature}{gpu_temp}, | |
driver => $$smi{nvidia_smi_log}{driver_version} | |
); | |
given ($ARGV[0]) { | |
when ("autoconf") { | |
if ($info{temp}) { | |
print "yes\n"; | |
exit 0; | |
} else { | |
print "no\n"; | |
exit 1; | |
} | |
} | |
when ("config") { | |
print <<"EOF"; | |
graph_title $info{model} graphics card | |
graph_args --upper-limit 120 -l 0 | |
graph_vlabel Percent or Degrees C | |
graph_category sensors | |
graph_info This graph shows information about your $info{model} graphics card running driver version $info{driver} | |
NV_gpu.label NVidia GPU utilization | |
NV_gpu.type GAUGE | |
NV_gpu.graph @{[$info{gpu} ne "N/A" ? "yes" : "no"]} | |
NV_fan.label NVidia fan speed | |
NV_fan.type GAUGE | |
NV_fan.graph @{[0 && $info{fan} > 10 ? "yes" : "no"]} | |
NV_mem.label NVidia memory utilization | |
NV_mem.type GAUGE | |
NV_temp.label NVidia temperature | |
NV_temp.type GAUGE | |
NV_temp.warning :75 | |
EOF | |
exit 0; | |
} | |
default { | |
print <<"EOF"; | |
NV_gpu.value $info{gpu} | |
NV_gpu.draw LINE0 | |
NV_fan.value $info{fan} | |
NV_fan.draw LINE1 | |
NV_mem.value $info{mem} | |
NV_mem.draw LINE2 | |
NV_temp.value $info{temp} | |
NV_temp.draw LINE3 | |
EOF | |
exit 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment