Skip to content

Commit

Permalink
Collect Diagnostic Data on Default (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReggieRichardson committed Mar 19, 2024
1 parent efded5f commit ed0bdbb
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions generate_postmortem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,30 +98,30 @@ for switch in $@; do
echo -e ""
echo -e "Available switches:"
echo -e ""
echo -e "--specific-namespaces: Target only the listed namespaces for the data collection. Example: --specific-namespaces=dev1,dev2,dev3"
echo -e "--extra-namespaces: Extra namespaces separated with commas. Example: --extra-namespaces=dev1,dev2,dev3"
echo -e "--log-limit: Set the number of lines to collect from each pod logs."
echo -e "--no-prompt: Do not prompt to report auto-detected namespaces."
echo -e "--performance-check: Set to run performance checks."
echo -e "--no-history: Do not collect user history."
echo -e "--specific-namespaces: Target only the listed namespaces for the data collection. Example: --specific-namespaces=dev1,dev2,dev3"
echo -e "--extra-namespaces: Extra namespaces separated with commas. Example: --extra-namespaces=dev1,dev2,dev3"
echo -e "--log-limit: Set the number of lines to collect from each pod logs."
echo -e "--no-prompt: Do not prompt to report auto-detected namespaces."
echo -e "--performance-check: Set to run performance checks."
echo -e "--no-history: Do not collect user history."
echo -e ""
echo -e "--ova: Only set if running inside an OVA deployment."
echo -e "--pull-appliance-logs: Call [apic logs] command then package into archive file."
echo -e "--ova: Only set if running inside an OVA deployment."
echo -e "--pull-appliance-logs: Call [apic logs] command then package into archive file."
echo -e ""
echo -e "--collect-private-keys: Include "tls.key" members in TLS secrets from targeted namespaces. Due to sensitivity of data, do not use unless requested by support."
echo -e "--collect-crunchy: Collect Crunchy mustgather."
echo -e "--collect-edb: Collect EDB mustgather."
echo -e "--collect-private-keys: Include "tls.key" members in TLS secrets from targeted namespaces. Due to sensitivity of data, do not use unless requested by support."
echo -e "--collect-crunchy: Collect Crunchy mustgather."
echo -e "--collect-edb: Collect EDB mustgather."
echo -e ""
echo -e "--diagnostic-all: Set to enable all diagnostic data."
echo -e "--diagnostic-manager: Set to include additional manager specific data."
echo -e "--diagnostic-gateway: Set to include additional gateway specific data."
echo -e "--diagnostic-portal: Set to include additional portal specific data."
echo -e "--diagnostic-analytics: Set to include additional analytics specific data."
echo -e "--no-diagnostic: Set to disable all diagnostic data."
echo -e "--no-manager-diagnostic: Set to disable additional manager specific data."
echo -e "--no-gateway-diagnostic: Set to disable additional gateway specific data."
echo -e "--no-portal-diagnostic: Set to disable additional portal specific data."
echo -e "--no-analytics-diagnostic: Set to disable additional analytics specific data."
echo -e ""
echo -e "--debug: Set to enable verbose logging."
echo -e "--no-script-check: Set to disable checking if the postmortem scripts are up to date."
echo -e "--debug: Set to enable verbose logging."
echo -e "--no-script-check: Set to disable checking if the postmortem scripts are up to date."
echo -e ""
echo -e "--version: Show postmortem version"
echo -e "--version: Show postmortem version"
exit 0
;;
*"--debug"*)
Expand All @@ -138,23 +138,23 @@ for switch in $@; do
NO_PROMPT=1
NAMESPACE_LIST="kube-system"
;;
*"--diagnostic-all"*)
DIAG_MANAGER=1
DIAG_GATEWAY=1
DIAG_PORTAL=1
DIAG_ANALYTICS=1
*"--no-diagnostic"*)
NOT_DIAG_MANAGER=1
NOT_DIAG_GATEWAY=1
NOT_DIAG_PORTAL=1
NOT_DIAG_ANALYTICS=1
;;
*"--diagnostic-manager"*)
DIAG_MANAGER=1
*"--no-manager-diagnostic"*)
NOT_DIAG_MANAGER=1
;;
*"--diagnostic-gateway"*)
DIAG_GATEWAY=1
*"--no-gateway-diagnostic"*)
NOT_DIAG_GATEWAY=1
;;
*"--diagnostic-portal"*)
DIAG_PORTAL=1
*"--no-portal-diagnostic"*)
NOT_DIAG_PORTAL=1
;;
*"--diagnostic-analytics"*)
DIAG_ANALYTICS=1
*"--no-analytics-diagnostic"*)
NOT_DIAG_ANALYTICS=1
;;
*"--log-limit"*)
limit=`echo "${switch}" | cut -d'=' -f2`
Expand Down Expand Up @@ -257,7 +257,7 @@ if [[ $? -ne 0 ]]; then
fi
fi

