7 sub XXX { warn Data::Dump::dump( @_ ) };
9 my $measurement = 'debug';
14 my ($hour,$min,$sec)=(0,0,0);
18 #warn "# time $yyyy-$mm-$dd $hour:$min:$sec $time\n";
19 $time = timelocal($sec,$min,$hour,$dd,$mm-1,$yyyy) * 1000_000_000;
31 if ( /^(\w+)\s+(\d+\S+)\s+(.+)\s+(\w+)\s+(\d\d\d\d)\/(\d\d)\/(\d\d)$/ ) {
33 @cols = qw( kernel build arch );
34 @vals = ( qq{"$2"}, qq{"$3"}, qq{"$4"} ); # must quote all this as strings for influx
35 ( $yyyy, $mm, $dd ) = ( $5, $6, $7 ); update_time;
37 } elsif ( m/analysis date: (\S+)/ ) {
38 ( $yyyy, $mm, $dd ) = split(/\//, $1, 3); update_time;
41 } elsif ( m/^\d\d:\d\d:\d\d\s+(.+)_(\w+)_/ ) {
44 $cols =~ s/(in|out):\s+(\w+)/$1_$2/g; # ipv4, ipv6
45 @cols = split(/\s+/, $cols);
48 } elsif ( m/^(\d\d:\d\d:\d\d)\s+(.+)/ ) {
49 next if m/logging restarted/;
50 ( $hour, $min, $sec ) = split(/:/, $1, 3); update_time;
51 @vals = split(/\s+/, $2);
52 } elsif ( m/^\s+(.+)/ ) {
53 @vals = split(/\s+/, $1);
60 next if $measurement =~ /top3/; # FIXME this isn't parsed yet
62 #XXX { cols => \@cols, vals => \@vals };
63 print "atop_$measurement,host=$host";
65 foreach my $i ( 0 .. $#cols ) {
66 if ( my $c = $cols[$i] ) {
69 if ( $c =~ m/(cpu|disk|interf)/ ) { ; # XXX tag
79 warn "WARN line: [$_]\nno vals[$i] in ",Data::Dump::dump( @vals );
83 #$v *= 1024 * 1024 if $v =~ s/M$//;
87 $v =~ s/\s/\\ /g unless $v =~ m/"/;
89 next if $c eq "busy" && $v eq "?";
91 # $s = 'i' if $v =~ m/^\d+$/;
96 $d = '' if $s eq " "; # move to values
97 $d = ',' if $d eq " "; # move to values
101 die "line: [$_]\nno cols[$i] in ",Data::Dump::dump( @cols );