--- ps2rrd.pl 2009/07/17 12:37:29 10 +++ ps2rrd.pl 2009/07/17 13:25:34 11 @@ -6,14 +6,25 @@ use Data::Dump qw/dump/; use RRD::Simple; use POSIX qw/mktime/; +use Getopt::Long; my $debug = 0; my $zoom = 2; +my $only_veid; +my $too_small = 64; # M + +GetOptions( + 'debug!' => \$debug, + 'zoom=i' => \$zoom, + 'veid=i' => \$only_veid, + 'size=i' => \$too_small, +); + + my $veids; my $vsz; -my $too_small = 16; # M $too_small *= 1024; # k sub count { @@ -47,7 +58,8 @@ @r = split(/\s+/, $_, $#c + 1 ); my $veid = c('VEID'); - $veid =~ s/^0$/hw/; + next if defined $only_veid && $only_veid != $veid; + $veid =~ s/^0$/0-hw/; my $s = c('VSZ'); if ( $s < $too_small ) { @@ -70,22 +82,26 @@ } -print STDERR "reading ps dumps"; +print STDERR "parsing ps with grouping < $too_small k"; count $_ foreach @ARGV; #print "VSZ: ",dump( $vsz ); -my @veids = keys %$veids; -warn "# veids = ",dump( sort @veids ); +my @veids = sort keys %$veids; +warn "# veids = ",dump( @veids ); my $rrd_file = 'ps.rrd'; unlink $rrd_file if -e $rrd_file; +my @t = sort keys %$vsz; + +print "\ndrawing $#t intervals ", $t[0], " - ", $t[$#t]; + my $rrd = RRD::Simple->new( file => $rrd_file ); $rrd->create( 'hour', map { ( $_ => 'GAUGE' ) } @veids ); -foreach my $t ( sort keys %$vsz ) { +foreach my $t ( @t ) { print STDERR "."; # warn "## ",dump( %{ $vsz->{$t} } );