blob: 132e4e3f4804af2d669fe7781214333a5ee9d668 (
plain)
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
|
#!/bin/bash
set -Eeu -o pipefail
shopt -s lastpipe
trap 'exit 3' ERR
ok=()
error=()
sudo asterisk -rx 'pjsip show registrations' \
| sed '1,4d' \
| head -n2 \
| while read -r uri auth status
do
msg="${auth} is ${status,,}"
if [ "$status" = Registered ]; then
ok+=("$msg")
else
err+=("$msg")
fi
done
if (( ${#error[@]} )); then
echo 'trunk is not registered!'
RC=2
else
echo 'all trunks registered'
RC=0
fi
if (( ${#error[@]} )); then
printf 'CRIT: %s\n' "${error[@]}"
fi
if (( ${#ok[@]} )); then
printf 'OK: %s\n' "${ok[@]}"
fi
exit $RC
|