From 6951e8b02b92c7ded608ea5717967ea7f39aa7c9 Mon Sep 17 00:00:00 2001 From: John Slivka Date: Fri, 10 Nov 2023 13:27:33 -0600 Subject: [PATCH] add insights_collect script (#835) --- scripts/insights_collect.sh | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 scripts/insights_collect.sh diff --git a/scripts/insights_collect.sh b/scripts/insights_collect.sh new file mode 100755 index 000000000..7b16ea682 --- /dev/null +++ b/scripts/insights_collect.sh @@ -0,0 +1,43 @@ +#! /bin/bash +# file: insights_collect.sh +# this is a simple bash script that collects job and pod data in the insights-agent namespace, +# to assist customers with debugging of insights +set -e +# redirect output to a file for uploading later +exec >> insights_collect_$(date +%s).log +exec 2>&1 +NAMESPACE=insights-agent +trap 'echo "Error on Line: $LINENO"' ERR + +echo "Collecting insights diagnostic information in namespace ${NAMESPACE}" + +kubectl -n ${NAMESPACE} get pods +kubectl -n ${NAMESPACE} get jobs + +pods=$(kubectl -n ${NAMESPACE} get pods | tail -n +2 | awk '{print $1}') +jobs=$(kubectl -n ${NAMESPACE} get jobs | tail -n +2 | awk '{print $1}') + +echo "found ${#pods[@]} pods in ${NAMESPACE}" +echo "found ${#jobs[@]} jobs in ${NAMESPACE}" + +for pod_name in $pods; do + echo + echo "========================" + echo "pod_name=${pod_name}" + echo "========================" + echo + kubectl -n ${NAMESPACE} describe pod ${pod_name} + echo + kubectl -n ${NAMESPACE} logs -f ${pod_name} --all-containers=true +done + +for job_name in $jobs; do + echo + echo "========================" + echo "job_name=${job_name}" + echo "========================" + echo + kubectl -n ${NAMESPACE} describe job ${job_name} + echo +done +