BMC Helix IT Operations Management (ITOM) – How to Check and Collect Pod or Service Logs in On-Prem Deployment (Manual Method and Script Included) – INCLUDES VIDEO |
Use the collect-diagnostic-logs.sh script (Attached to this Knowledge Article) to automatically gather diagnostic information from the cluster and package it into a support bundle. The script:
The script must be executed from a system that has kubectl or oc CLI installed and configured to access the Kubernetes/OpenShift cluster Script Namecollect-diagnostic-logs.sh
Steps to Run the Script
chmod +x collect-diagnostic-logs.sh
./collect-diagnostic-logs.sh User Inputs RequiredDuring execution, the script prompts for the following inputs: ITSM Namespace (Optional)Enter the ITSM namespace, or type No in case there is no ITSM OnPrem deployed:
ITOM Namespace (Mandatory)Enter ITOM namespace (Required):
Example: Enter ITSM namespace, or type No in case there is no ITSM OnPrem deployed: No Enter ITOM namespace (Required): itomwmk What the Script CollectsThe script collects diagnostic information from several areas of the cluster. 1. Cluster InformationThe script gathers cluster-level information to verify the overall health of the cluster. Collected data includes:
Commands executed: kubectl version
kubectl cluster-info This helps identify:
2. Namespace Resource InformationThe script collects workload and configuration details from the ITSM and ITOM namespaces. Collected resources include:
Commands executed: kubectl get pods
kubectl get deployments This helps verify:
3. Pod Resource UtilizationThe script collects real-time CPU and memory usage for pods. Commands executed: kubectl top pods
oc adm top pods This helps identify:
4. High Resource Utilization DetectionThe script identifies pods where:
Logic used:
For such pods, the script collects: kubectl describe pod This helps identify:
5. Detection of Pods in Problematic StatesThe script detects pods that are not running correctly by inspecting container state reasons (not just STATUS column). Detected states include: ImagePullBackOff
ErrImagePull Commands used: kubectl get pod -o jsonpath
kubectl describe pod This ensures accurate detection even when STATUS column is misleading. 6. Diagnostics Collected for Problematic PodsFor each problematic pod, the script collects:
Commands executed: kubectl describe pod <pod>
kubectl get pod <pod> -o yaml This helps diagnose:
7. Restarted Container Diagnostics (Last 2 Days)The script detects containers that restarted within the last 2 days. Collected data:
Commands executed: kubectl describe pod
kubectl logs This helps identify:
8. PostgreSQL Health ChecksIf PostgreSQL is present, the script collects diagnostics from:
Collected data includes:
Commands executed: kubectl exec <pod> -- df -h
kubectl exec <pod> -- patronictl list This helps identify:
9. PostgreSQL Leader DetectionThe script identifies the primary node using: role=primary
This ensures correct execution of database checks. 10. PostgreSQL Replication Slot VerificationFrom the leader pod: select * from pg_replication_slots;
This helps identify:
11. Support Bundle CreationAfter execution, the script generates a compressed bundle: k8s_support_bundle_<timestamp>.zip
Example: k8s_support_bundle_20260408_213804.zip
The bundle contains:
SummaryThe collect-diagnostic-logs.sh script automates the collection of diagnostic data from Kubernetes/OpenShift environments used in BMC Helix ITSM and ITOM deployments. It helps troubleshoot issues related to:
The generated ZIP file can be shared with support teams for faster analysis and resolution. Manual Steps (If Script Cannot Be Used)If the collect-diagnostic-logs.sh script cannot be executed in the environment, the required logs can be collected manually using the following commands. |