feat: add collectors and rules
This commit is contained in:
26
scripts/lib/common.sh
Executable file
26
scripts/lib/common.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
vmcc_root() {
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd
|
||||
}
|
||||
|
||||
iso_utc_now() {
|
||||
date -u "+%Y-%m-%dT%H:%M:%SZ"
|
||||
}
|
||||
|
||||
run_id() {
|
||||
local ts
|
||||
ts="$(date -u "+%Y%m%dT%H%M%SZ")"
|
||||
local rnd
|
||||
rnd="$(head -c 8 /dev/urandom | od -An -tx1 | tr -d ' \n')"
|
||||
echo "${ts}_${rnd:0:8}"
|
||||
}
|
||||
|
||||
require_cmd() {
|
||||
command -v "$1" >/dev/null 2>&1 || { echo "missing required tool: $1" >&2; exit 2; }
|
||||
}
|
||||
|
||||
json_emit() {
|
||||
printf '%s\n' "$1"
|
||||
}
|
||||
Reference in New Issue
Block a user