blob: 9258b3471d2add78c30c6fea9f71bf05daf50af9 [file] [log] [blame]
Michael Lando451a3402017-02-19 10:28:42 +02001#!/bin/bash
2
3FILE='/data/logs/docker_stats.out'
4FE_ID=`docker ps|grep sdc-front|awk '{print $1}'`
5BE_ID=`docker ps|grep sdc-back |awk '{print $1}'`
6
7echo `date` >> ${FILE}
8
9if [ ! -z "${FE_ID}" ]; then
10 docker stats ${FE_ID} --no-stream >> /data/logs/docker_stats.out
11else
12 echo "frontend Docker is down!!!" >> /data/logs/docker_stats.out
13fi
14
15if [ ! -z "${BE_ID}" ]; then
16 docker stats ${BE_ID} --no-stream >> /data/logs/docker_stats.out
17else
18 echo "backend Docker is down!!!" >> /data/logs/docker_stats.out
19fi
20
21echo "------------------------------------------" >> ${FILE}
22
23grep -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}
33/GiB/ {
34 print $1" "d" "$3" "$8
35 next
36}' > `echo ${FILE}|awk -F"." '{ print $1".csv"}'`