diff --git a/README.md b/README.md index 58da63e..9751c8d 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,17 @@ The import command: - Auto-creates runtime tables (hourly/daily/monthly snapshot tables and cache tables) when needed. - Replaces existing data in imported Postgres tables during the run. +If you want a one-time canonical aggregation benchmark (Go vs SQL cores) and exit, use: + +```shell +vctp -settings /path/to/vctp.yml -benchmark-aggregations -benchmark-runs 3 +``` + +The benchmark command: +- Uses canonical cache sources (`vm_hourly_stats` for daily, `vm_daily_rollup` for monthly). +- Runs Go and SQL aggregation cores for the latest available daily/monthly windows. +- Writes results to startup logs and exits without changing scheduled defaults. + ## Database Configuration By default the app uses SQLite and creates/opens `db.sqlite3`. @@ -205,8 +216,12 @@ Hourly and daily snapshot table retention can be configured in the settings file ## Runtime Environment Flags These optional flags are read from the process environment (for example via `/etc/default/vctp`): -- `DAILY_AGG_GO`: set to `1` (default in `src/vctp.default`) to use the Go daily aggregation path. -- `MONTHLY_AGG_GO`: set to `1` (default in `src/vctp.default`) to use the Go monthly aggregation path. +- `DAILY_AGG_GO`: set to `1` (default in `src/vctp.default`) to force Go for manual daily runs. +- `DAILY_AGG_SQL`: set to `1` to force legacy SQL fallback for manual daily runs. +- `MONTHLY_AGG_GO`: set to `1` (default in `src/vctp.default`) to force Go for manual monthly runs. +- `MONTHLY_AGG_SQL`: set to `1` to force legacy SQL fallback for manual monthly runs. + +Scheduled aggregation engine selection is controlled by YAML (`settings.scheduled_aggregation_engine`), not these env vars. ## Authentication and Authorization Authentication uses LDAP bind + JWT bearer tokens. @@ -246,6 +261,16 @@ Debug endpoints: - `/debug/pprof/*` handlers are only registered when `settings.enable_pprof: true`. - When enabled, they require an authenticated `admin` token. +## Airgapped Static Assets +vCTP is safe for airgapped operation without internet/CDN dependencies for UI/docs assets: + +- CSS, JS, and favicon assets are bundled into the binary via Go `embed` and served from local routes (`/assets/*`, `/favicon*`). +- Swagger UI is vendored under `server/router/swagger-ui-dist` and served locally from `/swagger/*`. +- Swagger spec is served locally from `/swagger.json` (`validatorUrl` is disabled in the initializer). +- Static responses include cache headers. In release builds, versioned assets are served with long-lived cache headers and immutable caching. + +This means runtime access to external asset hosts is not required. + ## Credential Encryption Lifecycle At startup, vCTP resolves `settings.vcenter_password` using this order: @@ -343,6 +368,8 @@ Snapshots: - `title_cell` (optional): explicit title cell; if omitted, derived from `pivot_range` - `settings.hourly_snapshot_retry_seconds`: interval for retrying failed hourly snapshots (default: 300 seconds) - `settings.hourly_snapshot_max_retries`: maximum retry attempts per vCenter snapshot (default: 3) +- `settings.postgres_vm_hourly_partitioning_enabled`: Postgres-only toggle to migrate/manage `vm_hourly_stats` as monthly range partitions (default: `false`) +- `settings.scheduled_aggregation_engine`: scheduled daily/monthly engine (`go` default, `sql` for canonical SQL rollout) Filters/chargeback: - `settings.tenants_to_filter`: list of tenant name patterns to exclude diff --git a/components/core/header.templ b/components/core/header.templ index 95c282d..e1e8d8c 100644 --- a/components/core/header.templ +++ b/components/core/header.templ @@ -8,14 +8,14 @@ templ Header() { - +
SHA1 Version
-{ info.SHA1Ver }
+{ truncateSHA(info.SHA1Ver) }
Go Runtime
{ info.GoVersion }
vCTP is a vSphere Chargeback Tracking Platform.
@@ -61,7 +72,7 @@ templ Index(info BuildInfo) {
Use /api/auth/me to inspect active claims and roles during integration and diagnostics.
Hourly snapshots capture inventory per vCenter (concurrency via hourly_snapshot_concurrency), then daily and monthly summaries are derived from those snapshots.
Monthly aggregation reports include a Daily Totals sheet with full-day interval labels (YYYY-MM-DD to YYYY-MM-DD) and prorated totals.
SamplesPresent is the count of snapshots in which the VM appears; TotalSamples is the count of unique snapshot times for that vCenter/day.
SHA1 Version
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "
SHA1 Version
Go Runtime
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var4 string - templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(info.GoVersion) + templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(truncateSHA(info.SHA1Ver)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/index.templ`, Line: 48, Col: 48} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/index.templ`, Line: 55, Col: 120} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "
vCTP is a vSphere Chargeback Tracking Platform.
Use fast vCenter totals views (Daily Aggregated and Hourly Detail 45d) and VM Trace views (Hourly Detail and Daily Aggregated) to move between long-range trends and granular timelines.
Use /api/auth/me to inspect active claims and roles during integration and diagnostics.
Hourly snapshots capture inventory per vCenter (concurrency via hourly_snapshot_concurrency), then daily and monthly summaries are derived from those snapshots.
Hourly tracks: VM identity (InventoryId, Name, VmId, VmUuid, Vcenter, EventKey, CloudId), lifecycle (CreationTime, DeletionTime, SnapshotTime), placement (Datacenter, Cluster, Folder, ResourcePool), and sizing/state (VcpuCount, RamGB, ProvisionedDisk, PoweredOn, IsTemplate, SrmPlaceholder).
Daily tracks: SamplesPresent, TotalSamples, AvgIsPresent, AvgVcpuCount, AvgRamGB, AvgProvisionedDisk, PoolTinPct, PoolBronzePct, PoolSilverPct, PoolGoldPct, plus chargeback totals columns Tin, Bronze, Silver, Gold.
Monthly tracks: the same daily aggregate fields, with monthly values weighted by per-day sample volume so partial-day VMs and config changes stay proportional.
Snapshots are registered in snapshot_registry so regeneration via /api/snapshots/aggregate can locate the correct tables (fallback scanning is also supported).
vCenter totals pages are accelerated by compact cache tables: vcenter_latest_totals and vcenter_aggregate_totals.
VM Trace daily mode uses the vm_daily_rollup cache when available, and falls back to daily summary tables if needed.
Reports (XLSX with totals/charts) are generated automatically after hourly, daily, and monthly jobs and written to a reports directory.
Hourly totals are interval-based: each row represents [HH:00, HH+1:00) and uses the first snapshot at or after the hour end (including cross-day snapshots) to prorate VM presence.
Monthly aggregation reports include a Daily Totals sheet with full-day interval labels (YYYY-MM-DD to YYYY-MM-DD) and prorated totals.
SamplesPresent is the count of snapshots in which the VM appears; TotalSamples is the count of unique snapshot times for that vCenter/day.
AvgIsPresent = SamplesPresent / TotalSamples (0 when TotalSamples is 0).
Daily AvgVcpuCount, AvgRamGB, and AvgProvisionedDisk are per-sample sums divided by TotalSamples (time-weighted).
Daily pool percentages (PoolTinPct/PoolBronzePct/PoolSilverPct/PoolGoldPct) use pool-hit counts divided by SamplesPresent.
Monthly aggregation converts each day into weighted sums using sample volume, then recomputes monthly averages and pool percentages from those weighted totals.
CreationTime is only set when vCenter provides it; otherwise it remains 0.
Go Runtime
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var5 string + templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(info.GoVersion) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/index.templ`, Line: 59, Col: 48} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "
vCTP is a vSphere Chargeback Tracking Platform.
Use fast vCenter totals views (Daily Aggregated and Hourly Detail 45d) and VM Trace views (Hourly Detail and Daily Aggregated) to move between long-range trends and granular timelines.
Use /api/auth/me to inspect active claims and roles during integration and diagnostics.
Hourly snapshots capture inventory per vCenter (concurrency via hourly_snapshot_concurrency), then daily and monthly summaries are derived from those snapshots.
Hourly tracks: VM identity (InventoryId, Name, VmId, VmUuid, Vcenter, EventKey, CloudId), lifecycle (CreationTime, DeletionTime, SnapshotTime), placement (Datacenter, Cluster, Folder, ResourcePool), and sizing/state (VcpuCount, RamGB, ProvisionedDisk, PoweredOn, IsTemplate, SrmPlaceholder).
Daily tracks: SamplesPresent, TotalSamples, AvgIsPresent, AvgVcpuCount, AvgRamGB, AvgProvisionedDisk, PoolTinPct, PoolBronzePct, PoolSilverPct, PoolGoldPct, plus chargeback totals columns Tin, Bronze, Silver, Gold.
Monthly tracks: the same daily aggregate fields, with monthly values weighted by per-day sample volume so partial-day VMs and config changes stay proportional.
Snapshots are registered in snapshot_registry so regeneration via /api/snapshots/aggregate can locate the correct tables (fallback scanning is also supported).
vCenter totals pages are accelerated by compact cache tables: vcenter_latest_totals and vcenter_aggregate_totals.
VM Trace daily mode uses the vm_daily_rollup cache when available, and falls back to daily summary tables if needed.
Reports (XLSX with totals/charts) are generated automatically after hourly, daily, and monthly jobs and written to a reports directory.
Hourly totals are interval-based: each row represents [HH:00, HH+1:00) and uses the first snapshot at or after the hour end (including cross-day snapshots) to prorate VM presence.
Monthly aggregation reports include a Daily Totals sheet with full-day interval labels (YYYY-MM-DD to YYYY-MM-DD) and prorated totals.
SamplesPresent is the count of snapshots in which the VM appears; TotalSamples is the count of unique snapshot times for that vCenter/day.
AvgIsPresent = SamplesPresent / TotalSamples (0 when TotalSamples is 0).
Daily AvgVcpuCount, AvgRamGB, and AvgProvisionedDisk are per-sample sums divided by TotalSamples (time-weighted).
Daily pool percentages (PoolTinPct/PoolBronzePct/PoolSilverPct/PoolGoldPct) use pool-hit counts divided by SamplesPresent.
Monthly aggregation converts each day into weighted sums using sample volume, then recomputes monthly averages and pool percentages from those weighted totals.
CreationTime is only set when vCenter provides it; otherwise it remains 0.