View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 2 posts ] 
Print view Previous topic   Next topic  
Author Message
Search for:
 Post subject: rrd customizations?
PostPosted: Tue Dec 18, 2007 11:22 am 
Offline
Joined: Mon Jun 27, 2005 7:25 pm
Posts: 20
i've done some searching and can't seem to find anything (current) that applies to this, so i'm posting here, hoping that someone with better php/perl can help me figure this thing out...

SITUATION: i've got three HDs in my mythbox, one for the myth install (to include /myth (hda), another for /myth/tv (hdb), and yet another for /myth/video (hdc)...

MISSION: i'd like to see temperature (/usr/local/bin/rrd_HDtemp.pl) and usage (/usr/local/bin/rrd_MythFS.pl) information for these other hard drives and i'd like to do it without adding four more graphs (a new graph for each additional drives temp and usage patterns). i've tried adding new devices and colors, etc, but haven't been able to figure out why it's not doing anything more...

EXECUTION: point me in the right direction and give me the right kind of clues a knucklehead like me needs to figure this thing out, or if you're ambitious enough, you could even post edited .pl and /etc/rrd.config files...

i've tried searching, but apparently there were some significant changes to the rrd pl files when r5f* came out, and all the information that i've found was for r5e50 or prior... anyone?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 18, 2007 7:26 pm 
Offline
Joined: Wed Jan 07, 2004 12:14 pm
Posts: 434
Location: Charlotte, NC
If you google 'rrd mythtv' you will get several hits that will give you examples of changes to display multiple hd temps and usage among others (also see http://www.knoppmyth.net/phpBB2/viewtopic.php?t=15957). I have included some of my changes as examples. Below is my /usr/local/bin/rrd_HDtemp.pl changes to display a total of 4 hd temps. The pertinent section of rrd.config follows. Oh, make sure you reset the logs of whatever device you change (in this example rename /myth/rrd/log/HDtemp.rrd).

Code:
#!/usr/bin/perl
#
#  rrd_HDtemp.pl
#       Disk temperature data collection routine for KnoppMyth
#
# Edited to add second hard drive monitor
# Mike Hanson 05/25/2007
#
# Edited to modify Mike's code to include additional drives, change
# colors and location of graphs - J Ravenel 10/02/07
########################################################################
# Configuration:
my $dbf = 'HDtemp';
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:hdt1:GAUGE:600:0:U",
####################################
#### Added the second DS below #####
####################################
            "DS:hdt2:GAUGE:600:0:U",
            "DS:hdt3:GAUGE:600:0:U",
            "DS:hdt4: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;
    }
}
##########################################
#### Added second set of $hdt?n below ####
##########################################
my ($hdt1, $hdt2, $hdt3, $hdt4, $hdtT1, $hdtT2, $hdtT3, $hdtT4, $hdtD1, $hdtD2, $hdtD3, $hdtD4);

###################################################################
#### I run the script in sub gather below one time per device. ####
#### There may be a more elegant way to do this, but it works. ####
###################################################################
sub gather {
  { #   $_[0] device name
    my $line1 = `/usr/sbin/hddtemp -q /dev/$_[0]`;
    chomp( $line1 );
    my ( $devN1, $devD1, $devT1 ) = split( /\:\s+/, $line1 );
    #print "HDtemp $_[0]: '$devN1' '$devD1' '$devT1'\n";
    my ( $dev11, $dev21 ) = split( /\s+or\s+/, $devT1 );
    #print "HDtemp $_[0]: '$dev11' '$dev21'\n";
    ( $hdt1, $hdtT1 ) = split( /\s+/, $dev11 );
    #print "HDtemp $_[0]: '$hdt1' '$hdtT1'\n";
    if ($devN1 ne "/dev/$_[0]") {
        $hdt1 = 0; $hdtT1 = '?'; $hdtD1 = '';
    } else {
        $hdtD1 = $devD1;
    }
    if ("$hdtT1" eq "") {$hdt1 = "C"; }
    print "HDtemp $_[0]: '$hdtD1' '$hdt1 $hdtT1'\n";
 }
 { #  $_[1] device name
    my $line2 = `/usr/sbin/hddtemp -q /dev/$_[1]`;
    chomp( $line2 );
    my ( $devN2, $devD2, $devT2 ) = split( /\:\s+/, $line2 );
    #print "HDtemp $_[1]: '$devN2' '$devD2' '$devT2'\n";
    my ( $dev12, $dev22 ) = split( /\s+or\s+/, $devT2 );
    #print "HDtemp $_[1]: '$dev12' '$dev22'\n";
    ( $hdt2, $hdtT2 ) = split( /\s+/, $dev12 );
    #print "HDtemp $_[1]: '$hdt2' '$hdtT2'\n";
    if ($devN2 ne "/dev/$_[1]") {
        $hdt2 = 0; $hdtT2 = '?'; $hdtD2 = '';
    } else {
        $hdtD2 = $devD2;
    }
    if ("$hdtT2" eq "") {$hdt2 = "C"; }
    print "HDtemp $_[1]: '$hdtD2' '$hdt2 $hdtT2'\n";
  }
  { #   $_[2] device name
    my $line3 = `/usr/sbin/hddtemp -q /dev/$_[2]`;
    chomp( $line3 );
    my ( $devN3, $devD3, $devT3 ) = split( /\:\s+/, $line3 );
    #print "HDtemp $_[2]: '$devN3' '$devD3' '$devT3'\n";
    my ( $dev13, $dev23 ) = split( /\s+or\s+/, $devT3 );
    #print "HDtemp $_[2]: '$dev13' '$dev23'\n";
    ( $hdt3, $hdtT3 ) = split( /\s+/, $dev13 );
    #print "HDtemp $_[2]: '$hdt3' '$hdtT3'\n";
    if ($devN3 ne "/dev/$_[2]") {
        $hdt3 = 0; $hdtT3 = '?'; $hdtD3 = '';
    } else {
        $hdtD3 = $devD3;
    }
    if ("$hdtT3" eq "") {$hdt3 = "C"; }
    print "HDtemp $_[2]: '$hdtD3' '$hdt3 $hdtT3'\n";
 }
 { #  $_[3] device name
    my $line4 = `/usr/sbin/hddtemp -q /dev/$_[3]`;
    chomp( $line4 );
    my ( $devN4, $devD4, $devT4 ) = split( /\:\s+/, $line4 );
    #print "HDtemp $_[3]: '$devN4' '$devD4' '$devT4'\n";
    my ( $dev14, $dev24 ) = split( /\s+or\s+/, $devT4 );
    #print "HDtemp $_[3]: '$dev14' '$dev24'\n";
    ( $hdt4, $hdtT4 ) = split( /\s+/, $dev14 );
    #print "HDtemp $_[3]: '$hdt4' '$hdtT4'\n";
    if ($devN4 ne "/dev/$_[3]") {
        $hdt4 = 0; $hdtT4 = '?'; $hdtD4 = '';
    } else {
        $hdtD4 = $devD4;
    }
    if ("$hdtT4" eq "") {$hdt4 = "C"; }
    print "HDtemp $_[3]: '$hdtD4' '$hdt4 $hdtT4'\n";
  }
}

