--- ps2rrd.pl 2009/07/17 16:41:12 13 +++ ps2rrd.pl 2009/07/19 18:47:52 16 @@ -12,14 +12,19 @@ my $zoom = 2; my $only_veid; +my $by_veid; my $too_small = 64; # M my $filter = qr{(apache|mysql|postgres|cgi-bin|SIP)}; +my $use = 'VSZ'; + GetOptions( 'debug!' => \$debug, 'zoom=i' => \$zoom, - 'veid=i' => \$only_veid, + 'only-veid=i' => \$only_veid, + 'by-veid!' => \$by_veid, 'size=i' => \$too_small, + 'use=s' => \$use, ); @@ -34,7 +39,8 @@ my $t = mktime( 0, $5, $4, $3, $2 - 1, $1 - 1900 ) if $file =~ m{(\d\d\d\d)-(\d\d)-(\d\d)/(\d\d)(\d\d)}; - warn "# $file ", -s $file, " bytes [$t]\n" if $debug; +# warn "# $file ", -s $file, " bytes [$t]\n" if $debug; + print STDERR "\n$file\t"; my $cols = <$fh>; $cols =~ s/^\s+//; @@ -60,17 +66,17 @@ my $veid = c('VEID'); next if defined $only_veid && $only_veid != $veid; - $veid =~ s/^0$/0-hw/; + $veid =~ s/^0$/_hw_0/; - my $s = c('VSZ'); + my $s = c($use); my $cmd = c('COMMAND'); - if ( $cmd =~ $filter ) { + if ( ! $by_veid && $cmd =~ $filter ) { $veid .= '-' . $1; $vsz->{$t}->{$veid} += $s * 1024; print STDERR uc(substr($1,0,1)); - } elsif ( $s < $too_small ) { + } elsif ( $s < $too_small || $by_veid ) { $vsz->{$t}->{$veid}+= $s * 1024; print STDERR "."; @@ -101,7 +107,7 @@ my @veids = sort keys %$veids; warn "# veids = ",dump( @veids ); -my $rrd_file = 'ps.rrd'; +my $rrd_file = $use . '.rrd'; unlink $rrd_file if -e $rrd_file; my @t = sort keys %$vsz; @@ -128,7 +134,7 @@ source_drawtypes => [ map { $_ ? 'STACK' : 'AREA' } 0 .. $#veids ], periods => [ qw/hour 6hour 12hour day week month year 3years/ ], extended_legend => 1, - title => "memory > $too_small K", + title => "$use > $too_small K", width => 500 * $zoom, height => 200 * $zoom, );