You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-Resolved issue where script wasn't recognizing daemonset and replicaset pods, thus skipping log collection.
-Added some additional logging lines to provide visibility of where logs are copied from.
-Added section to other_logCollection to collect both container-azm-ms-aks-k8scluster as well as ama-logs-rs-config configmap.
Copy file name to clipboardExpand all lines: scripts/troubleshoot/LogCollection/AgentLogCollection.sh
+56-27Lines changed: 56 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -1,36 +1,35 @@
1
1
#!/bin/bash
2
-
#
3
-
# Copyright (c) Microsoft Corporation.
4
-
#
5
-
# This script will collect all logs from the replicaset agent pod and a random daemonset pod, also collect onboard logs with processes
6
-
#
7
-
# Author Nina Li
2
+
#Copyright (c) Microsoft Corporation.
3
+
# Description: This script will collect all logs from the Replicaset Agent Pod and Daemonset Agent Pod.
4
+
# Also collects onboarding logs with processes.
5
+
# Original Author: Nina Li
6
+
# Modified By: Brandon DeGolier
8
7
9
8
Red='\033[0;31m'
10
9
Cyan='\033[0;36m'
11
-
NC='\033[0m'# No Color
10
+
NC='\033[0m'
12
11
13
12
init()
14
13
{
15
14
echo -e "Preparing for log collection..."| tee -a Tool.log
16
15
17
16
if! cmd="$(type -p kubectl)"|| [[ -z$cmd ]];then
18
-
echo -e "${Red}Command kubectl not found, please install it firstly, exit...${NC}"
17
+
echo -e "${Red}Command kubectl not found, please install to continue, exiting...${NC}"
19
18
cd ..
20
19
rm -rf $output_path
21
20
exit
22
21
fi
23
22
24
23
if! cmd="$(type -p tar)"|| [[ -z$cmd ]];then
25
-
echo -e "${Red}Command tar not found, please install it firstly, exit...${NC}"
24
+
echo -e "${Red}Command tar not found, please install to continue, exiting...${NC}"
26
25
cd ..
27
26
rm -rf $output_path
28
27
exit
29
28
fi
30
29
31
30
cmd=`kubectl get nodes 2>&1`
32
31
if [[ $cmd==*"refused"* ]];then
33
-
echo -e "${Red}Fail to connect your AKS, please fisrlty connect to cluster by command: az aks get-credentials --resource-group myResourceGroup --name myAKSCluster${NC}"
32
+
echo -e "${Red}Failed to connect your AKS, please connect to your cluster by command: az aks get-credentials --resource-group myResourceGroup --name myAKSCluster, exiting...${NC}"
34
33
cd ..
35
34
rm -rf $output_path
36
35
exit
@@ -41,19 +40,19 @@ init()
41
40
do
42
41
if [ `echo $node| tr -s '[:upper:]''[:lower:]'`!="ready" ];then
43
42
kubectl get nodes
44
-
echo -e "${Red}One or more AKS node is not ready, please start this node firstly for log collection, exit...${NC}"
43
+
echo -e "${Red}One or more AKS node is not ready, please start this node for log collection, exiting...${NC}"
45
44
cd ..
46
45
rm -rf $output_path
47
46
exit
48
47
fi
49
48
done
50
-
echo -e "Prerequistes check is done, all good"| tee -a Tool.log
49
+
echo -e "Prerequisites check complete!"| tee -a Tool.log
51
50
52
-
echo -e "Saving cluster information"| tee -a Tool.log
51
+
echo -e "Saving cluster information..."| tee -a Tool.log
53
52
54
53
cmd=`kubectl cluster-info 2>&1`
55
54
if [[ $cmd==*"refused"* ]];then
56
-
echo -e "${Red}Fail to get cluster info, please check your AKS status fistly, exit...${NC}"
55
+
echo -e "${Red}Failed to get cluster info, please check your AKS status, exiting...${NC}"
57
56
cd ..
58
57
rm -rf $output_path
59
58
exit
@@ -76,6 +75,10 @@ ds_logCollection()
76
75
if [[ $cmd==*"cannot access"* ]];then
77
76
echo -e "${Red}/var/opt/microsoft not exist on ${ds_pod}${NC}"| tee -a Tool.log
78
77
else
78
+
echo -e "Collecting the following logs from ${ds_pod}:"
export deploy=$(kubectl get deployment --namespace=kube-system | grep -E ama-logs | head -n 1 | awk '{print $1}')
174
193
if [ -z"$deploy" ];then
175
-
echo -e "${Red}there is not ama-logs deployment, skipping log collection of deployment${NC}"| tee -a Tool.log
194
+
echo -e "${Red}There is no ama-logs deployment present, skipping log collection of deployment${NC}"| tee -a Tool.log
176
195
else
196
+
echo -e "Collecting deployment info..."
177
197
kubectl get deployment $deploy --namespace=kube-system -o yaml > deployment_${deploy}.txt
178
198
fi
179
199
180
-
export config=$(kubectl get configmaps --namespace=kube-system | grep -E container-azm-ms-agentconfig| head -n 1 | awk '{print $1}')
200
+
export config=$(kubectl get configmaps --namespace=kube-system | grep -E container-azm-ms-aks-k8scluster| head -n 1 | awk '{print $1}')
181
201
if [ -z"$config" ];then
182
-
echo -e "${Red}configMap named container-azm-ms-agentconfig is not found, if you created configMap for ama-logs, please manually save your custom configMap of ama-logs by command: kubectl get configmaps <configMap name> --namespace=kube-system -o yaml > configMap.yaml${NC}"| tee -a Tool.log
202
+
echo -e "${Red}configMap named container-azm-ms-aks-k8scluster is not found, if you created configMap for ama-logs, please manually save your custom configMap of ama-logs by command: kubectl get configmaps <configMap name> --namespace=kube-system -o yaml > configMap.yaml${NC}"| tee -a Tool.log
kubectl get configmaps $config --namespace=kube-system -o yaml >${config}.yaml
185
206
fi
186
207
208
+
export config2=$(kubectl get configmaps --namespace=kube-system | grep -E ama-logs-rs-config | head -n 1 | awk '{print $1}')
209
+
if [ -z"$config2" ];then
210
+
echo -e "${Red}configMap named ama-logs-rs-config is not found, if you created configMap for ama-logs, please manually save your custom configMap of ama-logs by command: kubectl get configmaps <configMap name> --namespace=kube-system -o yaml > configMap.yaml${NC}"| tee -a Tool.log
0 commit comments