/[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 11 by dpavlin, Fri Jul 17 13:25:34 2009 UTC revision 14 by dpavlin, Fri Jul 17 18:35:34 2009 UTC
# Line 13  my $zoom = 2; Line 13  my $zoom = 2;
13    
14  my $only_veid;  my $only_veid;
15  my $too_small = 64;     # M  my $too_small = 64;     # M
16    my $filter = qr{(apache|mysql|postgres|cgi-bin|SIP)};
17    
18  GetOptions(  GetOptions(
19          'debug!'   => \$debug,          'debug!'   => \$debug,
# Line 33  sub count { Line 34  sub count {
34    
35          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)};
36    
37          warn "# $file ", -s $file, " bytes [$t]\n" if $debug;  #       warn "# $file ", -s $file, " bytes [$t]\n" if $debug;
38            print STDERR "\n$file\t";
39    
40          my $cols = <$fh>;          my $cols = <$fh>;
41          $cols =~ s/^\s+//;          $cols =~ s/^\s+//;
# Line 59  sub count { Line 61  sub count {
61    
62                  my $veid = c('VEID');                  my $veid = c('VEID');
63                  next if defined $only_veid && $only_veid != $veid;                  next if defined $only_veid && $only_veid != $veid;
64                  $veid =~ s/^0$/0-hw/;                  $veid =~ s/^0$/_hw_0/;
65    
66                  my $s = c('VSZ');                  my $s = c('VSZ');
67                  if ( $s < $too_small ) {                  my $cmd = c('COMMAND');
68                    if ( $cmd =~ $filter ) {
69    
70                            $veid .= '-' . $1;
71                            $vsz->{$t}->{$veid} += $s * 1024;
72                            print STDERR uc(substr($1,0,1));
73    
74                    } elsif ( $s < $too_small ) {
75    
76                          $vsz->{$t}->{$veid}+= $s * 1024;                          $vsz->{$t}->{$veid}+= $s * 1024;
77                          print STDERR ".";                          print STDERR ".";
78    
79                  } else {                  } else {
80                          my $cmd = c('COMMAND');  
81                          $cmd =~ s{-.+$}{};                          $cmd =~ s{-.+$}{};
82                          $cmd =~ s{^/\S+/(\w+?)}{$1};                          $cmd =~ s{^/\S+/(\w+?)}{$1};
83                          $cmd =~ s{^\w+ /\S+/(\w+?)}{$1};                          $cmd =~ s{^\w+ /\S+/(\w+?)}{$1};
# Line 99  my @t = sort keys %$vsz; Line 110  my @t = sort keys %$vsz;
110  print "\ndrawing $#t intervals ", $t[0], " - ", $t[$#t];  print "\ndrawing $#t intervals ", $t[0], " - ", $t[$#t];
111    
112  my $rrd = RRD::Simple->new( file => $rrd_file );  my $rrd = RRD::Simple->new( file => $rrd_file );
113  $rrd->create( 'hour', map { ( $_ => 'GAUGE' ) } @veids );  $rrd->create( map { ( $_ => 'GAUGE' ) } @veids );
114    
115  foreach my $t ( @t ) {  foreach my $t ( @t ) {
116          print STDERR ".";          print STDERR ".";

Legend:
Removed from v.11  
changed lines
  Added in v.14

  ViewVC Help
Powered by ViewVC 1.1.26