specify DB using enviroment variable
[atop-influxdb] / import-host.sh
1 #!/bin/sh
2
3 host=$1
4 tags=$2
5 db=$3
6 test -z "$host" && echo "usage: $0 host" && exit 1
7
8 test -z "$db" && db=$DB
9 test -z "$db" && db=atop
10
11 :> /dev/shm/atop-import-$host.sh
12 #ssh mjesec.ffzg.hr 'ls -t /var/log/atop/atop_*' | tee /dev/shm/atop.$host.logs | while read log
13 ssh $host 'ls -t /var/log/atop/atop_* || ls -t /var/log/atop.log*' | tee /dev/shm/atop.$host.logs
14 cat /dev/shm/atop.$host.logs | while read log 
15 do
16         echo "# $host:$log";
17         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=$db --data-binary '@-' >> /dev/shm/atop-import-$host.sh
18 done
19 sh -x /dev/shm/atop-import-$host.sh