blob: 37d0755a3391b54994cd7c452edb16625ad98ff0 [file] [log] [blame]
Sergio Slobodrianee417fa2017-08-11 09:34:50 -04001#!/bin/bash
2
3# This script will collect all of the pertinent logs from a voltha
4# HA swarm cluster, tar, and bizip them to facilitate sending them
5# to the suspected issue owner.
6
7volthaDir="/cord/incubator/voltha"
8
9# Get the list of the other hosts that make up the cluster
10hosts=`docker node ls | tail -n +2 | awk '{print $2}' | grep -v "*"`
11
12# Create a temporary directory for temporary storage of all the logs
13mkdir ${volthaDir}/log_tmp
14pushd ${volthaDir}/log_tmp
15
16# Docker health in general.
17
18echo "Getting docker node ls"
19docker node ls > docker_node_ls.log 2>&1
20echo "Getting docker service ls"
21docker service ls > docker_service_ls.log 2>&1
22
23# Get the list of services to ps each one and get logs for each one.
24svcs=`docker service ls | tail -n +2 | awk '{print $2}'`
25
26# Get the PS information
27for i in $svcs
28do
29 echo "Getting docker service ps $i"
30 docker service ps ${i} > docker_service_ps_${i} 2>&1
31done
32
33# Get the logs for each service
34for i in $svcs
35do
36 echo "Getting docker service logs $i"
37 docker service logs ${i} > docker_service_logs_${i} 2>&1 &
38done
39
40patience=10
41while [ ! -z "`jobs -p`" ]
42do
43 echo "*** Waiting on log collection to complete. Outstanding jobs: `jobs -p | wc -l`"
44 sleep 10
45 patience=`expr $patience - 1`
46 if [ $patience -eq 0 ]; then
47 echo "Log collection stuck, killing any active collectors"
48 for i in `jobs -p`
49 do
50 kill -s TERM $i
51 done
52 break
53 fi
54done
55
56# Get the image list from this host
57echo "Getting docker image ls from `hostname`"
58docker image ls > docker_image_ls_`hostname` 2>&1
59for i in $hosts
60do
61 echo "Getting docker image ls from $i"
62 ssh voltha@$i "docker image ls" > docker_image_ls_$i 2>&1
63done
64
65
66popd
67tar cjvf logs.tar.bz2 log_tmp/*
68rm -fr log_tmp
69
70
71