forked from quobyte/quobyte-csi-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
log_collector.sh
executable file
·58 lines (48 loc) · 2.31 KB
/
log_collector.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
DRIVER_NAMESPACE="kube-system"
csi_pods=()
while IFS= read -r line; do
csi_pods+=( "$line" )
done < <(kubectl -n $DRIVER_NAMESPACE get po -owide | grep ^quobyte-csi | cut -f 1 -d' ')
if [[ ${#csi_pods[@]} == 0 ]]; then
echo "Quobyte CSI pods are not found under $DRIVER_NAMESPACE namespace."
exit 1
fi
if [ -d csi_logs ]; then
rm -rf csi_logs
fi
mkdir -p ./csi_logs
echo '###kubectl version info###' >> ./csi_logs/csi_pods.txt
kubectl version >> ./csi_logs/csi_pods.txt
echo '' >> ./csi_logs/csi_pods.txt
echo '###CSIDriver object status###' >> ./csi_logs/csi_pods.txt
kubectl get CSIDriver | grep ^csi.quobyte.com >> ./csi_logs/csi_pods.txt
echo '' >> ./csi_logs/csi_pods.txt
echo '###Quobyte CSI pods status###' >> ./csi_logs/csi_pods.txt
kubectl -n $DRIVER_NAMESPACE get po -owide | grep ^quobyte-csi >> ./csi_logs/csi_pods.txt
for el in "${csi_pods[@]}"
do
mkdir -p "./csi_logs/$el"
if [[ $el =~ quobyte-csi-controller.* ]]; then
kubectl -n $DRIVER_NAMESPACE logs $el -c csi-provisioner >> ./csi_logs/$el/csi-provisioner.log
kubectl -n $DRIVER_NAMESPACE logs $el -c csi-attacher >> ./csi_logs/$el/csi-attacher.log
kubectl -n $DRIVER_NAMESPACE logs $el -c csi-resizer >> ./csi_logs/$el/csi-resizer.log
kubectl -n $DRIVER_NAMESPACE logs $el -c quobyte-csi-driver >> ./csi_logs/$el/quobyte-csi-driver.log
kubectl -n $DRIVER_NAMESPACE logs $el -c csi-snapshotter >> ./csi_logs/$el/csi-snapshotter.log
elif [[ $el =~ quobyte-csi-node.* ]];then
kubectl -n $DRIVER_NAMESPACE logs $el -c csi-node-driver-registrar >> ./csi_logs/$el/csi-node-driver-registrar.log
kubectl -n $DRIVER_NAMESPACE logs $el -c quobyte-csi-driver >> ./csi_logs/$el/quobyte-csi-node-driver.log
kubectl -n $DRIVER_NAMESPACE logs $el -c quobyte-pod-killer >> ./csi_logs/$el/quobyte-pod-killer.log
fi
done
# when snapshots are enabled we should also get logs from snapshot-controller
kubectl -n kube-system get po | grep -q "snapshot-controller"
found_snapshot_controller="$?"
if [[ ${found_snapshot_controller} -eq 0 ]]; then
kubectl -n kube-system logs snapshot-controller-0 >> ./csi_logs/snapshot-controller.log
fi
# TODO(venkat): collect daemonset, statefulsets and deployment details as part of logs
if [[ -f quobyte_csi_logs.tar.gz ]]; then
rm quobyte_csi_logs.tar.gz
fi
tar -zcf quobyte_csi_logs.tar.gz ./csi_logs