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)}; |
18 |
|
|
19 |
GetOptions( |
GetOptions( |
20 |
'debug!' => \$debug, |
'debug!' => \$debug, |
21 |
'zoom=i' => \$zoom, |
'zoom=i' => \$zoom, |
22 |
'veid=i' => \$only_veid, |
'only-veid=i' => \$only_veid, |
23 |
|
'by-veid!' => \$by_veid, |
24 |
'size=i' => \$too_small, |
'size=i' => \$too_small, |
25 |
); |
); |
26 |
|
|
36 |
|
|
37 |
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)}; |
38 |
|
|
39 |
warn "# $file ", -s $file, " bytes [$t]\n" if $debug; |
# warn "# $file ", -s $file, " bytes [$t]\n" if $debug; |
40 |
|
print STDERR "\n$file\t"; |
41 |
|
|
42 |
my $cols = <$fh>; |
my $cols = <$fh>; |
43 |
$cols =~ s/^\s+//; |
$cols =~ s/^\s+//; |
63 |
|
|
64 |
my $veid = c('VEID'); |
my $veid = c('VEID'); |
65 |
next if defined $only_veid && $only_veid != $veid; |
next if defined $only_veid && $only_veid != $veid; |
66 |
$veid =~ s/^0$/0-hw/; |
$veid =~ s/^0$/_hw_0/; |
67 |
|
|
68 |
my $s = c('VSZ'); |
my $s = c('VSZ'); |
69 |
if ( $s < $too_small ) { |
my $cmd = c('COMMAND'); |
70 |
|
if ( ! $by_veid && $cmd =~ $filter ) { |
71 |
|
|
72 |
|
$veid .= '-' . $1; |
73 |
|
$vsz->{$t}->{$veid} += $s * 1024; |
74 |
|
print STDERR uc(substr($1,0,1)); |
75 |
|
|
76 |
|
} elsif ( $s < $too_small || $by_veid ) { |
77 |
|
|
78 |
$vsz->{$t}->{$veid}+= $s * 1024; |
$vsz->{$t}->{$veid}+= $s * 1024; |
79 |
print STDERR "."; |
print STDERR "."; |
80 |
|
|
81 |
} else { |
} else { |
82 |
my $cmd = c('COMMAND'); |
|
83 |
$cmd =~ s{-.+$}{}; |
$cmd =~ s{-.+$}{}; |
84 |
$cmd =~ s{^/\S+/(\w+?)}{$1}; |
$cmd =~ s{^/\S+/(\w+?)}{$1}; |
85 |
$cmd =~ s{^\w+ /\S+/(\w+?)}{$1}; |
$cmd =~ s{^\w+ /\S+/(\w+?)}{$1}; |
112 |
print "\ndrawing $#t intervals ", $t[0], " - ", $t[$#t]; |
print "\ndrawing $#t intervals ", $t[0], " - ", $t[$#t]; |
113 |
|
|
114 |
my $rrd = RRD::Simple->new( file => $rrd_file ); |
my $rrd = RRD::Simple->new( file => $rrd_file ); |
115 |
$rrd->create( 'hour', map { ( $_ => 'GAUGE' ) } @veids ); |
$rrd->create( map { ( $_ => 'GAUGE' ) } @veids ); |
116 |
|
|
117 |
foreach my $t ( @t ) { |
foreach my $t ( @t ) { |
118 |
print STDERR "."; |
print STDERR "."; |