/[ps-trend]/ps2rrd.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /ps2rrd.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 13 by dpavlin, Fri Jul 17 16:41:12 2009 UTC revision 16 by dpavlin, Sun Jul 19 18:47:52 2009 UTC
# Line 12  my $debug = 0; Line 12  my $debug = 0;
12  my $zoom = 2;  my $zoom = 2;
13    
14  my $only_veid;  my $only_veid;
15    my $by_veid;
16  my $too_small = 64;     # M  my $too_small = 64;     # M
17  my $filter = qr{(apache|mysql|postgres|cgi-bin|SIP)};  my $filter = qr{(apache|mysql|postgres|cgi-bin|SIP)};
18    
19    my $use = 'VSZ';
20    
21  GetOptions(  GetOptions(
22          'debug!'   => \$debug,          'debug!'   => \$debug,
23          'zoom=i'   => \$zoom,          'zoom=i'   => \$zoom,
24          'veid=i'   => \$only_veid,          'only-veid=i' => \$only_veid,
25            'by-veid!' => \$by_veid,
26          'size=i'   => \$too_small,          'size=i'   => \$too_small,
27            'use=s'    => \$use,
28  );  );
29    
30    
# Line 34  sub count { Line 39  sub count {
39    
40          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)};          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)};
41    
42          warn "# $file ", -s $file, " bytes [$t]\n" if $debug;  #       warn "# $file ", -s $file, " bytes [$t]\n" if $debug;
43            print STDERR "\n$file\t";
44    
45          my $cols = <$fh>;          my $cols = <$fh>;
46          $cols =~ s/^\s+//;          $cols =~ s/^\s+//;
# Line 60  sub count { Line 66  sub count {
66    
67                  my $veid = c('VEID');                  my $veid = c('VEID');
68                  next if defined $only_veid && $only_veid != $veid;                  next if defined $only_veid && $only_veid != $veid;
69                  $veid =~ s/^0$/0-hw/;                  $veid =~ s/^0$/_hw_0/;
70    
71                  my $s = c('VSZ');                  my $s = c($use);
72                  my $cmd = c('COMMAND');                  my $cmd = c('COMMAND');
73                  if ( $cmd =~ $filter ) {                  if ( ! $by_veid && $cmd =~ $filter ) {
74    
75                          $veid .= '-' . $1;                          $veid .= '-' . $1;
76                          $vsz->{$t}->{$veid} += $s * 1024;                          $vsz->{$t}->{$veid} += $s * 1024;
77                          print STDERR uc(substr($1,0,1));                          print STDERR uc(substr($1,0,1));
78    
79                  } elsif ( $s < $too_small ) {                  } elsif ( $s < $too_small || $by_veid ) {
80    
81                          $vsz->{$t}->{$veid}+= $s * 1024;                          $vsz->{$t}->{$veid}+= $s * 1024;
82                          print STDERR ".";                          print STDERR ".";
# Line 101  count $_ foreach @ARGV; Line 107  count $_ foreach @ARGV;
107  my @veids = sort keys %$veids;  my @veids = sort keys %$veids;
108  warn "# veids = ",dump( @veids );  warn "# veids = ",dump( @veids );
109    
110  my $rrd_file = 'ps.rrd';  my $rrd_file = $use . '.rrd';
111  unlink $rrd_file if -e $rrd_file;  unlink $rrd_file if -e $rrd_file;
112    
113  my @t = sort keys %$vsz;  my @t = sort keys %$vsz;
# Line 128  $rrd->graph( Line 134  $rrd->graph(
134          source_drawtypes => [ map { $_ ? 'STACK' : 'AREA' } 0 .. $#veids ],          source_drawtypes => [ map { $_ ? 'STACK' : 'AREA' } 0 .. $#veids ],
135          periods => [ qw/hour 6hour 12hour day week month year 3years/ ],          periods => [ qw/hour 6hour 12hour day week month year 3years/ ],
136          extended_legend => 1,          extended_legend => 1,
137          title => "memory > $too_small K",          title => "$use > $too_small K",
138          width =>  500 * $zoom,          width =>  500 * $zoom,
139          height => 200 * $zoom,          height => 200 * $zoom,
140  );  );

Legend:
Removed from v.13  
changed lines
  Added in v.16

  ViewVC Help
Powered by ViewVC 1.1.26