LinHES Forums
http://forum.linhes.org/

rrd and lm-sensors
http://forum.linhes.org/viewtopic.php?f=6&t=16608
Page 1 of 1

Author:  graysky [ Tue Sep 18, 2007 6:25 pm ]
Post subject:  rrd and lm-sensors

Is anyone using lm-sensors to report their CPU/MB temps? MBMON doesn't work properly with my system (cpu temp is always 255). Lm-sensors works very well on my machine. I just have no idea if it's possible and how to go about using it for my rrd. Any help is appreciated.

Author:  marc.aronson [ Tue Sep 18, 2007 7:05 pm ]
Post subject: 

Graysky, see http://mysettopbox.tv/phpBB2/viewtopic. ... rd+sensors

Although I'm a bit confused because I believe you're already on that thread, so maybe I am mis-understanding your question.

Marc

Author:  mihanson [ Tue Sep 18, 2007 7:37 pm ]
Post subject: 

I use sensors and had to run sensors-detect once as was mentioned in the above referenced thread. I customized my RRD's to have one central MBsensors.rrd database and the create graphs for individual sensors components by pulling info from that single MBsensors.rrd DB. Here is my /etc/rrd.config with just the portions that pertain to MBsensors:

Code:
#  rrd_MBtemp.pl configuration: # Motherboard / CPU temperature
#-----------------------------------------------------------------------
$color_temp1 = '#00FF00';       # color of 'System' graph line
$color_temp3 = '#FF0000';       # color of 'CPU' graph line
#=======================================================================
#  rrd_MBfan.pl configuration:  # Motherboard fan speeds
#-----------------------------------------------------------------------
$color_fan1 = '#00FF00';        # color of 'CPU' graph line
$color_fan2 = '#FF0000';        # color of 'Intake' graph line
$color_fan3 = '#0000FF';        # color of 'Exhaust' graph line
#=======================================================================
#  rrd_MBsensors.pl configuration       # Motherboard sensors
#-----------------------------------------------------------------------
$color_vcore1 = '#FF0000';      # CPU Core 1 color
$color_vcore2 = '#FF9933';      # CPU Core 2 color
$color_p33v = '#FFCC00';        # PSU +3.3v
$color_p5v = '#FF00CC';         # PSU +5v
$color_p12v = '#003300';        # PSU +12v
$color_n12v = '#00FF00';        # PSU -12v
$color_n5v = '#CC99FF';         # PSU -5v
$color_v5sb = '#9933FF';        # V5SB
$color_vbat = '#0033FF';        # Battery Voltage
$color_vid = '#996666';         # Video voltage
########################################################################


And here is my all encompassing sensors script:
Code:
#!/usr/bin/perl
#
#  rrd_MBSensors.pl
#       Motherboard sensor data collection routine for KnoppMyth
#
########################################################################
# Configuration:
my $dbf = 'MBsensors';
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:vcore1:GAUGE:600:0:U",
            "DS:vcore2:GAUGE:600:0:U",
            "DS:p33v:GAUGE:600:0:U",
            "DS:p5v:GAUGE:600:0:U",
            "DS:p12v:GAUGE:600:0:U",
            "DS:n12v:GAUGE:600:0:U",
            "DS:n5v:GAUGE:600:0:U",
            "DS:v5sb:GAUGE:600:0:U",
            "DS:vbat:GAUGE:600:0:U",
            "DS:fan1:GAUGE:600:0:U",
            "DS:fan2:GAUGE:600:0:U",
            "DS:fan3:GAUGE:600:0:U",
            "DS:temp1:GAUGE:600:0:U",
           # "DS:temp2:GAUGE:600:0:U",
            "DS:temp3:GAUGE:600:0:U",
            "DS:vid: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 ($vcore1, $vcore2, $p33v, $p5v, $p12v, $n12v, $n5v, $v5sb, $vbat, $fan1, $fan2, $fan3, $temp1, $temp3, $vid);

