Author |
Message |
graysky
|
Posted: Sat Aug 23, 2008 10:25 am |
|
Joined: Wed Dec 10, 2003 8:31 pm
Posts: 1996
Location:
/dev/null
|
Can someone help me create an rrd monitor for my GPU temp? The key data gathering script is simply:
Code: /usr/bin/nvclock -T | grep GPU | cut -c 21-22
Which on my machine will return the GPU temp as a two digit number.
I can't for the life of me adapt one of my rrd_x.pl scripts to work with this. I tried using my rrd_HDDTemp.pl and making what I thought were the correct changes. Anyway, I don't know perl
Can anyone with some perl skills have a crack at it for me?
_________________ Retired KM user (R4 - R6.04); friend to LH users.
Last edited by graysky on Sun Aug 24, 2008 11:59 pm, edited 2 times in total.
|
|
Top |
|
 |
graysky
|
Posted: Sun Aug 24, 2008 2:33 pm |
|
Joined: Wed Dec 10, 2003 8:31 pm
Posts: 1996
Location:
/dev/null
|
I think I got it!
I adapted the rrd_MBtemp.pl to work for GPU core temp. My only problem with it now is that I can't remove the green CPU Temp portion from the graph without causing errors when the script runs.
If I comment out any of the mbt2 lines, I get errors. Here is the modified script: Code: #!/usr/bin/perl # # rrd_GPUtemp.pl # GPU Core temp for KnoppMyth # ######################################################################## # Configuration: my $dbf = 'GPUtemp'; my $configfile = '/etc/rrd.config'; ######################################################################## use RRDs;
if (! -d "/myth") { $configfile = "./D_rrd.config"; } # DEBUG do $configfile;
sub create { # $_[0] = filename if (! -e "$log/$_[0].rrd") { print "Create db for $_[0] => $log/$_[0].rrd\n"; RRDs::create( "$log/$_[0].rrd", "-s 300", "DS:mbt1:GAUGE:600:0:U", "DS:mbt2:GAUGE:600:0:U", "DS:mbt3:GAUGE:600:0:U", "RRA:AVERAGE:0.5:1:576", "RRA:AVERAGE:0.5:6:672", "RRA:AVERAGE:0.5:24:732", "RRA:AVERAGE:0.5:144:1460"); $ERROR = RRDs::error; print "Error: RRDs::create failed for '$_[0]' : $ERROR\n" if $ERROR; } }
#my ($mbt1, $mbt2); my $mbt1;
sub gather { $mbt1 = `/usr/bin/nvclock -T | grep GPU | cut -c 21-22`; # $mbt2 = `$MBT_prog 2`; # $mbt3 = `$MBT_prog 3`; $mbt1 =~ s/[\n ]//g; # $mbt2 =~ s/[\n ]//g; # $mbt3 =~ s/[\n ]//g; print "$dbf: gpu $mbt1, °C\n"; # The motherboard sensor occasionally returns nonsense values. # This should keep the spurious peaks from roaching the graph... # if ($mbt1 > 100.0) { $mbt1 = $mbt2 } # print "$dbf: motherboard $mbt1, CPU $mbt2, case $mbt3, °C\n"; }
sub update { # $_[0] = filename RRDs::update( "$log/$_[0].rrd", "-t", "mbt1", "N:$mbt1"); $ERROR = RRDs::error; print "Error: RRDs::update for '$_[0]' : $ERROR\n" if $ERROR; }
sub graph { # $_[0] = time interval (ie: day...) # $_[1] = filename suffix. RRDs::graph( "$png/$dbf-$_[1].png", "-s -1$_[0]", "-aPNG", "-w $Gwd", "-h $Ght", "-E", "-l 20", "-M", "--color", "SHADEB$color", "--color", "SHADEA$color", "--color", "BACK$color", "-t nVidia GeForce 6200 Core temperature degrees C :: $_[0]", "DEF:mbt1=$log/$dbf.rrd:mbt1:AVERAGE", "DEF:mbt2=$log/$dbf.rrd:mbt2:AVERAGE", "LINE1:mbt1$color_mbt1:GPU Core temp\\:", "GPRINT:mbt1:MIN:Minimum\\: % 5.1lf", "GPRINT:mbt1:MAX:Maximum\\: % 5.1lf", "GPRINT:mbt1:AVERAGE:Average\\: % 5.1lf", "GPRINT:mbt1:LAST:Current\\: % 5.1lf °C\\j", "LINE1:mbt2$color_mbt2:CPU temp\\:", "GPRINT:mbt2:MIN:Minimum\\: % 5.1lf", "GPRINT:mbt2:MAX:Maximum\\: % 5.1lf", "GPRINT:mbt2:AVERAGE:Average\\: % 5.1lf", "GPRINT:mbt2:LAST:Current\\: % 5.1lf °C\\j"); $ERROR = RRDs::error; print "Error: RRDs::graph failed for '$_[0]' : $ERROR\n" if $ERROR; } ######################################################################## create "$dbf"; gather; update "$dbf"; graph '2hour', '12hourly'; graph 'day', 'Daily'; graph 'week', 'Weekly'; graph 'month', 'Monthly'; graph 'year', 'Yearly'; ######################################################################## # vim: sw=4 ts=8 # End
If anyone can tell me what I need to do to it to remove the green CPU Temp, I'd really appreciate it 
_________________ Retired KM user (R4 - R6.04); friend to LH users.
Last edited by graysky on Sun Aug 24, 2008 4:22 pm, edited 1 time in total.
|
|
Top |
|
 |
md10md
|
Posted: Sun Aug 24, 2008 3:16 pm |
|
Joined: Sat Jun 25, 2005 7:39 pm
Posts: 162
|
Great work! I've added it to my config. Thanks again.
|
|
Top |
|
 |
graysky
|
Posted: Sun Aug 24, 2008 4:23 pm |
|
Joined: Wed Dec 10, 2003 8:31 pm
Posts: 1996
Location:
/dev/null
|
Hehe, is it working? You might have rm -rf .nvclock and then touch .nvclock in your /home/mythtv for it to work. It worked out-of-the-box on one machine, but I had to do as I described above on two other machines.
It's also pretty crude and not very elegant at the moment... I'm still hoping someone out there will help out by cleaning it up 
_________________ Retired KM user (R4 - R6.04); friend to LH users.
Last edited by graysky on Sun Aug 24, 2008 4:27 pm, edited 3 times in total.
|
|
Top |
|
 |
md10md
|
Posted: Sun Aug 24, 2008 4:25 pm |
|
Joined: Sat Jun 25, 2005 7:39 pm
Posts: 162
|
Yeah, worked OOTB for me. I've used nvclock in the past though and I think I remember having to mess around with that file. When (If) I get around to it I'll try changing the file to see if I can get that defunct CPU temp out of their.
|
|
Top |
|
 |
graysky
|
Posted: Sun Aug 24, 2008 4:28 pm |
|
Joined: Wed Dec 10, 2003 8:31 pm
Posts: 1996
Location:
/dev/null
|
Cool man, I'm always glad to share with the community.
You do know to edit your /usr/local/bin/rrd_Config.sh and add a line for the GPUTemp right? That way, the cgi script will make your GPUTemp.html automatically.
Here is the relevant section of mine for your reference:
Code: # Establish the checklist: TYPARY=( \ Net "Network In/Out Traffic" on \ Disk "Disk reads/writes" on \ Count "Count of files in /myth/tv" on \ MythFS "/myth Space & Inode usage" on \ HDtemp "Disk temperature" on \ GPUtemp "GPU temperature" off \ MBtemp "MB and CPU temperature" off \ MBfan "MB fan speeds" off \ UPS "UPS information" off \
_________________ Retired KM user (R4 - R6.04); friend to LH users.
|
|
Top |
|
 |
graysky
|
Posted: Sun Aug 24, 2008 11:05 pm |
|
Joined: Wed Dec 10, 2003 8:31 pm
Posts: 1996
Location:
/dev/null
|
Figured it out! It's all about the grammar of the perl script.
Original code (relevant section): Code: sub graph { # $_[0] = time interval (ie: day...) # $_[1] = filename suffix. RRDs::graph( "$png/$dbf-$_[1].png", "-s -1$_[0]", "-aPNG", "-w $Gwd", "-h $Ght", "-E", "-l 20", "-M", "--color", "SHADEB$color", "--color", "SHADEA$color", "--color", "BACK$color", "-t nVidia GeForce 6200 Core temperature degrees C :: $_[0]", "DEF:mbt1=$log/$dbf.rrd:mbt1:AVERAGE", "DEF:mbt2=$log/$dbf.rrd:mbt2:AVERAGE", "LINE1:mbt1$color_mbt1:GPU Core temp\\:", "GPRINT:mbt1:MIN:Minimum\\: % 5.1lf", "GPRINT:mbt1:MAX:Maximum\\: % 5.1lf", "GPRINT:mbt1:AVERAGE:Average\\: % 5.1lf", "GPRINT:mbt1:LAST:Current\\: % 5.1lf °C\\j", "LINE1:mbt2$color_mbt2:CPU temp\\:", "GPRINT:mbt2:MIN:Minimum\\: % 5.1lf", "GPRINT:mbt2:MAX:Maximum\\: % 5.1lf", "GPRINT:mbt2:AVERAGE:Average\\: % 5.1lf", "GPRINT:mbt2:LAST:Current\\: % 5.1lf °C\\j"); Functional code (relevant section): Code: sub graph { # $_[0] = time interval (ie: day...) # $_[1] = filename suffix. RRDs::graph( "$png/$dbf-$_[1].png", "-s -1$_[0]", "-aPNG", "-w $Gwd", "-h $Ght", "-E", "-l 40", "-r", "-v temp. (°C)", "-M", "--color", "SHADEB$color", "--color", "SHADEA$color", "--color", "BACK$color", "-t nVidia GeForce 6200 Core temperature :: $_[0]", "DEF:mbt1=$log/$dbf.rrd:mbt1:AVERAGE", # "DEF:mbt2=$log/$dbf.rrd:mbt2:AVERAGE", "LINE1:mbt1$color_mbt1:GPU Core temp\\:", "GPRINT:mbt1:MIN:Minimum\\: % 5.1lf", "GPRINT:mbt1:MAX:Maximum\\: % 5.1lf", "GPRINT:mbt1:AVERAGE:Average\\: % 5.1lf", "GPRINT:mbt1:LAST:Current\\: % 5.1lf °C\\j"); # "LINE1:mbt2$color_mbt2:CPU temp\\:", # "GPRINT:mbt2:MIN:Minimum\\: % 5.1lf", # "GPRINT:mbt2:MAX:Maximum\\: % 5.1lf", # "GPRINT:mbt2:AVERAGE:Average\\: % 5.1lf", # "GPRINT:mbt2:LAST:Current\\: % 5.1lf °C\\j");
See the difference? No? It was all about the position of the ending ) mark. You have to move it up to the the end of the mbt1 lines and end with a ; (see the "GPRINT:mbt1:LAST:Current\\: % 5.1lf °C\\j"); line).
Anyway, now it works just fine:
Before
After
Oh, the other thing I did was to add the following to the line that defines the graph:
"-l 40",
"-r",
"-v temp. (°C)",
The "-l 40" limits to lower axis to 40 when you invoke the "-r" switch that rigidly enforces the limit. The "-v temp. (°C)" switch adds the text to the vertical axis. BTW, you get the ° sign by typing alt+0176. For more, see the rrdgraph docs.
_________________ Retired KM user (R4 - R6.04); friend to LH users.
|
|
Top |
|
 |
graysky
|
Posted: Sun Aug 24, 2008 11:58 pm |
|
Joined: Wed Dec 10, 2003 8:31 pm
Posts: 1996
Location:
/dev/null
|
I also combined the video card and hdd temps into one graph. Why not add the mb and cpu temp? I wrote this for a machine that's from 1997 and doesn't have mb and cpu logging!
If you're interested, here is the modified /usr/local/bin/rrd_GPUtemp.pl:
Code: #!/usr/bin/perl # # rrd_MBtemp.pl # Motherboard Temperature data collection routine for KnoppMyth # ######################################################################## # Configuration: my $dbf = 'GPUtemp'; my $configfile = '/etc/rrd.config'; ######################################################################## use RRDs;
if (! -d "/myth") { $configfile = "./D_rrd.config"; } # DEBUG do $configfile;
sub create { # $_[0] = filename if (! -e "$log/$_[0].rrd") { print "Create db for $_[0] => $log/$_[0].rrd\n"; RRDs::create( "$log/$_[0].rrd", "-s 300", "DS:mbt1:GAUGE:600:0:U", "DS:mbt2:GAUGE:600:0:U", "DS:mbt3:GAUGE:600:0:U", "RRA:AVERAGE:0.5:1:576", "RRA:AVERAGE:0.5:6:672", "RRA:AVERAGE:0.5:24:732", "RRA:AVERAGE:0.5:144:1460"); $ERROR = RRDs::error; print "Error: RRDs::create failed for '$_[0]' : $ERROR\n" if $ERROR; } }
my ($mbt1, $mbt2);
sub gather { $mbt1 = `/usr/bin/nvclock -T | grep GPU | cut -c 21-22`; $mbt2 = `/usr/sbin/hddtemp -n /dev/hda`; # $mbt3 = `$MBT_prog 3`; $mbt1 =~ s/[\n ]//g; $mbt2 =~ s/[\n ]//g; # $mbt3 =~ s/[\n ]//g;
print "$dbf: gpu temp $mbt1, hdd temp $mbt2, °C\n";
# The motherboard sensor occasionally returns nonsense values. # This should keep the spurious peaks from roaching the graph... if ($mbt1 > 100.0) { $mbt1 = $mbt2 } # print "$dbf: GPU Core temp $mbt1, $mbt2, HDD temp $mbt3, °C\n"; print "$dbf: gpu temp $mbt1, hdd temp $mbt2, °C\n"; }
sub update { # $_[0] = filename RRDs::update( "$log/$_[0].rrd", "-t", "mbt1:mbt2", "N:$mbt1:$mbt2"); $ERROR = RRDs::error; print "Error: RRDs::update for '$_[0]' : $ERROR\n" if $ERROR; }
sub graph { # $_[0] = time interval (ie: day...) # $_[1] = filename suffix. RRDs::graph( "$png/$dbf-$_[1].png", "-s -1$_[0]", "-aPNG", "-w $Gwd", "-h $Ght", "-E", "-A", "--color", "SHADEB$color", "--color", "SHADEA$color", "--color", "BACK$color", "-t Video Card and HDD Core Temperature (° C) :: $_[0]", "DEF:mbt1=$log/$dbf.rrd:mbt1:AVERAGE", "DEF:mbt2=$log/$dbf.rrd:mbt2:AVERAGE", "LINE1:mbt1$color_mbt1:GPU\\:", "GPRINT:mbt1:MIN:Minimum\\: % 5.1lf", "GPRINT:mbt1:MAX:Maximum\\: % 5.1lf", "GPRINT:mbt1:AVERAGE:Average\\: % 5.1lf", "GPRINT:mbt1:LAST:Current\\: % 5.1lf °C\\j", "LINE1:mbt2$color_mbt3:HDD\\:", "GPRINT:mbt2:MIN:Minimum\\: % 5.1lf", "GPRINT:mbt2:MAX:Maximum\\: % 5.1lf", "GPRINT:mbt2:AVERAGE:Average\\: % 5.1lf", "GPRINT:mbt2:LAST:Current\\: % 5.1lf °C\\j"); $ERROR = RRDs::error; print "Error: RRDs::graph failed for '$_[0]' : $ERROR\n" if $ERROR; } ######################################################################## create "$dbf"; gather; update "$dbf"; graph '2hour', '12hourly'; graph 'day', 'Daily'; graph 'week', 'Weekly'; graph 'month', 'Monthly'; graph 'year', 'Yearly'; ######################################################################## # vim: sw=4 ts=8 # End
Oh, and I removed the -v stuff from the last post because it resized the output png making it slightly larger than the others. I also took away some of the graphing options and replaced them with the -A for auto scaling.
_________________ Retired KM user (R4 - R6.04); friend to LH users.
|
|
Top |
|
 |