mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-08 05:04:21 +08:00
🎈 Sync 2026-09-09 01:06:03
This commit is contained in:
1 parent
b6b067e0ad
commit
302b45db1b
35 files changed
+5887
No files matched your search
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
. /usr/libexec/haproxy-manager/common.sh
|
||||
|
||||
BASE="$(incident_dir)"
|
||||
[ ! -d "$BASE" ] || BASE="$(resolve_storage_dir "$BASE")" || exit 1
|
||||
LAST=""
|
||||
[ ! -r "$BASE/LAST" ] || LAST="$(basename "$(sed -n '1p' "$BASE/LAST")")"
|
||||
|
||||
safe_field() {
|
||||
printf '%s' "$1" | tr '\t\r\n' ' '
|
||||
}
|
||||
|
||||
count=0
|
||||
for dir in $(find "$BASE" -maxdepth 1 -type d -name '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9]' 2>/dev/null | sort -r); do
|
||||
[ -d "$dir" ] || continue
|
||||
id="$(basename "$dir")"
|
||||
latest=0
|
||||
[ "$id" != "$LAST" ] || latest=1
|
||||
result="$(sed -n '1p' "$dir/result" 2>/dev/null || echo detected)"
|
||||
action="$(sed -n 's/^action=//p' "$dir/meta" 2>/dev/null | head -1)"
|
||||
interface="$(sed -n 's/^interface=//p' "$dir/meta" 2>/dev/null | head -1)"
|
||||
reason="$(sed -n 's/^reason=//p' "$dir/meta" 2>/dev/null | head -1)"
|
||||
printf 'incident\t%s\t%s\t%s\t%s\t%s\t%s\n' \
|
||||
"$id" "$latest" "$(safe_field "$result")" "$(safe_field "$action")" \
|
||||
"$(safe_field "$interface")" "$(safe_field "$reason")"
|
||||
count=$((count + 1))
|
||||
[ "$count" -lt "$INCIDENT_LIMIT" ] || break
|
||||
done
|
||||
Reference in new issue
Block a user