Skip to content

Commit

Permalink
add insights_collect script (#835)
Browse files Browse the repository at this point in the history
  • Loading branch information
jslivka authored Nov 10, 2023
1 parent 95e377e commit 6951e8b
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions scripts/insights_collect.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6951e8b

Please sign in to comment.