if [[ $DIAG_MANAGER -eq 1 ]]; then
if [[ $NOT_DIAG_MANAGER -eq 0 ]]; then
EDB_CLUSTER_NAME=$($KUBECTL get cluster --all-namespaces -o=jsonpath='{.items[0].metadata.name}' 2>/dev/null)
if [[ -z "$EDB_CLUSTER_NAME" ]]; then
COLLECT_CRUNCHY=1
Expand Down Expand Up @@ -1418,7 +1418,7 @@ for NAMESPACE in $NAMESPACE_LIST; do
fi

#grab postgres data
if [[ $DIAG_MANAGER -eq 1 && $COLLECT_CRUNCHY -eq 1 && "$status" == "Running" && "$pod" == *"postgres"* && ! "$pod" =~ (backrest|pgbouncer|stanza|operator|backup) ]]; then
if [[ $NOT_DIAG_MANAGER -eq 0 && $COLLECT_CRUNCHY -eq 1 && "$status" == "Running" && "$pod" == *"postgres"* && ! "$pod" =~ (backrest|pgbouncer|stanza|operator|backup) ]]; then
echo "Collecting manager diagnostic data..."
target_dir="${K8S_NAMESPACES_POD_DIAGNOSTIC_DATA}/postgres/${pod}-pglogs"
health_dir="${K8S_NAMESPACES_POD_DIAGNOSTIC_DATA}/postgres/${pod}-health-stats"
Expand Down Expand Up @@ -1504,7 +1504,7 @@ for NAMESPACE in $NAMESPACE_LIST; do
fi

PG_BACKREST_REPO_POD=$($KUBECTL -n "$NAMESPACE" get po -lpgo-backrest-repo=true,vendor=crunchydata -o=custom-columns=NAME:.metadata.name --no-headers)
if [[ $DIAG_MANAGER -eq 1 && $COLLECT_CRUNCHY -eq 1 && "$status" == "Running" && "$pod" == "$PG_BACKREST_REPO_POD" ]]; then
if [[ $NOT_DIAG_MANAGER -eq 0 && $COLLECT_CRUNCHY -eq 1 && "$status" == "Running" && "$pod" == "$PG_BACKREST_REPO_POD" ]]; then
target_dir="${K8S_NAMESPACES_POD_DIAGNOSTIC_DATA}/postgres/${pod}"
mkdir -p "$target_dir"

Expand All @@ -1531,7 +1531,7 @@ for NAMESPACE in $NAMESPACE_LIST; do
fi

#grab gateway diagnostic data
if [[ $DIAG_GATEWAY -eq 1 && $IS_GATEWAY -eq 1 && $ready -eq 1 && "$status" == "Running" && "$pod" != *"monitor"* && "$pod" != *"operator"* ]]; then
if [[ $NOT_DIAG_GATEWAY -eq 0 && $IS_GATEWAY -eq 1 && $ready -eq 1 && "$status" == "Running" && "$pod" != *"monitor"* && "$pod" != *"operator"* ]]; then
echo "Collecting gateway diagnostic data..."
GATEWAY_DIAGNOSTIC_DATA="${K8S_NAMESPACES_POD_DIAGNOSTIC_DATA}/gateway/${pod}"
mkdir -p $GATEWAY_DIAGNOSTIC_DATA
Expand Down Expand Up @@ -1616,7 +1616,7 @@ for NAMESPACE in $NAMESPACE_LIST; do
fi

#grab analytics diagnostic data
if [[ $DIAG_ANALYTICS -eq 1 && $IS_ANALYTICS -eq 1 && $ready -eq 1 && "$status" == "Running" ]]; then
if [[ $NOT_DIAG_ANALYTICS -eq 0 && $IS_ANALYTICS -eq 1 && $ready -eq 1 && "$status" == "Running" ]]; then
echo "Collecting analytics diagnostic data..."
ANALYTICS_DIAGNOSTIC_DATA="${K8S_NAMESPACES_POD_DIAGNOSTIC_DATA}/analytics/${pod}"
mkdir -p $ANALYTICS_DIAGNOSTIC_DATA
Expand Down Expand Up @@ -1653,7 +1653,7 @@ for NAMESPACE in $NAMESPACE_LIST; do
[[ $? -eq 0 && -s "${LOG_TARGET_PATH}/${pod}_${container}_previous.log" ]] || rm -f "${LOG_TARGET_PATH}/${pod}_${container}_previous.log"

#grab portal data
if [[ $DIAG_PORTAL -eq 1 && $IS_PORTAL -eq 1 && "$status" == "Running" ]]; then
if [[ $NOT_DIAG_PORTAL -eq 0 && $IS_PORTAL -eq 1 && "$status" == "Running" ]]; then
echo "Collecting portal diagnostic data..."
PORTAL_DIAGNOSTIC_DATA="${K8S_NAMESPACES_POD_DIAGNOSTIC_DATA}/portal/${pod}/${container}"

Expand Down

0 comments on commit ed0bdbb

Please sign in to comment.