-
Notifications
You must be signed in to change notification settings - Fork 13
/
check-for-module-loaded.sh
executable file
·52 lines (47 loc) · 1.75 KB
/
check-for-module-loaded.sh
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
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# Checks for kernel modules in bosh instances
if [[ -z ${MODULE} || ${1} =~ -h ]]; then
echo "usage: MODULES=module [DEPLOYMENT=deployment] check-for-module-loaded.sh"
exit 2
fi
if [[ -n ${DEPLOYMENT} ]]; then
echo "Deployment set - only checking ${DEPLOYMENT}"
${DEPLOYMENTS}=${DEPLOYMENT}
else
echo "Getting all deployments"
DEPLOYMENTS=$(bosh deployments --json| jq -r '.Tables[].Rows[].name')
fi
present=""
not_present=""
error=""
for DEPLOYMENT in ${DEPLOYMENTS}; do
echo "Getting modules for ${DEPLOYMENT}"
results=$(bosh ssh -d ${DEPLOYMENT} -r --json -c "grep ${MODULE} /proc/modules")
for instance in $(echo ${results} | jq -r '.Tables[].Rows[] | select(.exit_code == "1").instance'); do
not_present+="${DEPLOYMENT}/${instance} "
done
for instance in $(echo ${results} | jq -r '.Tables[].Rows[] | select(.exit_code == "0").instance'); do
present+="${DEPLOYMENT}/${instance} "
done
for instance in $(echo ${results} | jq -r '.Tables[].Rows[] | select(.exit_code != "0" and .exit_code != "1").instance'); do
error+="$DEPLOYMENT/${instance} "
done
done
echo "==========================================="
echo ":: Instances without this module ::"
echo "==========================================="
for instance in ${not_present}; do
echo ${instance}
done
echo "==========================================="
echo ":: Instances with this module ::"
echo "==========================================="
for instance in ${present}; do
echo ${present}
done
if [[ -n $error ]]; then
echo "==========================================="
echo ":: Errored Instances ::"
echo "==========================================="
echo ${error}
fi