From 34cfe3d86fad10ec3e5f73a2c7a50425a0e1cd41 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sat, 10 Dec 2016 15:26:40 +0100 Subject: [PATCH] added TAGS=dc=ffzg --- atop2influx.pl | 5 ++++- import-host.sh | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/atop2influx.pl b/atop2influx.pl index d56c4da..1bb781b 100755 --- a/atop2influx.pl +++ b/atop2influx.pl @@ -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] ) { diff --git a/import-host.sh b/import-host.sh index 12ef387..590469d 100755 --- a/import-host.sh +++ b/import-host.sh @@ -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 -- 2.20.1