################################################
#### Added hdt2 to the update routine below ####
################################################
sub update {
    #   $_[0] = filename
    RRDs::update( "$log/$_[0].rrd", "-t",
        "hdt1:hdt2:hdt3:hdt4",
        "N:$hdt1:$hdt2:$hdt3:$hdt4");
    $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", "SHADEA$color",
        "--color", "SHADEB$color",
        "--color", "BACK$color",
#        "-t Disk $dev1/$dev2/$dev3/$dev4 ($hdtD1/$hdtD2/$hdtD3/$hdtD4) temp :: $_[0]",
        "-t Disk $dev1/$dev2/$dev3/$dev4 temp :: $_[0]",
        "DEF:hdt1=$log/$dbf.rrd:hdt1:AVERAGE",
############################################
#### Added second DEF for hdt2 below.   ####
#### Added second $color_hdt variable. ####
#### Changed LINE1 to LINE2 for thicker ####
#### lines on the graphs.               ####
############################################
        "DEF:hdt2=$log/$dbf.rrd:hdt2:AVERAGE",
        "DEF:hdt3=$log/$dbf.rrd:hdt3:AVERAGE",
        "DEF:hdt4=$log/$dbf.rrd:hdt4:AVERAGE",
        "LINE1:hdt1$color_hdt1: $dev1 degrees $hdtT1\\:",
        "GPRINT:hdt1:MIN:Minimum\\: %.0lf",
        "GPRINT:hdt1:MAX:Maximum\\: %.0lf",
        "GPRINT:hdt1:AVERAGE:Average\\: %.2lf",
        "GPRINT:hdt1:LAST:Current\\: %.1lf\\j",
        "LINE1:hdt2$color_hdt2: $dev2 degrees $hdtT2\\:",
        "GPRINT:hdt2:MIN:Minimum\\: %.0lf",
        "GPRINT:hdt2:MAX:Maximum\\: %.0lf",
        "GPRINT:hdt2:AVERAGE:Average\\: %.2lf",
        "GPRINT:hdt2:LAST:Current\\: %.1lf\\j",
        "LINE1:hdt3$color_hdt3: $dev3 degrees $hdtT3\\:",
        "GPRINT:hdt3:MIN:Minimum\\: %.0lf",
        "GPRINT:hdt3:MAX:Maximum\\: %.0lf",
        "GPRINT:hdt3:AVERAGE:Average\\: %.2lf",
        "GPRINT:hdt3:LAST:Current\\: %.1lf\\j",
        "LINE1:hdt4$color_hdt4: $dev4 degrees $hdtT4\\:",
        "GPRINT:hdt4:MIN:Minimum\\: %.0lf",
        "GPRINT:hdt4:MAX:Maximum\\: %.0lf",
        "GPRINT:hdt4:AVERAGE:Average\\: %.2lf",
        "GPRINT:hdt4:LAST:Current\\: %.1lf\\j");
    $ERROR = RRDs::error;
    print "Error: RRDs::graph failed for '$_[0]' : $ERROR\n" if $ERROR;
}
########################################################################
create "$dbf";
#####################################################
#### Changed '$dev' to '$dev1' and added '$dev2' ####
#### '$dev3' ,etc... to gather below.                      ####
#####################################################
gather "$dev1", "$dev2", "$dev3", "$dev4";
update "$dbf";
graph 'day',   'Daily';
graph 'week',  'Weekly';
graph 'month', 'Monthly';
graph 'year',  'Yearly';
########################################################################
# vim: sw=4 ts=8
# End


Code:
#=======================================================================
#  rrd_HDtemp.pl config:   # hard disk temperature
#-----------------------------------------------------------------------
$dev1 = 'hda';                  # Disk being measured
$dev2 = 'hdb';                  # Disk being measured
$dev3 = 'sda';                  # Disk being measured
$dev4 = 'sdb';                  # Disk being measured
$color_hdt1 = '#0000FF';        # color of temperature graph line
$color_hdt2 = '#00FF00';        # color of temperature graph line
$color_hdt3 = '#FF0000';        # color of temperature graph line
$color_hdt4 = '#FFFF00';        # color of temperature graph line


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 


All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 31 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu