![]() |
downloads | documentation | HowTo | reporting bugs | links | Recent Changes |
What is a Wiki?See WikiWikiWeb If you don't know how to use a wiki see the WikiHowto ErfurtWiki is maintained by a loosely knit group of developers. Quick LinksRelated sitesContactPlease submit website bugs in the BugReports Contribute!Please file any wishes on UserSuggestions. Hosted By |
This HOWTO shows some quick steps to use rrdtool to allow you to monitor your KnoppMyth backend's important stats, like CPU usage, Memory usage, Disk usage, Network usage, and Disk temperature for S.M.A.R.T. enabled disks. A quick note, I got this working on my machine a while ago, and while I think this is all the steps I took to get it working, it has been a while, so there may be omissions. I got this working on R5D1. Please skip to the bottom for notes about R5E50. For R5F1, just run /usr/local/bin/rrd_Configure.sh as root to set up rrdtool. None of the other edits below are required. This will write to /myth/rrd.? A extra step can be taken to add RRD Disk Partition Usage if required. Most of these scripts were taken from other sites, and though some were modified, let me assure you that I don't have nearly enough perl knowledge to have created these on my own. If you want to keep your databases in a location other than /var/lib/rrd, be sure to modify that in each of the files below. If anyone else has some good scripts for using mbmon or other monitoring tools with rrdtool please post them below. Please use this thread for discussion. Example output
Get the necessary programs.apt-get update apt-get install rrdtool librrds-perl hddtemp sysstat Create /usr/local/bin/rrd_cpu.plnano /usr/local/bin/rrd_cpu.pl Copy paste the following into the buffer:
#!/usr/bin/perl
use RRDs;
my $rrdlog = '/var/lib/rrd';
my $graphs = '/var/www/rrdtool';
updatecpudata();
updatecpugraph('day');
updatecpugraph('week');
updatecpugraph('month');
updatecpugraph('year');
sub updatecpugraph {
my $period = $_[0];
RRDs::graph ("$graphs/cpu-$period.png",
"--start", "-1$period", "-aPNG", "-i", "-z",
"--alt-y-grid", "-w 600", "-h 100", "-l 0", "-u 100", "-r",
"--color", "SHADEA#EAE9EE",
"--color", "SHADEB#EAE9EE",
"--color", "BACK#EAE9EE",
"-t cpu usage per $period",
"DEF:user=$rrdlog/cpu.rrd:user:AVERAGE",
"DEF:system=$rrdlog/cpu.rrd:system:AVERAGE",
"DEF:idle=$rrdlog/cpu.rrd:idle:AVERAGE",
"CDEF:total=user,system,idle,+,+",
"CDEF:userpct=100,user,total,/,*",
"CDEF:systempct=100,system,total,/,*",
"CDEF:idlepct=100,idle,total,/,*",
"AREA:userpct#0000FF:user cpu usage\\j",
"STACK:systempct#FF0000:system cpu usage\\j",
"STACK:idlepct#00FF00:idle cpu usage\\j",
"GPRINT:userpct:MAX:maximal user cpu\\:%3.2lf%%",
"GPRINT:userpct:AVERAGE:average user cpu\\:%3.2lf%%",
"GPRINT:userpct:LAST:current user cpu\\:%3.2lf%%\\j",
"GPRINT:systempct:MAX:maximal system cpu\\:%3.2lf%%",
"GPRINT:systempct:AVERAGE:average system cpu\\:%3.2lf%%",
"GPRINT:systempct:LAST:current system cpu\\:%3.2lf%%\\j",
"GPRINT:idlepct:MAX:maximal idle cpu\\:%3.2lf%%",
"GPRINT:idlepct:AVERAGE:average idle cpu\\:%3.2lf%%",
"GPRINT:idlepct:LAST:current idle cpu\\:%3.2lf%%\\j");
$ERROR = RRDs::error;
print "Error in RRD::graph for cpu: $ERROR\n" if $ERROR;
}
sub updatecpudata {
if ( ! -e "$rrdlog/cpu.rrd") {
RRDs::create ("$rrdlog/cpu.rrd", "--step=300",
"DS:user:COUNTER:600:0:U",
"DS:system:COUNTER:600:0:U",
"DS:idle:COUNTER: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 in RRD::create for cpu: $ERROR\n" if $ERROR;
}
my ($cpu, $user, $nice, $system, $idle);
open STAT, "/proc/stat";
while(<STAT>) {
chomp;
/^cpu\s/ or next;
($cpu, $user, $nice, $system, $idle) = split /\s+/;
last;
}
close STAT;
$user += $nice;
RRDs::update ("$rrdlog/cpu.rrd",
"-t", "user:system:idle",
"N:$user:$system:$idle");
$ERROR = RRDs::error;
print "Error in RRD::update for cpu: $ERROR\n" if $ERROR;
print "N:$user:$system:$idle\n";
}
Create /usr/local/bin/rrd_disk.pl
#!/usr/bin/perl
use RRDs;
my $rrdlog = '/var/lib/rrd';
my $graphs = '/var/www/rrdtool';
updatedata ();
updategraph ('day');
updategraph ('week');
updategraph ('month');
updategraph ('year');
sub updatedata {
my ($readsect, $writesect);
if ( ! -e "$rrdlog/disk.rrd") {
RRDs::create ("$rrdlog/disk.rrd", "--step=300",
"DS:readsect:COUNTER:600:0:5000000000",
"DS:writesect:COUNTER:600:0:5000000000",
"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 in RRD::create for disk: $ERROR\n" if $ERROR;
print "$rrdlog/disk.rrd created.";
}
my @diskdata = `iostat -d`;
my $temp = $diskdata[3];
chomp($temp);
my @tempa = split(/\s+/, $temp);
$readsect= $tempa[4];
$writesect= $tempa[5];
print "N:$readsect:$writesect\n";
RRDs::update ("$rrdlog/disk.rrd",
"-t", "readsect:writesect",
"N:$readsect:$writesect");
$ERROR = RRDs::error;
print "Error in RRD::update for disk: $ERROR\n" if $ERROR;
}
sub updategraph {
my $period = $_[0];
RRDs::graph ("$graphs/disk-$period.png",
"--start", "-1$period", "-aPNG", "-i", "-z",
"--alt-y-grid", "-w 600", "-h 100", "-l 0", "-r",
"--color", "SHADEA#EAE9EE",
"--color", "SHADEB#EAE9EE",
"--color", "BACK#EAE9EE",
"-t disk access per $period",
"DEF:read=$rrdlog/disk.rrd:readsect:AVERAGE",
"DEF:write=$rrdlog/disk.rrd:writesect:AVERAGE",
"AREA:read#0000FF:sectors read from disk per second\\j",
"STACK:write#00FF00:sectors written to disk per second\\j",
"GPRINT:read:MAX:maximal read sectors\\:%8.0lf",
"GPRINT:read:AVERAGE:average read sectors\\:%8.0lf",
"GPRINT:read:LAST:current read sectors\\:%8.0lf\\j",
"GPRINT:write:MAX:maximal written sectors\\:%8.0lf",
"GPRINT:write:AVERAGE:average written sectors\\:%8.0lf",
"GPRINT:write:LAST:current written sectors\\:%8.0lf\\j");
$ERROR = RRDs::error;
print "Error in RRD::graph for disk: $ERROR\n" if $ERROR;
}
Create /usr/local/bin/rrd_traffic.pl
#!/usr/bin/perl
#
# copyright Martin Pot 2003
# http://martybugs.net/linux/rrdtool/traffic.cgi
#
# rrd_traffic.pl
use RRDs;
# define location of rrdtool databases
my $rrd = '/var/lib/rrd';
my $rrdlog = '/var/lib/rrd';
# define location of images
my $img = '/var/www/rrdtool';
my $graphs = '/var/www/rrdtool';
# process data for each interface (add/delete as required)
&ProcessInterface("eth0", "local network");
#&ProcessInterface("eth1", "internet gateway");
updateifgraph ('eth0', 'day');
updateifgraph ('eth0', 'week');
updateifgraph ('eth0', 'month');
updateifgraph ('eth0', 'year');
sub ProcessInterface
{
# process interface
# inputs: $_[0]: interface name (ie, eth0/eth1/eth2/ppp0)
# $_[1]: interface description
# get network interface info
my $in = `ifconfig $_[0] |grep bytes|cut -d":" -f2|cut -d" " -f1`;
my $out = `ifconfig $_[0] |grep bytes|cut -d":" -f3|cut -d" " -f1`;
# remove eol chars
chomp($in);
chomp($out);
print "$_[0] traffic in, out: $in, $out\n";
# if rrdtool database doesn't exist, create it
if (! -e "$rrd/$_[0].rrd")
{
print "creating rrd database for $_[0] interface...\n";
RRDs::create "$rrd/$_[0].rrd",
"-s 300",
"DS:in:DERIVE:600:0:12500000",
"DS:out:DERIVE:600:0:12500000",
"RRA:AVERAGE:0.5:1:576",
"RRA:AVERAGE:0.5:6:672",
"RRA:AVERAGE:0.5:24:732",
"RRA:AVERAGE:0.5:144:1460";
}
# insert values into rrd
RRDs::update "$rrd/$_[0].rrd",
"-t", "in:out",
"N:$in:$out";
}
sub CreateGraph
{
# creates graph
# inputs: $_[0]: interface name (ie, eth0/eth1/eth2/ppp0)
# $_[1]: interval (ie, day, week, month, year)
# $_[2]: interface description
RRDs::graph "$img/$_[0]-$_[1].png",
"-s -1$_[1]",
"-t traffic on $_[0] :: $_[2]",
"--lazy",
"-h", "80", "-w", "600",
"-l 0",
"-a", "PNG",
"-v bytes/sec",
"DEF:in=$rrd/$_[0].rrd:in:AVERAGE",
"DEF:out=$rrd/$_[0].rrd:out:AVERAGE",
"CDEF:out_neg=out,-1,*",
"AREA:in#32CD32:Incoming",
"LINE1:in#336600",
"GPRINT:in:MAX: Max\\: %5.1lf %s",
"GPRINT:in:AVERAGE: Avg\\: %5.1lf %S",
"GPRINT:in:LAST: Current\\: %5.1lf %Sbytes/sec\\n",
"AREA:out_neg#4169E1:Outgoing",
"LINE1:out_neg#0033CC",
"GPRINT:out:MAX: Max\\: %5.1lf %S",
"GPRINT:out:AVERAGE: Avg\\: %5.1lf %S",
"GPRINT:out:LAST: Current\\: %5.1lf %Sbytes/sec",
"HRULE:0#000000";
if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] traffic graph: $ERROR\n"; }
}
sub updateifgraph {
my $interface = $_[0];
my $period = $_[1];
RRDs::graph ("$graphs/$interface-$period.png",
"--start", "-1$period", "-aPNG", "-i", "-z",
"--alt-y-grid", "-w 600", "-h 100",
"--color", "SHADEA#EAE9EE",
"--color", "SHADEB#EAE9EE",
"--color", "BACK#EAE9EE",
"-t traffic on $interface (graph per $period)",
"-v bytes per second",
"DEF:incoming=$rrdlog/$interface.rrd:in:AVERAGE",
"DEF:outgoing=$rrdlog/$interface.rrd:out:AVERAGE",
"AREA:incoming#00FF00:incoming traffic in bytes per second\\j",
"LINE1:outgoing#0000FF:outgoing traffic in bytes per second\\j",
"GPRINT:incoming:MAX:maximal in\\:%8.3lf %sBps",
"GPRINT:incoming:AVERAGE:average in\\:%8.3lf %sBps",
"GPRINT:incoming:LAST:current in\\:%8.3lf %sBps\\j",
"GPRINT:outgoing:MAX:maximal out\\:%8.3lf %sBps",
"GPRINT:outgoing:AVERAGE:average out\\:%8.3lf %sBps",
"GPRINT:outgoing:LAST:current out\\:%8.3lf %sBps\\j");
$ERROR = RRDs::error;
print "Error in RRD::graph for $interface: $ERROR\n" if $ERROR;
}
Create /usr/local/bin/rrd_mem.pl
#!/usr/bin/perl
use RRDs;
my $rrdlog = '/var/lib/rrd';
my $graphs = '/var/www/rrdtool';
updatememdata ();
updatememgraph ('day');
updatememgraph ('week');
updatememgraph ('month');
updatememgraph ('year');
sub updatememgraph {
my $period = $_[0];
RRDs::graph ("$graphs/memory-$period.png",
"--start", "-1$period", "-aPNG", "-i", "-z",
"--alt-y-grid", "-w 600", "-h 100", "-l 0", "-u 100", "-r",
"--color", "SHADEA#EAE9EE",
"--color", "SHADEB#EAE9EE",
"--color", "BACK#EAE9EE",
"-t memory usage per $period",
"DEF:used=$rrdlog/mem.rrd:memused:AVERAGE",
"DEF:free=$rrdlog/mem.rrd:memfree:AVERAGE",
"DEF:shared=$rrdlog/mem.rrd:memshared:AVERAGE",
"DEF:buffer=$rrdlog/mem.rrd:membuffers:AVERAGE",
"DEF:cache=$rrdlog/mem.rrd:memcache:AVERAGE",
"CDEF:total=used,free,+",
"CDEF:used2=used,buffer,cache,shared,+,+,-",
"CDEF:usedpct=100,used2,total,/,*",
"CDEF:sharedpct=100,shared,total,/,*",
"CDEF:bufferpct=100,buffer,total,/,*",
"CDEF:cachepct=100,cache,total,/,*",
"CDEF:freepct=100,free,total,/,*",
"AREA:usedpct#0000FF:used memory\\j",
"STACK:sharedpct#FF0000:shared memory\\j",
"STACK:bufferpct#FF00FF:buffered memory\\j",
"STACK:cachepct#FFFF00:cached memory\\j",
"STACK:freepct#00FF00:free memory\\j",
"GPRINT:usedpct:MAX:maximal used memory\\:%3.2lf%%",
"GPRINT:usedpct:AVERAGE:average used memory\\:%3.2lf%%",
"GPRINT:usedpct:LAST:current used memory\\:%3.2lf%%\\j",
"GPRINT:sharedpct:MAX:maximal shared memory\\:%3.2lf%%",
"GPRINT:sharedpct:AVERAGE:average shared memory\\:%3.2lf%%",
"GPRINT:sharedpct:LAST:current shared memory\\:%3.2lf%%\\j",
"GPRINT:bufferpct:MAX:maximal buffered memory\\:%3.2lf%%",
"GPRINT:bufferpct:AVERAGE:average buffered memory\\:%3.2lf%%",
"GPRINT:bufferpct:LAST:current buffered memory\\:%3.2lf%%\\j",
"GPRINT:cachepct:MAX:maximal cached memory\\:%3.2lf%%",
"GPRINT:cachepct:AVERAGE:average cached memory\\:%3.2lf%%",
"GPRINT:cachepct:LAST:current cached memory\\:%3.2lf%%\\j",
"GPRINT:freepct:MAX:maximal free memory\\:%3.2lf%%",
"GPRINT:freepct:AVERAGE:average free memory\\:%3.2lf%%",
"GPRINT:freepct:LAST:current free memory\\:%3.2lf%%\\j");
$ERROR = RRDs::error;
print "Error in RRD::graph for mem: $ERROR\n" if $ERROR;
RRDs::graph ("$graphs/swap-$period.png",
"--start", "-1$period", "-aPNG", "-i", "-z",
"--alt-y-grid", "-w 600", "-h 100", "-l 0", "-u 100", "-r",
"--color", "SHADEA#EAE9EE",
"--color", "SHADEB#EAE9EE",
"--color", "BACK#EAE9EE",
"-t swap usage per $period",
"DEF:used=$rrdlog/mem.rrd:swapused:AVERAGE",
"DEF:free=$rrdlog/mem.rrd:swapfree:AVERAGE",
"CDEF:total=used,free,+",
"CDEF:usedpct=100,used,total,/,*",
"CDEF:freepct=100,free,total,/,*",
"AREA:usedpct#0000FF:used swap\\j",
"STACK:freepct#00FF00:free swap\\j",
"GPRINT:usedpct:MAX:maximal used swap\\:%3.2lf%%",
"GPRINT:usedpct:AVERAGE:average used swap\\:%3.2lf%%",
"GPRINT:usedpct:LAST:current used swap\\:%3.2lf%%\\j",
"GPRINT:freepct:MAX:maximal free swap\\:%3.2lf%%",
"GPRINT:freepct:AVERAGE:average free swap\\:%3.2lf%%",
"GPRINT:freepct:LAST:current free swap\\:%3.2lf%%\\j");
$ERROR = RRDs::error;
print "Error in RRD::graph for swap: $ERROR\n" if $ERROR;
}
sub updatememdata {
my ($memused, $memfree, $memshared, $membuffers, $memcache, $swapused, $swapfree);
if ( ! -e "$rrdlog/mem.rrd") {
RRDs::create ("$rrdlog/mem.rrd", "--step=300",
"DS:memused:ABSOLUTE:600:0:U",
"DS:memfree:ABSOLUTE:600:0:U",
"DS:memshared:ABSOLUTE:600:0:U",
"DS:membuffers:ABSOLUTE:600:0:U",
"DS:memcache:ABSOLUTE:600:0:U",
"DS:swapused:ABSOLUTE:600:0:U",
"DS:swapfree:ABSOLUTE: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 in RRD::create for mem: $ERROR\n" if $ERROR;
}
my @memdata = `free -b -o`;
my $temp = $memdata[1];
chomp( $temp );
my @tempa = split (/\s+/, $temp);
$memused = $tempa [2];
$memfree = $tempa [3];
$memshared = $tempa [4];
$membuffers = $tempa [5];
$memcache = $tempa [6];
$temp = $memdata[2];
chomp( $temp );
@tempa = split (/\s+/, $temp);
$swapused = $tempa [2];
$swapfree = $tempa [3];
print "N:$memused:$memfree:$memshared:$membuffers:$memcache:$swapused:$swapfree\n";
RRDs::update ("$rrdlog/mem.rrd",
"-t", "memused:memfree:memshared:membuffers:memcache:swapused:swapfree",
"N:$memused:$memfree:$memshared:$membuffers:$memcache:$swapused:$swapfree");
$ERROR = RRDs::error;
print "Error in RRD::update for mem: $ERROR\n" if $ERROR;
}
Create /usr/local/bin/rrd_hddtemp.pl
#!/usr/bin/perl
#
# copyright Martin Pot 2003
# http://martybugs.net/linux/hddtemp.cgi
#
# rrd_hddtemp.pl
use RRDs;
# define location of rrdtool databases
my $rrd = '/var/lib/rrd';
# define location of images
my $img = '/var/www/rrdtool';
# process data for each specified HDD (add/delete as required)
&ProcessHDD("hda", "primary master");
#&ProcessHDD("hdb", "primary slave");
#&ProcessHDD("hdc", "40GB Seagate");
#&ProcessHDD("hdd", "secondary slave");
sub ProcessHDD
{
# process HDD
# inputs: $_[0]: hdd (ie, hda, etc)
# $_[1]: hdd description
# get hdd temp for master drive on secondary IDE channel
my $temp=`/usr/sbin/hddtemp -n /dev/$_[0]`;
# remove eol chars and white space
$temp =~ s/[\n ]//g;
print "$_[1] (/dev/$_[0]) temp: $temp degrees C\n";
# if rrdtool database doesn't exist, create it
if (! -e "$rrd/$_[0].rrd")
{
print "creating rrd database for /dev/$_[0]...\n";
RRDs::create "$rrd/$_[0].rrd",
"-s 300",
"DS:temp:GAUGE:600:0:100",
"RRA:AVERAGE:0.5:1:576",
"RRA:AVERAGE:0.5:6:672",
"RRA:AVERAGE:0.5:24:732",
"RRA:AVERAGE:0.5:144:1460";
}
# insert value into rrd
RRDs::update "$rrd/$_[0].rrd",
"-t", "temp",
"N:$temp";
# create graphs
&CreateGraph($_[0], "day", $_[1]);
&CreateGraph($_[0], "week", $_[1]);
&CreateGraph($_[0], "month", $_[1]);
&CreateGraph($_[0], "year", $_[1]);
}
sub CreateGraph
{
# creates graph
# inputs: $_[0]: hdd name (ie, hda, etc)
# $_[1]: interval (ie, day, week, month, year)
# $_[2]: hdd description
RRDs::graph "$img/$_[0]-$_[1].png",
"--lazy",
"-s -1$_[1]",
"-t hdd temperature :: $_[2] (/dev/$_[0])",
"-h", "80", "-w", "600",
"-a", "PNG",
"-v degrees C",
"DEF:temp=$rrd/$_[0].rrd:temp:AVERAGE",
"LINE2:temp#0000FF:$_[2] (/dev/$_[0])",
"GPRINT:temp:MIN: Min\\: %2.lf",
"GPRINT:temp:MAX: Max\\: %2.lf",
"GPRINT:temp:AVERAGE: Avg\\: %4.1lf",
"GPRINT:temp:LAST: Current\\: %2.lf degrees C\\n";
if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] graph: $ERROR\n"; }
}
Make the .pl files executable.chmod each of the above files in /usr/local/bin to allow execution (775) Create the directory /var/www/rrdtoolmkdir /var/www/rrdtool Create the directory /var/lib/rrdmkdir /var/lib/rrd Add the following lines to/etc/crontab# get hdd temps for rrdtool */5 * * * * root /usr/local/bin/rrd_hddtemp.pl > /dev/null # get hdd io for rrdtool */5 * * * * root /usr/local/bin/rrd_disk.pl > /dev/null # get ip traffic for rrdtool */5 * * * * root /usr/local/bin/rrd_traffic.pl > /dev/null # get mem data for rrdtool */5 * * * * root /usr/local/bin/rrd_mem.pl > /dev/null # get cpu data for rrdtool */5 * * * * root /usr/local/bin/rrd_cpu.pl > /dev/null Here is a very simple HTML page. Which will allow you to view all the graphs on one page. Depening on your network interfaces and disk drives you may need to change this a little. But it is a starting point. Create /var/www/rrdtool/index.htm<HTML> <HEAD> </HEAD> <BODY> <FONT=BOLD>CPU usage</FONT> <P> <IMG SRC = "cpu-day.png"> <IMG SRC = "cpu-week.png"> <IMG SRC = "cpu-month.png"> <IMG SRC = "cpu-year.png"> </P> <FONT=BOLD>Disk Access</FONT> <P> <IMG SRC = "disk-day.png"> <IMG SRC = "disk-week.png"> <IMG SRC = "disk-month.png"> <IMG SRC = "disk-year.png"> </P> <FONT=BOLD>eth0 Usage</FONT> <P> <IMG SRC = "eth0-day.png"> <IMG SRC = "eth0-week.png"> <IMG SRC = "eth0-month.png"> <IMG SRC = "eth0-year.png"> </P> <FONT=BOLD>hda Temp</FONT> <P> <IMG SRC = "hda-day.png"> <IMG SRC = "hda-week.png"> <IMG SRC = "hda-month.png"> <IMG SRC = "hda-year.png"> </P> </BODY> </HTML> You should be all set. After a few minutes (5-10) you can browse to your KnoppMyth backend at http://mythtv/rrdtool/ (replace mythtv with your KnoppMyth backend's hostname or IP address) and see the graphs produced. Update 01/20/07: The steps above work with R5C7 too! NOTE: There is a problem where the disk usage graph gets screwed up after a reboot. This is because the counter of disk i/o gets reset to 0 on reboot, and I don't yet have enough experience working with rrdtool to figure out how to keep this from happening. Motherboard temp monitoring with mbmonCut & paste the code below into /usr/local/bin/rrd_mbtemp.pl
#!/usr/bin/perl
#
# Modified from Martin Pot's 2003 script at
# http://martybugs.net/linux/hddtemp.cgi
#
# Graphs motherboard temperatures using mbmon
# rrd_mbtemp.pl
use RRDs;
# define location of rrdtool databases
my $rrd = '/var/lib/rrd';
# define location of images
my $img = '/var/www/rrdtool';
# process data for each temperature sensor (add/delete as required)
# run mbmon -r -c 1 to see what temps your mobo supports, then make
# an educated guess about which component corresponds to which temp
# Note TEMP0 = T 1, TEMP1 = T 2, TEMP2 = T 3
&ProcessHDD("mbtemp", "T 1", "Motherboard");
&ProcessHDD("cputemp", "T 2", "CPU");
&ProcessHDD("ambtemp", "T 3", "Case ambient");
sub ProcessHDD
{
# process HDD
# inputs: $_[0]: component being measured (used for graph filenames)
# $_[1]: code (mbmon code)
# $_[2]: description
# get temp value from mbmon
my $temp=`/usr/bin/mbmon -c 1 -$_[1]`;
# remove eol chars and white space
$temp =~ s/[\n ]//g;
print "$_[2] temp: $temp degrees C\n";
# if rrdtool database doesn't exist, create it
if (! -e "$rrd/$_[0].rrd")
{
print "creating rrd database for $_[0]...\n";
RRDs::create "$rrd/$_[0].rrd",
"-s 300",
"DS:temp:GAUGE:600:0:100",
"RRA:AVERAGE:0.5:1:576",
"RRA:AVERAGE:0.5:6:672",
"RRA:AVERAGE:0.5:24:732",
"RRA:AVERAGE:0.5:144:1460";
}
# insert value into rrd
RRDs::update "$rrd/$_[0].rrd",
"-t", "temp",
"N:$temp";
# create graphs
&CreateGraph($_[0], "day", $_[2]);
&CreateGraph($_[0], "week", $_[2]);
&CreateGraph($_[0], "month", $_[2]);
&CreateGraph($_[0], "year", $_[2]);
}
sub CreateGraph
{
# creates graph
# inputs: $_[0]: component being measured (used for graph filenames)
# $_[1]: interval (ie, day, week, month, year)
# $_[2]: description
RRDs::graph "$img/$_[0]-$_[1].png",
"--lazy",
"-s -1$_[1]",
"--color", "SHADEA#EAE9EE",
"--color", "SHADEB#EAE9EE",
"--color", "BACK#295990",
"-t temperature :: $_[2] ($_[0])",
"-h", "80", "-w", "600",
"-a", "PNG",
"-v degrees C",
"DEF:temp=$rrd/$_[0].rrd:temp:AVERAGE",
"LINE2:temp#0000FF:$_[2] ($_[0])",
"GPRINT:temp:MIN: Min\\: %2.lf",
"GPRINT:temp:MAX: Max\\: %2.lf",
"GPRINT:temp:AVERAGE: Avg\\: %4.1lf",
"GPRINT:temp:LAST: Current\\: %2.lf degrees C\\n";
if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] graph: $ERROR\n"; }
}
Then add the following to /etc/crontab # get mobo temp data for rrdtool */5 * * * * root /usr/local/bin/rrd_mbtemp.pl > /dev/null KnoppMyth R5E50 NotesSome graphs may be empty after you install R5E50. Motherboard temperature sensorsRun the following as root: /usr/sbin/sensors-detect I just answer YES to everything. A new /etc/sensors.conf will be created, and /etc/modules will be modified. /dev/hda (ATA) vs. /dev/sda (SATA)Run each of the /usr/local/bin/rrd_*.pl lines in /etc/cron.hourly/rrd_km without the "> /dev/null" on the command line by itself to look for errors. root@mythsvr:/usr/local/bin# /usr/local/bin/rrd_hddtemp.pl /dev/hda: open: No such file or directory primary master (/dev/hda) temp: degrees C creating rrd database for /dev/hda... root@mythsvr:/usr/local/bin# I do not have /dev/hda because my first hard drive is a SATA drive at /dev/sda. Edit /usr/local/bin/rrd_hddtemp.pl to remove "&ProcessHDD("hda", "primary master");" and add "&ProcessHDD("sda", "sda");" as appropriate for your system. root@mythsvr:/usr/local/bin# /usr/local/bin/rrd_hddtemp.pl sda (/dev/sda) temp: 38 degrees C root@mythsvr:/usr/local/bin# /usr/local/bin/rrd_disk.pl N:14750100:12780768 root@mythsvr:/usr/local/bin# /usr/local/bin/rrd_traffic.pl eth0 traffic in, out: 22421356, 61817840 root@mythsvr:/usr/local/bin# /usr/local/bin/rrd_mem.pl N:1008947200:48865280:0:15368192:552812544:45056:2006913024 root@mythsvr:/usr/local/bin# /usr/local/bin/rrd_cpu.pl N:5313069:96089:5010093 root@mythsvr:/usr/local/bin# /usr/local/bin/rrd_mbtemp.pl Motherboard temp: 47.0 degrees C CPU temp: 71.0 degrees C Case ambient temp: 25.0 degrees C You may delete the following if you replaced hda with sda above. /var/lib/rrd/hda.rrd /var/www/rrdtool/hda*.png The following will also need to be modified if you replaced hda with sda above. /var/www/rrdtool_*.html Just do a global search and replace from "hda" to "sda". RRDTool hardware status graphs should now be working. You can directly run /etc/cron.hourly/rrd_km a few times to add some immediate data points to your graphs. EditThisPage BackLinks PageInfo Pages like this Attachments RSS/Atom last changed on Thu Aug 23 19:37:44 2007 |
UpdatedPages· TroubleShooting last changed on Wed Sep 8 10:58:29 2010· R5A12DvdRipping last changed on Wed Sep 8 10:56:26 2010 · PickingComponents last changed on Wed Sep 8 10:54:11 2010 · KnoppMythInstall last changed on Wed Sep 8 10:52:15 2010 · Additional Software last changed on Wed Sep 8 10:49:11 2010 · Links last changed on Wed Sep 8 10:45:45 2010 · HowTo last changed on Wed Sep 8 10:43:16 2010 · MythwebFlash last changed on Tue Sep 7 08:01:14 2010 · HauppaugeThreeFiftyInstallation last changed on Tue Sep 7 07:59:50 2010 · MythStreamTV last changed on Tue Sep 7 07:58:13 2010 · UsingSambaHowto last changed on Tue Sep 7 07:57:01 2010 · TVOverScanHowto last changed on Tue Sep 7 07:53:19 2010 · TinnyAudioPVR150 last changed on Mon Sep 6 14:42:38 2010 · KnoppmythDownloads last changed on Sun Sep 5 22:27:51 2010 · LinuxTips last changed on Fri Sep 3 12:44:17 2010 · RepairingMythConvergDB last changed on Wed Sep 1 01:56:32 2010 · KnoppMythWiki last changed on Sun Aug 29 14:22:57 2010 · HVR950HowTo last changed on Mon Aug 23 11:00:20 2010 · MythVodkaHowTo last changed on Mon Aug 23 00:48:53 2010 · x11vncHowTo last changed on Tue Aug 17 08:20:17 2010 · MediaMVP_LinuxHOWTO last changed on Tue Aug 17 08:17:10 2010 · webminhowto last changed on Tue Aug 17 08:11:10 2010 · MythTVBurn_Scripts_HowTo last changed on Mon Aug 16 15:44:19 2010 · EditThisPage last changed on Wed Aug 4 04:10:39 2010 · R5.5/R6.x Differences Table and Equivalent Commands last changed on Wed Aug 4 00:27:20 2010 · Media_Center_Edition_Remote_Control last changed on Tue Aug 3 08:19:13 2010 |
| sitemap | | |