Browse Source

add node get-node-logs script

Mangirdas 6 years ago
parent
commit
18bb4c63ff

+ 8 - 0
playbooks/azure/openshift-cluster/build_node_image.yml

@@ -64,6 +64,14 @@
   - name: deconfigure yum repositories
     import_tasks: tasks/remove_yum.yml
 
+  - name: add get-node-logs script
+    copy:
+      src: files/get-node-logs
+      dest: /usr/local/bin/get-node-logs
+      owner: root
+      group: root
+      mode: 0755
+
   - name: record installed rpms
     yum:
       list: installed

+ 46 - 0
playbooks/azure/openshift-cluster/files/get-node-logs

@@ -0,0 +1,46 @@
+#!/bin/bash
+set -x
+
+LOG_DIR=$(mktemp -d)
+
+trap "{ rm -rf $LOG_DIR }" EXIT
+
+SYSTEMD_SERVICES=("dnsmasq NetworkManager atomic-openshift-node origin-node")
+
+since_docker="24h"
+since_systemd="24 hour ago"
+
+# Dump systemd services logs
+for name in ${SYSTEMD_SERVICES} ; do
+  dump_file_path=${LOG_DIR}/${name}.log
+  journalctl -u ${name}.service --since "${since_systemd}" > $dump_file_path
+done
+
+# Dump command output
+ip a > ${LOG_DIR}/ip_a.log
+netstat -antu > ${LOG_DIR}/netstat_antu.log
+dmesg > ${LOG_DIR}/dmesg.log
+route -n > ${LOG_DIR}/route_n.log
+ss -ntpl > ${LOG_DIR}/ss_ntpl.log
+cat /etc/resolv.conf > ${LOG_DIR}/resolve_conf.log
+df -h > ${LOG_DIR}/df_h.log
+vmstat 2 20 > ${LOG_DIR}/vmstat_2_20.log
+mount > ${LOG_DIR}/mount.log
+
+for table in filter nat; do
+    iptables -t $table -nvL > ${LOG_DIR}/iptables_$table.log
+done
+
+# Dump system journal
+journalctl --since "${since_systemd}" > ${LOG_DIR}/journalctl.log
+
+# Dump sdn container logs
+uid=$(docker ps -l -a --filter "label=io.kubernetes.container.name=sdn" --format '{{ .Label "io.kubernetes.pod.uid" }}')
+if [[ ! -z "${uid}" ]]; then
+  container=$(docker ps -l -a -q --filter "label=io.kubernetes.pod.uid=${uid}" --filter "label=io.kubernetes.container.name=sdn")
+  docker logs --since ${since_docker} "${container}" >& ${LOG_DIR}/sdn.log
+fi
+
+prefix=osa_node_$(hostname)_$(date +%Y%m%d%H%M%S)
+tar -czPf $prefix.tar.gz  --xform="s|^$LOG_DIR|$prefix|" $LOG_DIR
+echo $prefix.tar.gz