Let an agent report a chosen hostname
CI / tests (Python 3.10) (pull_request) Successful in 22s
CI / tests (Python 3.11) (pull_request) Successful in 22s
CI / tests (Python 3.12) (pull_request) Successful in 22s
CI / tests (Python 3.13) (pull_request) Successful in 21s
CI / lint (pull_request) Successful in 3s
CI / tests (Python 3.10) (pull_request) Successful in 22s
CI / tests (Python 3.11) (pull_request) Successful in 22s
CI / tests (Python 3.12) (pull_request) Successful in 22s
CI / tests (Python 3.13) (pull_request) Successful in 21s
CI / lint (pull_request) Successful in 3s
REPORT_HOSTNAME in agent.conf replaces hostname -f in the report, for hosts registered under a label that differs from their real hostname (otherwise the dashboard notes a mismatch forever). install.sh --report-hostname NAME sets it, --default-report-hostname clears it, and re-running with --server (register, rotate) keeps it. Agent 0.4.1. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3e62d086d1
commit
10b1d6abb8
6 files changed
+57
-6
No files matched your search
@@ -6,7 +6,7 @@
|
||||
# rules can change without redeploying agents.
|
||||
set -euo pipefail
|
||||
|
||||
AGENT_VERSION=0.4.0
|
||||
AGENT_VERSION=0.4.1
|
||||
|
||||
# Prefix for every file the agent reads. Only the test suite sets this.
|
||||
ROOT=${KERNELWATCH_ROOT:-}
|
||||
@@ -68,6 +68,8 @@ SERVER_URL=
|
||||
TOKEN_FILE=$ROOT/etc/kernelwatch/agent.token
|
||||
CA_FILE=
|
||||
TIMEOUT=30
|
||||
# Name to report instead of `hostname -f`, for a host registered under another name.
|
||||
REPORT_HOSTNAME=
|
||||
|
||||
load_config() {
|
||||
[[ -r $CONF ]] || return 0
|
||||
@@ -84,6 +86,7 @@ load_config() {
|
||||
TOKEN_FILE) TOKEN_FILE=$value ;;
|
||||
CA_FILE) CA_FILE=$value ;;
|
||||
TIMEOUT) TIMEOUT=$value ;;
|
||||
REPORT_HOSTNAME) REPORT_HOSTNAME=$value ;;
|
||||
*) echo "kernelwatch-agent: ignoring unknown config key '$key'" >&2 ;;
|
||||
esac
|
||||
done <"$CONF"
|
||||
@@ -248,7 +251,7 @@ build_report() {
|
||||
|
||||
printf '{'
|
||||
printf '"agent_version":%s,' "$(json_str "$AGENT_VERSION")"
|
||||
printf '"reported_hostname":%s,' "$(json_str "$(hostname -f 2>/dev/null || hostname)")"
|
||||
printf '"reported_hostname":%s,' "$(json_str "${REPORT_HOSTNAME:-$(hostname -f 2>/dev/null || hostname)}")"
|
||||
printf '"os_id":%s,' "$(json_str "$(os_release_field ID)")"
|
||||
printf '"os_version_id":%s,' "$(json_str "$(os_release_field VERSION_ID)")"
|
||||
printf '"os_pretty_name":%s,' "$(json_str "$(os_release_field PRETTY_NAME)")"
|
||||
|
||||
Reference in new issue
Block a user