sub gather {
        my @sensors = `/usr/bin/sensors`;

        # Vcore 1
        $vcore1a = $sensors[2];
        my @vcore1b = split( /\s+/, $vcore1a );
        $vcore1 = $vcore1b[2];
        #print "vcore1c = $vcore1c\n";
        #my @vcore1d = split( /\s+/, $vcore1c );
        #$vcore = $vcore1d[0];
        $vcore1 =~ s/[\n ]//g;

        # Vcore 2
        $vcore2a = $sensors[3];
        my @vcore2b = split( /\s+/, $vcore2a );
        $vcore2 = $vcore2b[2];
        #my @vcore2d = split( /V/, $vcore2c );
        #$vcore2 = $vcore2d[0];
        $vcore2 =~ s/[\n ]//g;

        # +3.3V
        $p33va = $sensors[4];
        #print "p33va = $p33va\n"; # debug
        my @p33vb = split( /\s+/, $p33va );
        $p33v = $p33vb[1];
        #print "p33vc = $p33vc\n"; # debug
        #my @p33vd = split( /\+/, $p33vc );
        #$p33v = $p33vd[1];
        $p33v =~ s/[\n ]//g;

        # +5V
        $p5va = $sensors[5];
        #print "p5va = $p5va\n"; # debug
        my @p5vb = split( /\s+/, $p5va );
        $p5v = $p5vb[1];
        #print "p5vc = $p5vc\n"; # debug
        #my @p5vd = split( /\+/, $p5vc );
        #$p5v = $p5vd[1];
        #print "p5ve = $p5ve\n"; #debug
        $p5v =~ s/[\n ]//g;

        # +12V
        $p12va = $sensors[6];
        #print "p12va = $p12va\n"; # debug
        my @p12vb = split( /\s+/, $p12va );
        $p12v = $p12vb[1];
        #print "p12vc = $p12vc\n"; # debug
        #my @p12vd = split( /\+/, $p12vc );
        #$p12v = $p12vd[1];
        #print "p12ve = $p12ve\n"; #debug
        $p12v =~ s/[\n ]//g;

        # -12V
        $n12va = $sensors[7];
        #print "n12va = $n12va\n"; # debug
        my @n12vb = split( /\s+/, $n12va );
        $n12v = $n12vb[1];
        $n12v =~ s/[\n ]//g;

        # -5V
        $n5va = $sensors[8];
        #print "n5va = $n5va\n"; # debug
        my @n5vb = split( /\s+/, $n5va );
        $n5v = $n5vb[1];
        $n5v =~ s/[\n ]//g;

        # V5SB
        $v5sba = $sensors[9];
        #print "v5sba = $v5sba\n"; # debug
        my @v5sbb = split( /\s+/, $v5sba );
        $v5sb = $v5sbb[1];
        #print "v5sbc = $v5sbc\n"; # debug
        #my @v5sbd = split( /\+/, $v5sbc );
        #$v5sb = $v5sbd[1];
        #print "v5sbe = $v5sbe\n"; #debug
        $v5sb =~ s/[\n ]//g;

        # VBat
        $vbata = $sensors[10];
        #print "vbata = $vbata\n"; # debug
        my @vbatb = split( /\s+/, $vbata );
        $vbat = $vbatb[1];
        #print "vbatc = $vbatc\n"; # debug
        #my @vbatd = split( /\+/, $vbatc );
        #$vbat = $vbatd[1];
        #print "vbate = $vbate\n"; #debug
        $vbat =~ s/[\n ]//g;

        # Fan 1
        $fan1a = $sensors[11];
        #print "fan1a = $fan1a\n"; # debug
        my @fan1b = split( /\s+/, $fan1a );
        $fan1 = $fan1b[1];
        $fan1 =~ s/[\n ]//g;

        # Fan 2
        $fan2a = $sensors[12];
        #print "fan2a = $fan2a\n"; # debug
        my @fan2b = split( /\s+/, $fan2a );
        $fan2 = $fan2b[1];
        $fan2 =~ s/[\n ]//g;

        # Fan 3
        $fan3a = $sensors[13];
        #print "fan3a = $fan3a\n"; # debug
        my @fan3b = split( /\s+/, $fan3a );
        $fan3 = $fan3b[1];
        $fan3 =~ s/[\n ]//g;

        # Temp 1
        $temp1a = $sensors[14];
        #print "temp1a = $temp1a\n"; # debug
        my @temp1b = split( /\s+/, $temp1a );
        $temp1 = $temp1b[1];
        #print "temp1c = $temp1c\n"; # debug
        #my @temp1d = split( /\+/, $temp1c );
        #$temp1 = $temp1d[1];
        $temp1 =~ s/[\n ]//g;

#       # Temp 2
#        $temp2a = $sensors[15];
#        #print "temp2a = $temp2a\n"; # debug
#        my @temp2b = split( /\s+/, $temp2a );
#        $temp2 = $temp2b[1];
#        #print "temp2c = $temp2c\n"; # debug
#        #my @temp2d = split( /\+/, $temp2c );
#        #$temp2 = $temp2d[1];
#        $temp2 =~ s/[\n ]//g;

        # Temp 3
        $temp3a = $sensors[16];
        #print "temp3a = $temp3a\n"; # debug
        my @temp3b = split( /\s+/, $temp3a );
        $temp3 = $temp3b[1];
        #print "temp3c = $temp3c\n"; # debug
        #my @temp3d = split( /\+/, $temp3c );
        #$temp3 = $temp3d[1];
        $temp3 =~ s/[\n ]//g;

        # vid
        $vida = $sensors[17];
        #print "vida = $vida\n"; # debug
        my @vidb = split( /\s+/, $vida );
        $vid = $vidb[1];
        #print "vidc = $vidc\n"; # debug
        #my @vidd = split( /\+/, $vidc );
        #$vid = $vidd[1];
        $vid =~ s/[\n ]//g;

        print "Vcore1 voltage = $vcore1\n";
        print "Vcore2 voltage = $vcore2\n";
        print "+3.3V voltage = $p33v\n";
        print "+5V voltage = $p5v\n";
        print "+12V voltage = $p12v\n";
        print "-12V voltage = $n12v\n";
        print "-5V voltage = $n5v\n";
        print "V5SB voltage = $v5sb\n";
        print "VBat voltage = $vbat\n";
        print "Vid voltage = $vid\n";
}

