mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
- have some dirs
This commit is contained in:
parent
0b089ea777
commit
08346aac58
687 changed files with 0 additions and 0 deletions
122
plugins/gpu/nvidia_smi_
Executable file
122
plugins/gpu/nvidia_smi_
Executable file
|
@ -0,0 +1,122 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
#
|
||||
# Copyright and BSD license
|
||||
#
|
||||
# Copyright (c) 2011 NVIDIA Corporation
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms are permitted
|
||||
# provided that the above copyright notice and this paragraph are
|
||||
# duplicated in all such forms and that any documentation,
|
||||
# advertising materials, and other materials related to such
|
||||
# distribution and use acknowledge that the software was developed
|
||||
# by NVIDIA Corporation. The name of the NVIDIA Corporation may not be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
|
||||
#
|
||||
# This script collects GPU information for use as a munin plugin
|
||||
# Inspired by Matthew Ritchie and Vadim Bulakh's nvidia_smi_ plugin
|
||||
#
|
||||
|
||||
#
|
||||
# This requires the NVML bindings and NVIDIA driver >= R270
|
||||
# $ sudo cpan install nvidia::ml
|
||||
# http://search.cpan.org/~nvbinding/nvidia-ml-pl/lib/nvidia/ml.pm
|
||||
#
|
||||
|
||||
use strict;
|
||||
use nvidia::ml qw(:all);
|
||||
|
||||
my $runType = "normal";
|
||||
my @runTypes = qw( normal config autoconf );
|
||||
if ($#ARGV + 1 == 1)
|
||||
{
|
||||
if (grep $_ eq $ARGV[0], @runTypes)
|
||||
{
|
||||
$runType = $ARGV[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Invalid arguement: $ARGV[0].\n";
|
||||
print "Valid arguements: @runTypes.\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
my $ret = nvmlInit();
|
||||
exit(1) unless $ret == $NVML_SUCCESS;
|
||||
|
||||
($ret, my $gpuCount) = nvmlDeviceGetCount();
|
||||
exit(1) unless $ret == $NVML_SUCCESS;
|
||||
|
||||
($ret, my $driverVersion) = nvmlSystemGetDriverVersion();
|
||||
$driverVersion = "Unknown" if $ret != $NVML_SUCCESS;
|
||||
|
||||
for (my $i = 0; $i < $gpuCount; $i++)
|
||||
{
|
||||
($ret, my $handle) = nvmlDeviceGetHandleByIndex($i);
|
||||
next if $ret != $NVML_SUCCESS;
|
||||
|
||||
($ret, my $pciInfo) = nvmlDeviceGetPciInfo($handle);
|
||||
my $gpuName = $pciInfo->{'busId'} if $ret == $NVML_SUCCESS;
|
||||
|
||||
if ($runType eq "config")
|
||||
{
|
||||
# only print the graph information once
|
||||
if ($i == 0)
|
||||
{
|
||||
print "graph_title GPU\n";
|
||||
print "graph_args --upper-limit 120 -l 0\n";
|
||||
print "graph_vlabel Percent or Degrees C\n";
|
||||
print "graph_category GPU Metrics\n";
|
||||
print "graph_info Information for NVIDIA GPUs using driver version $driverVersion\n";
|
||||
}
|
||||
|
||||
# metrics are collected for all the GPUs to a single graph
|
||||
print "GPU_UTIL_$i.label GPU$i - $gpuName : GPU utilization\n";
|
||||
print "GPU_FANSPEED_$i.label GPU$i - $gpuName : fan speed\n";
|
||||
print "GPU_MEM_UTIL_$i.label GPU$i - $gpuName : GPU memory utilization\n";
|
||||
print "GPU_TEMP_$i.label GPU$i - $gpuName : GPU temperature\n";
|
||||
}
|
||||
elsif ($runType eq "autoconf")
|
||||
{
|
||||
print "yes\n";
|
||||
exit(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
($ret, my $gpuTemp) = nvmlDeviceGetTemperature($handle,
|
||||
$NVML_TEMPERATURE_GPU);
|
||||
$gpuTemp = "N/A" if $ret != $NVML_SUCCESS;
|
||||
|
||||
($ret, my $gpuFanSpeed) = nvmlDeviceGetFanSpeed($handle);
|
||||
$gpuFanSpeed = "N/A" if $ret != $NVML_SUCCESS;
|
||||
|
||||
($ret, my $utilRates) = nvmlDeviceGetUtilizationRates($handle);
|
||||
my $gpuUtil;
|
||||
my $memUtil;
|
||||
if ($ret == $NVML_SUCCESS)
|
||||
{
|
||||
$gpuUtil = $utilRates->{'gpu'};
|
||||
$memUtil = $utilRates->{'memory'};
|
||||
}
|
||||
else
|
||||
{
|
||||
$gpuUtil = "N/A";
|
||||
$memUtil = "N/A";
|
||||
}
|
||||
|
||||
print "GPU_TEMP_$i.value $gpuTemp\n";
|
||||
print "GPU_FANSPEED_$i.value $gpuFanSpeed\n";
|
||||
print "GPU_UTIL_$i.value $gpuUtil\n";
|
||||
print "GPU_MEM_UTIL_$i.value $memUtil\n";
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue