X-Git-Url: http://git.rot13.org/?p=atop-influxdb;a=blobdiff_plain;f=atop2influx.pl;h=19f0768d14f0348b291bfdc839d7c65ebac68907;hp=1bb781b29c212e18f4d4d07ae4881740c32da8ea;hb=d9949e66bac16b867464cc015a6928e42696c039;hpb=34cfe3d86fad10ec3e5f73a2c7a50425a0e1cd41 diff --git a/atop2influx.pl b/atop2influx.pl index 1bb781b..19f0768 100755 --- a/atop2influx.pl +++ b/atop2influx.pl @@ -21,7 +21,7 @@ sub update_time { } my $tags = $ENV{TAGS}; -$tags = ",$tags" unless $tags =~ m/^,/; +$tags = ",$tags" if $tags && $tags !~ m/^,/; while(<>) { chomp; @@ -31,7 +31,7 @@ while(<>) { my @vals; - if ( /^(\w+)\s+(\d+\S+)\s+(.+)\s+(\w+)\s+(\d\d\d\d)\/(\d\d)\/(\d\d)$/ ) { + if ( /^([\w\-]+)\s+(\d+\S+)\s+(.+)\s+(\w+)\s+(\d\d\d\d)\/(\d\d)\/(\d\d)$/ ) { $host = $1; @cols = qw( kernel build arch ); @vals = ( qq{"$2"}, qq{"$3"}, qq{"$4"} ); # must quote all this as strings for influx @@ -55,7 +55,7 @@ while(<>) { } elsif ( m/^\s+(.+)/ ) { @vals = split(/\s+/, $1); } else { - die "UNPARSED: $_\n"; + warn "UNPARSED: $_\n"; } next unless @vals; @@ -63,7 +63,7 @@ while(<>) { next if $measurement =~ /top3/; # FIXME this isn't parsed yet #XXX { cols => \@cols, vals => \@vals }; - print "atop_$measurement,host=$host$tags"; + print "$measurement,host=$host$tags"; my $d = " "; foreach my $i ( 0 .. $#cols ) { if ( my $c = $cols[$i] ) {