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