reports

package
v1.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package reports writes capacity, inventory and backup-compliance reports from facts the API collects on every cluster member, keeps them in -state-dir/reports, and runs report schedules (ADR-0030, made real in ADR-0032). Reports only state what was measured: a number VirtoMir does not know is left out, never estimated.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backup

type Backup struct {
	DomainUUID string    `json:"domainUuid"`
	Created    time.Time `json:"created"`
	SizeBytes  uint64    `json:"sizeBytes"`
}

type BackupSchedule

type BackupSchedule struct {
	DomainUUID string        `json:"domainUuid"`
	Interval   time.Duration `json:"interval"`
}

BackupSchedule is how often a machine is backed up automatically.

type CapacityData

type CapacityData struct {
	Hosts []capRow `json:"hosts"`
	Total capRow   `json:"total"`
	Pools []Pool   `json:"pools"`
}

CapacityData is the capacity report's JSON form.

type Facts

type Facts struct {
	Hosts []HostFacts `json:"hosts"`
	// Missing names members that did not answer; their machines are not in the report.
	Missing    []string         `json:"missing,omitempty"`
	Compliance []HostCompliance `json:"compliance,omitempty"`
}

Facts is what the reports are made of: one entry per cluster member that answered.

type Format

type Format string
const (
	HTML Format = "html"
	CSV  Format = "csv"
	JSON Format = "json"
)

type HostCompliance added in v0.9.0

type HostCompliance = compliance.HostCompliance

type HostFacts

type HostFacts struct {
	Name       string           `json:"name"`
	CPUs       int              `json:"cpus"`
	MemoryKiB  uint64           `json:"memoryKiB"`
	Machines   []Machine        `json:"machines"`
	Pools      []Pool           `json:"pools"`
	Backups    []Backup         `json:"backups"`
	Schedules  []BackupSchedule `json:"schedules"`
	Compliance *HostCompliance  `json:"compliance,omitempty"`
}

type InventoryItem

type InventoryItem struct {
	Machine
	Host string `json:"host"`
}

InventoryItem is one machine of the inventory report.

type Kind

type Kind string
const (
	Capacity   Kind = "capacity"
	Inventory  Kind = "inventory"
	BackupSLA  Kind = "backup_sla"
	Showback   Kind = "showback"
	Compliance Kind = "compliance"
)

type Machine

type Machine struct {
	UUID      string   `json:"uuid"`
	Name      string   `json:"name"`
	State     string   `json:"state"`
	Owner     string   `json:"owner,omitempty"`
	VCPUs     int      `json:"vcpus"`
	MemoryMiB uint64   `json:"memoryMiB"`
	DiskBytes uint64   `json:"diskBytes"` // capacity of its disks (CD-ROMs not counted)
	Disks     int      `json:"disks"`
	Addresses []string `json:"addresses,omitempty"`
	Autostart bool     `json:"autostart"`
	Template  bool     `json:"template"`
}

type Meta

type Meta struct {
	ID          string    `json:"id"`
	Kind        Kind      `json:"kind"`
	Title       string    `json:"title"`
	Format      Format    `json:"format"`
	GeneratedAt time.Time `json:"generatedAt"`
	SizeBytes   int64     `json:"sizeBytes"`
	Summary     string    `json:"summary"`
	// By is who asked for it, or "schedule: <name>".
	By         string `json:"by"`
	ScheduleID string `json:"scheduleId,omitempty"`
}

Meta describes one stored report.

type Pool

type Pool struct {
	Name            string `json:"name"`
	Type            string `json:"type"`
	Path            string `json:"path,omitempty"`
	Active          bool   `json:"active"`
	CapacityBytes   uint64 `json:"capacityBytes"`
	AllocationBytes uint64 `json:"allocationBytes"`
	AvailableBytes  uint64 `json:"availableBytes"`
}

type SLAItem

type SLAItem struct {
	Machine    string     `json:"machine"`
	UUID       string     `json:"uuid"`
	Host       string     `json:"host"`
	Status     string     `json:"status"` // ok, late, overdue, never, unscheduled
	LastBackup *time.Time `json:"lastBackup,omitempty"`
	AgeHours   float64    `json:"ageHours,omitempty"`
	Backups    int        `json:"backups"`
	SizeBytes  uint64     `json:"sizeBytes"` // all of its backups
	// Interval is its backup schedule ("" without one).
	Interval string `json:"interval,omitempty"`
}

SLAItem is one machine of the backup compliance report.

type Schedule

type Schedule struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	Kind    Kind   `json:"kind"`
	Format  Format `json:"format"`
	Enabled bool   `json:"enabled"`
	// Every: "daily", "weekly" (Mondays) or "monthly" (on the 1st), at At ("HH:MM", local).
	Every string `json:"every"`
	At    string `json:"at"`
	// KeepDays deletes this schedule's reports older than that (0: keep all).
	KeepDays int `json:"keepDays"`
	// Notify sends the summary through the alert channels (webhook, email) when done.
	Notify    bool       `json:"notify"`
	LastRun   *time.Time `json:"lastRun,omitempty"`
	LastError string     `json:"lastError,omitempty"`
	NextRun   *time.Time `json:"nextRun,omitempty"` // computed
}

Schedule makes a report regularly.

func (Schedule) Next

func (sc Schedule) Next(t time.Time) time.Time

Next is the first run after t.

type ShowbackBuilder added in v0.9.0

type ShowbackBuilder func(format Format) (summary string, body []byte, err error)

ShowbackBuilder builds a showback report body for one period. The API layer wires one up from the catalog package so schedules can name the showback kind like any other report.

type Store

type Store struct {
	// contains filtered or unexported fields
}

func Open

func Open(dir string) (*Store, error)

func (*Store) Delete

func (s *Store) Delete(id string) error

Delete removes a report.

func (*Store) DeleteSchedule

func (s *Store) DeleteSchedule(id string) error

func (*Store) Due

func (s *Store) Due(since time.Time) []Schedule

Due returns the enabled schedules whose next run after their last run (or after since, when they never ran) has come.

func (*Store) Generate

func (s *Store) Generate(kind Kind, format Format, f Facts, by, scheduleID string) (Meta, error)

Generate writes a report from facts and stores it.

func (*Store) Get

func (s *Store) Get(id string) (Meta, []byte, error)

Get returns a report and its content.

func (*Store) List

func (s *Store) List() []Meta

List is every stored report, newest first.

func (*Store) PutSchedule

func (s *Store) PutSchedule(sc Schedule) (Schedule, error)

PutSchedule adds (no ID) or replaces a schedule.

func (*Store) Ran

func (s *Store) Ran(id string, err error)

Ran records a schedule's run and deletes its reports older than KeepDays.

func (*Store) Schedules

func (s *Store) Schedules() []Schedule

Schedules lists the report schedules with their next run.

func (*Store) SetShowbackBuilder added in v0.9.0

func (s *Store) SetShowbackBuilder(fn ShowbackBuilder)

SetShowbackBuilder registers (or clears, with nil) the showback builder.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL