added TAGS=dc=ffzg
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 10 Dec 2016 14:26:40 +0000 (15:26 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 10 Dec 2016 14:26:40 +0000 (15:26 +0100)
atop2influx.pl
import-host.sh

index d56c4da..1bb781b 100755 (executable)
@@ -20,6 +20,9 @@ sub update_time {
        return $time;
 }
 
+my $tags = $ENV{TAGS};
+$tags = ",$tags" unless $tags =~ m/^,/;
+
 while(<>) {
        chomp;
        next if /^$/;
@@ -60,7 +63,7 @@ while(<>) {
        next if $measurement =~ /top3/; # FIXME this isn't parsed yet
 
        #XXX { cols => \@cols, vals => \@vals };
-       print "atop_$measurement,host=$host";
+       print "atop_$measurement,host=$host$tags";
        my $d = " ";
        foreach my $i ( 0 .. $#cols ) {
                if ( my $c = $cols[$i] ) {
index 12ef387..590469d 100755 (executable)
@@ -1,6 +1,7 @@
 #!/bin/sh
 
 host=$1
+tags=$2
 test -z "$host" && echo "usage: $0 host" && exit 1
 
 :> /dev/shm/atop-import-$host.sh
@@ -9,6 +10,6 @@ ssh $host 'ls -t /var/log/atop/atop_* || ls -t /var/log/atop.log*' | tee /dev/sh
 cat /dev/shm/atop.$host.logs | while read log 
 do
        echo "# $host:$log";
-       echo ssh $host \"atopsar -A -r $log\" \| ./atop2influx.pl \| tee /dev/shm/atop.$host.influx \| curl -i -X POST http://localhost:8086/write?db=atop --data-binary '@-' >> /dev/shm/atop-import-$host.sh
+       echo ssh $host \"atopsar -A -r $log\" \| TAGS=$tags ./atop2influx.pl \| tee /dev/shm/atop.$host.influx \| curl -i -X POST http://localhost:8086/write?db=atop3 --data-binary '@-' >> /dev/shm/atop-import-$host.sh
 done
 sh -x /dev/shm/atop-import-$host.sh