sub update {
    #   $_[0] = filename
    RRDs::update( "$log/$_[0].rrd", "-t",
        "vcore1:vcore2:p33v:p5v:p12v:n12v:n5v:v5sb:vbat:fan1:fan2:fan3:temp1:temp3:vid",
        "N:$vcore1:$vcore2:$p33v:$p5v:$p12v:$n12v:$n5v:$v5sb:$vbat:$fan1:$fan2:$fan3:$temp1:$temp3:$vid");
    $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 Motherboard Sensor Readings :: $_[0]",
        "DEF:vcore1=$log/$dbf.rrd:vcore1:AVERAGE",
        "DEF:vcore2=$log/$dbf.rrd:vcore2:AVERAGE",
        "DEF:p33v=$log/$dbf.rrd:p33v:AVERAGE",
        "DEF:p5v=$log/$dbf.rrd:p5v:AVERAGE",
        "DEF:p12v=$log/$dbf.rrd:p12v:AVERAGE",
        "DEF:n12v=$log/$dbf.rrd:n12v:AVERAGE",
        "DEF:n5v=$log/$dbf.rrd:n5v:AVERAGE",
        "DEF:v5sb=$log/$dbf.rrd:v5sb:AVERAGE",
        "DEF:vbat=$log/$dbf.rrd:vbat:AVERAGE",
        "DEF:vid=$log/$dbf.rrd:vid:AVERAGE",
        "LINE1:vcore1$color_vcore1:CPU Core 1\\:",
        "GPRINT:vcore1:MIN:Minimum\\: % 5.1lf",
        "GPRINT:vcore1:MAX:Maximum\\: % 5.1lf",
        "GPRINT:vcore1:AVERAGE:Average\\: % 5.1lf",
        "GPRINT:vcore1:LAST:Current\\: % 5.1lf V\\j",
        "LINE1:vcore2$color_vcore2:CPU Core 2\\:",
        "GPRINT:vcore2:MIN:Minimum\\: % 5.1lf",
        "GPRINT:vcore2:MAX:Maximum\\: % 5.1lf",
        "GPRINT:vcore2:AVERAGE:Average\\: % 5.1lf",
        "GPRINT:vcore2:LAST:Current\\: % 5.1lf V\\j",
        "LINE1:p33v$color_p33v:PSU 3.3v\\:  ",
        "GPRINT:p33v:MIN:Minimum\\: % 5.1lf",
        "GPRINT:p33v:MAX:Maximum\\: % 5.1lf",
        "GPRINT:p33v:AVERAGE:Average\\: % 5.1lf",
        "GPRINT:p33v:LAST:Current\\: % 5.1lf V\\j",
        "LINE1:p5v$color_p5v:PSU 5v\\:    ",
        "GPRINT:p5v:MIN:Minimum\\: % 5.1lf",
        "GPRINT:p5v:MAX:Maximum\\: % 5.1lf",
        "GPRINT:p5v:AVERAGE:Average\\: % 5.1lf",
        "GPRINT:p5v:LAST:Current\\: % 5.1lf V\\j",
        "LINE1:p12v$color_p12v:PSU 12v\\:   ",
        "GPRINT:p12v:MIN:Minimum\\: % 5.1lf",
        "GPRINT:p12v:MAX:Maximum\\: % 5.1lf",
        "GPRINT:p12v:AVERAGE:Average\\: % 5.1lf",
        "GPRINT:p12v:LAST:Current\\: % 5.1lf V\\j",
        "LINE1:n12v$color_p12v:PSU -12v\\:  ",
        "GPRINT:n12v:MIN:Minimum\\: % 5.1lf",
        "GPRINT:n12v:MAX:Maximum\\: % 5.1lf",
        "GPRINT:n12v:AVERAGE:Average\\: % 5.1lf",
        "GPRINT:n12v:LAST:Current\\: % 5.1lf V\\j",
        "LINE1:n5v$color_n5v:PSU -5v\\:   ",
        "GPRINT:n5v:MIN:Minimum\\: % 5.1lf",
        "GPRINT:n5v:MAX:Maximum\\: % 5.1lf",
        "GPRINT:n5v:AVERAGE:Average\\: % 5.1lf",
        "GPRINT:n5v:LAST:Current\\: % 5.1lf V\\j",
        "LINE1:v5sb$color_v5sb:V5SB\\:      ",
        "GPRINT:v5sb:MIN:Minimum\\: % 5.1lf",
        "GPRINT:v5sb:MAX:Maximum\\: % 5.1lf",
        "GPRINT:v5sb:AVERAGE:Average\\: % 5.1lf",
        "GPRINT:v5sb:LAST:Current\\: % 5.1lf V\\j",
        "LINE1:vbat$color_vbat:Battery\\:   ",
        "GPRINT:vbat:MIN:Minimum\\: % 5.1lf",
        "GPRINT:vbat:MAX:Maximum\\: % 5.1lf",
        "GPRINT:vbat:AVERAGE:Average\\: % 5.1lf",
        "GPRINT:vbat:LAST:Current\\: % 5.1lf V\\j",
        "LINE1:vid$color_vid:Video\\:     ",
        "GPRINT:vid:MIN:Minimum\\: % 5.1lf",
        "GPRINT:vid:MAX:Maximum\\: % 5.1lf",
        "GPRINT:vid:AVERAGE:Average\\: % 5.1lf",
        "GPRINT:vid:LAST:Current\\: % 5.1lf V\\j");
    $ERROR = RRDs::error;
    print "Error: RRDs::graph failed for '$_[0]' : $ERROR\n" if $ERROR;
}
########################################################################
create "$dbf";
gather;
update "$dbf";
graph 'day',   'Daily';
graph 'week',  'Weekly';
graph 'month', 'Monthly';
graph 'year',  'Yearly';
########################################################################
# vim: sw=4 ts=8
# End


And in order to get all that to graph, I edited the rrd_Configure.sh (lines 254-265) and replaced them with:
Code:
function choose_rrd() { # no arguments.
    SAFE='CPU Load Mem Swap'
    # Establish the checklist:
    TYPARY=( \
    Net         "Network In/Out Traffic"        on \
    Count       "Count of files in /myth/tv"    on \
    MythFS      "/myth Space & Inode usage"     on \
    HDtemp      "Disk temperature"              on \
    MBsensors-temp      "MB and CPU temperature"        on \
    MBsensors-fan       "MB fan speeds"                 on \
    MBsensors   "MB sensor readings"            on \
    )


I then re-ran the rrd_Configure.sh script and had all my info appear. Hope this was helpful.

Author:  Heem [ Wed Sep 19, 2007 8:31 am ]
Post subject: 

I like your solution Mike. I was going for a "quick and dirty" method in my original thread on the topic. I'm going to try your way as well to see if I like your output better.

Author:  arriflex [ Tue Oct 02, 2007 7:45 pm ]
Post subject: 

I was curious what the outcome was of your trying this out before I go and do the same from a noob standpoint!

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/