-
Notifications
You must be signed in to change notification settings - Fork 0
/
velia-list-alarms.in
63 lines (55 loc) · 1.5 KB
/
velia-list-alarms.in
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
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env bash
usage() {
cat <<EOF
Usage: $0 [--cleared | --active] [-h]
Lists alarms from ietf-alarms.
Options:
--help, -h Show this help message.
--cleared, -c List only cleared alarms.
--active, -a List only active alarms.
--since DATE, -s=DATE List alarms last raised after the given date. DATE is ISO 8601 string.
--until DATE, -u=DATE List alarms last raised before the given date. DATE is ISO 8601 string.
EOF
exit 1
}
CONFIG="{}"
OPTS=$(getopt -q \
--options cas:u: \
--longoptions 'cleared,active,since:,until:' \
-n list-alarms -- $@)
[ $? -eq 0 ] || usage
eval set -- "$OPTS"
while true; do
case "$1" in
-c | --cleared)
CONFIG=$(jq '.cleared = true' <<< "${CONFIG}")
shift
;;
-a | --active)
CONFIG=$(jq '.cleared = false' <<< "${CONFIG}")
shift
;;
-s | --since)
CONFIG=$(jq ".since = \"$2\"" <<< "${CONFIG}")
shift 2
;;
-u | --until)
CONFIG=$(jq ".until = \"$2\"" <<< "${CONFIG}")
shift 2
;;
--)
shift
break
;;
-h|--help)
;&
*)
usage
;;
esac
done
sysrepocfg -f json -d operational -X -m ietf-alarms | \
jq -r \
-f "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/velia/velia-list-alarms.jq" \
--argjson config "${CONFIG}" \
| column -ts $'\t'