more index cleanups to optimise space
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,8 +1,108 @@
|
||||
#!/bin/bash
|
||||
|
||||
TARGET_CFG="/etc/dtms/vctp.yml"
|
||||
SOURCE_CFG="${TARGET_CFG}.rpmnew"
|
||||
|
||||
extract_setting_key_lines() {
|
||||
local file="$1"
|
||||
awk '
|
||||
/^settings:[[:space:]]*$/ { in_settings = 1; next }
|
||||
in_settings && /^[^[:space:]]/ { in_settings = 0 }
|
||||
in_settings && $0 ~ /^ [A-Za-z0-9_]+:[[:space:]]*/ {
|
||||
key = $1
|
||||
sub(":", "", key)
|
||||
print key "\t" $0
|
||||
}
|
||||
' "$file"
|
||||
}
|
||||
|
||||
merge_missing_settings_from_rpmnew() {
|
||||
local target="$1"
|
||||
local source="$2"
|
||||
|
||||
if [ ! -f "$target" ] || [ ! -f "$source" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
local src_pairs target_pairs missing_lines merged_file
|
||||
src_pairs="$(mktemp /tmp/vctp-postinstall-src-XXXXXX)" || return 0
|
||||
target_pairs="$(mktemp /tmp/vctp-postinstall-target-XXXXXX)" || { rm -f "$src_pairs"; return 0; }
|
||||
missing_lines="$(mktemp /tmp/vctp-postinstall-missing-XXXXXX)" || {
|
||||
rm -f "$src_pairs" "$target_pairs"
|
||||
return 0
|
||||
}
|
||||
merged_file="$(mktemp /tmp/vctp-postinstall-merged-XXXXXX)" || {
|
||||
rm -f "$src_pairs" "$target_pairs" "$missing_lines"
|
||||
return 0
|
||||
}
|
||||
|
||||
extract_setting_key_lines "$source" > "$src_pairs"
|
||||
extract_setting_key_lines "$target" > "$target_pairs"
|
||||
|
||||
declare -A existing_keys=()
|
||||
while IFS=$'\t' read -r key _; do
|
||||
[ -n "$key" ] || continue
|
||||
existing_keys["$key"]=1
|
||||
done < "$target_pairs"
|
||||
|
||||
local added=0
|
||||
: > "$missing_lines"
|
||||
while IFS=$'\t' read -r key line; do
|
||||
[ -n "$key" ] || continue
|
||||
if [ -z "${existing_keys[$key]+x}" ]; then
|
||||
if [ "$added" -eq 0 ]; then
|
||||
echo " # Added automatically by RPM postinstall from vctp.yml.rpmnew defaults." >> "$missing_lines"
|
||||
fi
|
||||
echo "$line" >> "$missing_lines"
|
||||
existing_keys["$key"]=1
|
||||
added=$((added + 1))
|
||||
fi
|
||||
done < "$src_pairs"
|
||||
|
||||
if [ "$added" -gt 0 ]; then
|
||||
awk -v missing_file="$missing_lines" '
|
||||
function print_missing( line) {
|
||||
while ((getline line < missing_file) > 0) {
|
||||
print line
|
||||
}
|
||||
close(missing_file)
|
||||
}
|
||||
BEGIN { in_settings = 0; inserted = 0 }
|
||||
{
|
||||
if ($0 ~ /^settings:[[:space:]]*$/) {
|
||||
in_settings = 1
|
||||
print
|
||||
next
|
||||
}
|
||||
if (in_settings && $0 ~ /^[^[:space:]]/) {
|
||||
if (!inserted) {
|
||||
print_missing()
|
||||
inserted = 1
|
||||
}
|
||||
in_settings = 0
|
||||
}
|
||||
print
|
||||
}
|
||||
END {
|
||||
if (in_settings && !inserted) {
|
||||
print_missing()
|
||||
}
|
||||
}
|
||||
' "$target" > "$merged_file" && cat "$merged_file" > "$target"
|
||||
|
||||
if [ "$?" -eq 0 ]; then
|
||||
echo "vCTP postinstall: added ${added} missing settings key(s) to ${target}"
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -f "$src_pairs" "$target_pairs" "$missing_lines" "$merged_file"
|
||||
}
|
||||
|
||||
merge_missing_settings_from_rpmnew "$TARGET_CFG" "$SOURCE_CFG" || :
|
||||
|
||||
if command -v systemctl >/dev/null 2>&1; then
|
||||
systemctl daemon-reload || :
|
||||
if [ "$1" -eq 1 ]; then
|
||||
if [ "${1:-0}" -eq 1 ]; then
|
||||
systemctl enable --now vctp.service || :
|
||||
else
|
||||
systemctl try-restart vctp.service || :
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
CPE_OPTS='-settings /etc/dtms/vctp.yml'
|
||||
MONTHLY_AGG_GO=0
|
||||
DAILY_AGG_GO=0
|
||||
# Optional explicit encryption key source (recommended for stable credential decryption across host changes):
|
||||
# VCTP_ENCRYPTION_KEY=''
|
||||
# PostgreSQL is experimental and disabled by default:
|
||||
# VCTP_ENABLE_EXPERIMENTAL_POSTGRES=0
|
||||
# Deprecated API endpoints are disabled by default:
|
||||
# VCTP_ENABLE_LEGACY_API=0
|
||||
|
||||
# Aggregation engine selection (default: Go paths enabled).
|
||||
# DAILY_AGG_GO=1:
|
||||
# Use the Go fan-out/reduce daily aggregation path.
|
||||
# MONTHLY_AGG_GO=1:
|
||||
# Use the Go monthly aggregation path for both monthly modes
|
||||
# (hourly or daily source tables, controlled by settings.monthly_aggregation_granularity).
|
||||
# Set either option to 0 to prefer the SQL implementation for that layer.
|
||||
# If a Go aggregation run fails, vCTP automatically falls back to SQL for that run.
|
||||
DAILY_AGG_GO=1
|
||||
MONTHLY_AGG_GO=1
|
||||
# Additional runtime behavior is configured in the YAML file (`/etc/dtms/vctp.yml` by default).
|
||||
|
||||
10
src/vctp.yml
10
src/vctp.yml
@@ -2,6 +2,8 @@ settings:
|
||||
log_level: "info"
|
||||
log_output: "text"
|
||||
database_driver: "sqlite"
|
||||
# PostgreSQL remains experimental and is disabled by default.
|
||||
enable_experimental_postgres: false
|
||||
database_url: "/var/lib/vctp/db.sqlite3"
|
||||
reports_dir: /var/lib/vctp/reports
|
||||
bind_ip:
|
||||
@@ -9,9 +11,14 @@ settings:
|
||||
bind_disable_tls: false
|
||||
tls_cert_filename: "/var/lib/vctp/vctp.crt"
|
||||
tls_key_filename: "/var/lib/vctp/vctp.key"
|
||||
# Optional explicit key source for credential encryption/decryption.
|
||||
# Leave empty to use host-derived key material.
|
||||
encryption_key: ""
|
||||
vcenter_username: ""
|
||||
vcenter_password: ""
|
||||
vcenter_insecure: false
|
||||
# Legacy API endpoints are disabled by default.
|
||||
enable_legacy_api: false
|
||||
# Deprecated (ignored): legacy event poller
|
||||
vcenter_event_polling_seconds: 0
|
||||
# Deprecated (ignored): legacy inventory poller
|
||||
@@ -21,6 +28,9 @@ settings:
|
||||
hourly_snapshot_concurrency: 0
|
||||
hourly_snapshot_max_age_days: 60
|
||||
daily_snapshot_max_age_months: 12
|
||||
# Retain hourly-table indexes only for recent data.
|
||||
# -1 disables index cleanup; 0 trims indexes from all hourly tables.
|
||||
hourly_index_max_age_days: 7
|
||||
snapshot_cleanup_cron: "30 2 * * *"
|
||||
hourly_snapshot_retry_seconds: 300
|
||||
hourly_snapshot_max_retries: 3
|
||||
|
||||
Reference in New Issue
Block a user