-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-conference-app.sh
More file actions
42 lines (35 loc) · 1.23 KB
/
check-conference-app.sh
File metadata and controls
42 lines (35 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
namespace="antmedia"
service_name="ant-media-origin"
port=5080
kubeconfig_path="/etc/conf.d/kubeconfig"
# Get all pod names in the namespace that match the service name
pods=$(kubectl --kubeconfig="$kubeconfig_path" get pods -n "$namespace" -l "app=$service_name" -o jsonpath='{.items[*].metadata.name}')
# Initialize variables
critical_pods=()
all_ok=true
echo "Checking HTTP status for each pod..."
echo "----------------------------------------"
for pod in $pods; do
status=$(kubectl --kubeconfig="$kubeconfig_path" exec -n "$namespace" "$pod" -- curl -s -o /dev/null -w "%{http_code}" http://localhost:$port/Conference/rest/circle/version)
echo "Pod: $pod - Status: $status"
if [[ "$status" != "200" ]]; then
echo "ERROR: Pod $pod returned status $status instead of 200!"
critical_pods+=("$pod")
all_ok=false
else
echo "Pod $pod status OK."
fi
echo "----------------------------------------"
done
if [ "$all_ok" == false ]; then
echo ""
echo "CRITICAL - The following pods returned non-200 status:"
for critical_pod in "${critical_pods[@]}"; do
echo "- $critical_pod"
done
exit 2
else
echo "OK - All pods returned status 200."
exit 0
fi