Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | FILE='/data/logs/docker_stats.out' |
| 4 | FE_ID=`docker ps|grep sdc-front|awk '{print $1}'` |
| 5 | BE_ID=`docker ps|grep sdc-back |awk '{print $1}'` |
| 6 | |
| 7 | echo `date` >> ${FILE} |
| 8 | |
| 9 | if [ ! -z "${FE_ID}" ]; then |
| 10 | docker stats ${FE_ID} --no-stream >> /data/logs/docker_stats.out |
| 11 | else |
| 12 | echo "frontend Docker is down!!!" >> /data/logs/docker_stats.out |
| 13 | fi |
| 14 | |
| 15 | if [ ! -z "${BE_ID}" ]; then |
| 16 | docker stats ${BE_ID} --no-stream >> /data/logs/docker_stats.out |
| 17 | else |
| 18 | echo "backend Docker is down!!!" >> /data/logs/docker_stats.out |
| 19 | fi |
| 20 | |
| 21 | echo "------------------------------------------" >> ${FILE} |
| 22 | |
| 23 | grep -v "^\-" ${FILE} |grep -v ^CONT| awk 'BEGIN { |
| 24 | split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec",month) |
| 25 | for (i in month) { |
| 26 | month_nums[month[i]]=i |
| 27 | } |
| 28 | } |
| 29 | /UTC/ { |
| 30 | d=$6"-"$2"-"substr("00",0,2-length($3))$3"-"substr($4,0,5) |
| 31 | next |
| 32 | } |
Grinberg Moti | 3cac199 | 2017-02-23 16:23:14 +0200 | [diff] [blame] | 33 | /MiB/ { |
| 34 | print $1" "d" "$3/1024" "$8 |
| 35 | next |
| 36 | } |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 37 | /GiB/ { |
| 38 | print $1" "d" "$3" "$8 |
| 39 | next |
| 40 | }' > `echo ${FILE}|awk -F"." '{ print $1".csv"}'` |
ml636r | 0649e65 | 2017-02-20 21:10:54 +0200 | [diff] [blame] | 41 | |