Skip to content

Commit ada7984

Browse files
committed
fix: set namespace as cmd line param
1 parent 658ae18 commit ada7984

File tree

1 file changed

+28
-20
lines changed

1 file changed

+28
-20
lines changed

docs/self-managed/operational-guides/troubleshooting/diagnostics.md

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,45 @@ The script outputs the following data from your namespace and creates a :
2323
### Usage
2424

2525
1. Save the script below as e.g. `camunda-collect-diagnostics.sh`.
26-
2. Replace `<NAMESPACE>` with the namespace of your Camunda deployment.
27-
3. Make the script executable.
26+
2. Make the script executable:
2827

2928
```bash
3029
chmod +x camunda-collect-diagnostics.sh
3130
```
3231

33-
4. Run the script.
32+
3. Execute the script replacing <namespace> with the namespace of your Camunda deployment:
3433

3534
```bash
36-
./camunda-collect-diagnostics.sh
35+
./camunda-collect-diagnostics.sh --namespace <namespace>
3736
```
3837

39-
5. Share the generated `.zip` archive with Camunda Support.
38+
4. Share the generated `.zip` archive with Camunda Support.
4039

4140
### Diagnostic collection script
4241

4342
```bash
4443
#!/bin/bash
4544

46-
# Define namespace
47-
namespace=<NAMESPACE>
45+
# Parse arguments
46+
while [[ "$#" -gt 0 ]]; do
47+
case $1 in
48+
--namespace) namespace="$2"; shift ;;
49+
*) echo "Unknown parameter passed: $1"; exit 1 ;;
50+
esac
51+
shift
52+
done
4853

49-
# Check if NAMESPACE is set
50-
if [[ "$namespace" == "NAMESPACE" ]]; then
51-
echo "ERROR: Please set the 'namespace' variable in the script before running it."
54+
# Check if namespace is provided
55+
if [[ -z "$namespace" ]]; then
56+
echo "ERROR: Namespace not provided. Please run the script with the --namespace parameter."
5257
echo "Example:"
53-
echo " namespace=\"camunda-platform\""
58+
echo " ./camunda-collect-diagnostics.sh --namespace camunda-platform"
59+
exit 1
60+
fi
61+
62+
# Check if namespace exists
63+
if ! kubectl get namespace "$namespace" > /dev/null 2>&1; then
64+
echo "ERROR: Namespace '$namespace' does not exist in the cluster."
5465
exit 1
5566
fi
5667

@@ -82,6 +93,12 @@ kubectl get events -n "$namespace" --sort-by='.lastTimestamp' > events.txt
8293
echo " - Collecting Persistent Volume Claims (PVCs) descriptions (storage claims in the namespace)."
8394
kubectl describe pvc -n "$namespace" > pvc-describe.txt
8495

96+
echo " - Collecting Persistent Volumes (PVs) descriptions (underlying storage volumes)."
97+
for pvc in $(kubectl get pvc -n "$namespace" --no-headers -o custom-columns=":spec.volumeName"); do
98+
echo " - Collecting information for PV: $pvc"
99+
kubectl describe pv "$pvc" >> pv-describe.txt
100+
done
101+
85102
echo " - Collecting service information (list of services in the namespace)."
86103
kubectl get svc -n "$namespace" > services.txt
87104

@@ -100,22 +117,13 @@ kubectl describe ing -n "$namespace" > ingresses-describe.txt
100117
echo " - Collecting config map information (configuration data stored in the namespace)."
101118
kubectl get cm -n "$namespace" -o yaml > configmaps.yaml
102119

103-
# Collect Persistent Volumes (PVs) relevant to the namespace
104-
echo " - Collecting Persistent Volumes (PVs):"
105-
for pvc in $(kubectl get pvc -n "$namespace" --no-headers -o custom-columns=":spec.volumeName"); do
106-
echo " - Collecting information for PV: $pvc"
107-
kubectl describe pv "$pvc" >> pv-describe.txt
108-
done
109-
110-
# Get nodes relevant to the namespace
111120
echo " - Collecting node information:"
112121
for node in $(kubectl get pods -n "$namespace" -o wide --no-headers | awk '{print $7}' | sort | uniq); do
113122
echo " - Collecting information for node: $node"
114123
kubectl describe node "$node" >> node-describe.txt
115124
echo "" >> node-describe.txt
116125
done
117126

118-
# Collect logs and descriptions for each pod
119127
echo " - Collecting logs and descriptions for each pod..."
120128
for pod in $(kubectl get pod -n "$namespace" --no-headers -o custom-columns=":metadata.name"); do
121129
echo " - Collecting logs for pod: $pod"

0 commit comments

Comments
 (0)