[rrd-developers] Bug#499349: librrds-perl: RRDs takes too much memory
Sebastian Harl
sh at tokkee.org
Thu Sep 18 12:17:42 CEST 2008
tags 499349 + upstream
thanks
Hi,
(This is a follow-up to Debian bug #499349 [1]. Please keep
499349-forwarded at bugs.debian.org Cc'ed when replying.)
[1] http://bugs.debian.org/499349
On Thu, Sep 18, 2008 at 12:46:00AM +0200, Vincent Lefevre wrote:
> Perl scripts using RRDs and running continuously take too much memory:
> e.g. several dozen of MBs. For instance, after 30 hours:
>
> PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command
> 2651 lefevre 20 0 117M 80588 4548 S 0.0 31.6 2h48:00 perl /home/lefevre
>
> This makes the machine very slow, almost unusable (it is an old
> machine with not much memory), with a load average that can go
> up to 7, in particular because I have several of such scripts.
> I've attached the one corresponding to the above line.
>
> I didn't have such problems in the past.
>
> Since the used memory increases, I suspect a new memory leak.
I'm not yet into the RRDs code, so I'd really appreciate if someone else
on rrd-developers could have a look at that.
TIA,
Sebastian
--
Sebastian "tokkee" Harl +++ GnuPG-ID: 0x8501C7FC +++ http://tokkee.org/
Those who would give up Essential Liberty to purchase a little Temporary
Safety, deserve neither Liberty nor Safety. -- Benjamin Franklin
-------------- next part --------------
#!/usr/bin/env perl
use strict;
use Filesys::DiskSpace;
use RRDs;
my $RCSID = '$Id: disk-update 2770 2004-03-17 22:39:32Z lefevre $';
my ($proc) = $RCSID =~ /^.Id: (\S+) / or die;
@ARGV or die "Usage: $proc <rrdfile> [ <webdir> ]\n";
my $file = shift;
-f $file or die "$proc: RRDtool file isn't a plain file\n";
-r $file or die "$proc: RRDtool file isn't readable\n";
-w $file or die "$proc: RRDtool file isn't writable\n";
my $wdir = shift;
if (defined $wdir)
{ -d $wdir or die "$proc: $wdir isn't a directory\n"; }
my %t = (
'day' => 1,
'week' => 6,
'month' => 24,
'year' => 288);
for(;;)
{
my $time = time;
my $root = (df '/')[2];
my $home = (df '/home')[2];
time - $time < 3
and RRDs::update ($file, "$time:$root:$home");
&rrdgraph('root', '/dev/hda4');
&rrdgraph('home', '/dev/hda5');
sleep 60;
}
sub rrdgraph
{
defined $wdir or return;
my ($name,$fs) = @_;
foreach (qw/day week month year/)
{
RRDs::graph ("$wdir/$name-$_.png", '-a', 'PNG',
'-h', 200, '-v', $fs, '-b', 1024,
'--start', -120000*$t{$_},
"DEF:kavg=$file:$name:AVERAGE", "CDEF:avg=kavg,1024,*",
"DEF:kmax=$file:$name:MAX", "CDEF:max=kmax,1024,*",
"AREA:avg#00ff00", "LINE1:max#ff0000");
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.oetiker.ch/pipermail/rrd-developers/attachments/20080918/b6da35d5/attachment.bin
More information about the rrd-developers
mailing list