/[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 10 by dpavlin, Fri Jul 17 12:37:29 2009 UTC revision 11 by dpavlin, Fri Jul 17 13:25:34 2009 UTC
# Line 6  use strict; Line 6  use strict;
6  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
7  use RRD::Simple;  use RRD::Simple;
8  use POSIX qw/mktime/;  use POSIX qw/mktime/;
9    use Getopt::Long;
10    
11  my $debug = 0;  my $debug = 0;
12  my $zoom = 2;  my $zoom = 2;
13    
14    my $only_veid;
15    my $too_small = 64;     # M
16    
17    GetOptions(
18            'debug!'   => \$debug,
19            'zoom=i'   => \$zoom,
20            'veid=i'   => \$only_veid,
21            'size=i'   => \$too_small,
22    );
23    
24    
25  my $veids;  my $veids;
26  my $vsz;  my $vsz;
27    
 my $too_small = 16;     # M  
28  $too_small *= 1024; # k  $too_small *= 1024; # k
29    
30  sub count {  sub count {
# Line 47  sub count { Line 58  sub count {
58                  @r = split(/\s+/, $_, $#c + 1 );                  @r = split(/\s+/, $_, $#c + 1 );
59    
60                  my $veid = c('VEID');                  my $veid = c('VEID');
61                  $veid =~ s/^0$/hw/;                  next if defined $only_veid && $only_veid != $veid;
62                    $veid =~ s/^0$/0-hw/;
63    
64                  my $s = c('VSZ');                  my $s = c('VSZ');
65                  if ( $s < $too_small ) {                  if ( $s < $too_small ) {
# Line 70  sub count { Line 82  sub count {
82    
83  }  }
84    
85  print STDERR "reading ps dumps";  print STDERR "parsing ps with grouping < $too_small k";
86    
87  count $_ foreach @ARGV;  count $_ foreach @ARGV;
88    
89  #print "VSZ: ",dump( $vsz );  #print "VSZ: ",dump( $vsz );
90    
91  my @veids = keys %$veids;  my @veids = sort keys %$veids;
92  warn "# veids = ",dump( sort @veids );  warn "# veids = ",dump( @veids );
93    
94  my $rrd_file = 'ps.rrd';  my $rrd_file = 'ps.rrd';
95  unlink $rrd_file if -e $rrd_file;  unlink $rrd_file if -e $rrd_file;
96    
97    my @t = sort keys %$vsz;
98    
99    print "\ndrawing $#t intervals ", $t[0], " - ", $t[$#t];
100    
101  my $rrd = RRD::Simple->new( file => $rrd_file );  my $rrd = RRD::Simple->new( file => $rrd_file );
102  $rrd->create( 'hour', map { ( $_ => 'GAUGE' ) } @veids );  $rrd->create( 'hour', map { ( $_ => 'GAUGE' ) } @veids );
103    
104  foreach my $t ( sort keys %$vsz ) {  foreach my $t ( @t ) {
105          print STDERR ".";          print STDERR ".";
106  #       warn "## ",dump( %{ $vsz->{$t} } );  #       warn "## ",dump( %{ $vsz->{$t} } );
107    

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

  ViewVC Help
Powered by ViewVC 1.1.26