/[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 6 by dpavlin, Thu Jul 16 19:13:01 2009 UTC revision 10 by dpavlin, Fri Jul 17 12:37:29 2009 UTC
# Line 5  use strict; Line 5  use strict;
5    
6  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
7  use RRD::Simple;  use RRD::Simple;
8  use DateTime;  use POSIX qw/mktime/;
9    
10  my $debug = 0;  my $debug = 0;
11  my $zoom = 2;  my $zoom = 2;
# Line 20  sub count { Line 20  sub count {
20          my $file = shift;          my $file = shift;
21          open(my $fh, '<', $file) || die "$file: $!";          open(my $fh, '<', $file) || die "$file: $!";
22    
23          print STDERR ".";          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 = (stat($file))[9];  
         if ( $file =~ m{(\d\d\d\d)-(\d\d)-(\d\d)/(\d\d)(\d\d)} ) {  
                 $t = new DateTime(  
                         year   => $1,  
                         month  => $2,  
                         day    => $3,  
                         hour   => $4,  
                         minute => $5,  
                 )->epoch;  
         }  
24    
25          warn "# $file ", -s $file, " bytes [$t]\n" if $debug;          warn "# $file ", -s $file, " bytes [$t]\n" if $debug;
26    
# Line 43  sub count { Line 32  sub count {
32          $cp->{$c[$_]} = $_ foreach 0 .. $#c;          $cp->{$c[$_]} = $_ foreach 0 .. $#c;
33          our @r;          our @r;
34          sub c {          sub c {
35                    return $r[ $cp->{$_[0]} ];      # XXX speedup
36    
37                  my $name = shift;                  my $name = shift;
38                  my $n = $cp->{$name};                  my $n = $cp->{$name};
39                  die "no column $name in ",dump( $cp ) unless defined $n;                  die "no column $name in ",dump( $cp ) unless defined $n;
# Line 61  sub count { Line 52  sub count {
52                  my $s = c('VSZ');                  my $s = c('VSZ');
53                  if ( $s < $too_small ) {                  if ( $s < $too_small ) {
54                          $vsz->{$t}->{$veid}+= $s * 1024;                          $vsz->{$t}->{$veid}+= $s * 1024;
55                            print STDERR ".";
56                  } else {                  } else {
57                          my $cmd = c('COMMAND');                          my $cmd = c('COMMAND');
58                          $cmd =~ s{-.+$}{};                          $cmd =~ s{-.+$}{};
# Line 71  sub count { Line 63  sub count {
63                          $veid .= '-' . $cmd;                          $veid .= '-' . $cmd;
64                          $veid = substr($veid,0,16);                          $veid = substr($veid,0,16);
65                          $vsz->{$t}->{$veid}+= $s * 1024;                          $vsz->{$t}->{$veid}+= $s * 1024;
66                            print STDERR substr($cmd,0,1);
67                  }                  }
68                  $veids->{$veid}++;                  $veids->{$veid}++;
69          }          }

Legend:
Removed from v.6  
changed lines
  Added in v.10

  ViewVC Help
Powered by ViewVC 1.1.26