icinga

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCertTemplate = `` /* 415-byte string literal not displayed */

DefaultCertTemplate is the Jet source seeded in the lab and shown as the Icinga settings placeholder. Rendered once per sync with .Checks.

Variables

This section is empty.

Functions

func FetchRemoteConfig

func FetchRemoteConfig(factumConfig *util.ConfigFactum) (*util.ConfigIcinga, error)

FetchRemoteConfig pulls the Icinga API connection settings from the primary, authenticated with factumConfig.Token (checked against the primary's Settings.FactumApiToken - see web.Controller.checkServiceToken).

func NewIcingaClient

func NewIcingaClient(c util.ConfigIcinga) *icingaClient

func RemoteClient

func RemoteClient(factumConfig *util.ConfigFactum) (*icingaClient, error)

RemoteClient is the FetchRemoteConfig + NewIcingaClient convenience most callers want.

Types

type FactumIcingaClient

type FactumIcingaClient struct {
	Config       *util.ConfigFactum
	IcingaConfig *util.ConfigIcinga
	Icinga       *icingaClient

	// Users collects alarm-destination email addresses seen while writing
	// hosts (writeDevices), for writeUsers to turn into Icinga User
	// objects. Reset at the start of each Update().
	Users map[string]bool
}

func NewFactumIcingaClient

func NewFactumIcingaClient(root *util.ConfigAgentRoot) (*FactumIcingaClient, error)

NewFactumIcingaClient fetches the Icinga API connection settings and the icinga_sync config (hosts/users file paths, templates, ignore list, ...) from the primary over REST - config.Icinga is never used, since factum2-icinga typically runs on a different host than the primary and has no local icinga config of its own (see util.ConfigIcinga's doc comment).

func (*FactumIcingaClient) Poll added in v1.3.0

func (fic *FactumIcingaClient) Poll(ctx context.Context, opt PollOptions, reporter jobevent.Reporter) error

Poll loads Icinga-monitored devices and submits one passive result per interface that has Interface alarms set, plus one per applied ELINE endpoint on a monitored device. Interval greater than zero repeats until ctx is cancelled. Counter state is kept in memory and, when StateFile is set, on disk so a later cycle can compute bit rates.

func (*FactumIcingaClient) Sync

func (fic *FactumIcingaClient) Sync(reporter jobevent.Reporter) error

Sync fetches devices from the Factum API, writes the icinga2 hosts, users, certificate-check, and interface config files, and asks icinga2 to reload if anything changed.

type HostState

type HostState struct {
	Name                 string
	Acknowledgement      int
	State                int
	Address              string
	Address6             string
	LastHardState        int
	LastHardStateChanged time.Time

	Notes string

	FactumComments     string
	FactumLocation     string
	FactumManufacturer string
	FactumModel        string
	FactumPlatform     string
	FactumRole         string
	FactumSiteName     string
}

HostState is the parsed, factum-relevant subset of an Icinga Host object (icinga's own https://icinga.com/docs/icinga2/latest/doc/12-icinga2-api/ "results[].attrs" shape, with the "vars.factum_*" custom vars set by Settings.IcingaHostTemplate - see internal/icinga/factum2-icinga.go).

type HostStateResult

type HostStateResult struct {
	Error   float32     `json:"error"`
	Status  string      `json:"status"`
	Results []HostState `json:"results"`
}

type PollOptions added in v1.3.0

type PollOptions struct {
	Workers     int
	Interval    time.Duration
	StateFile   string
	CommandPipe string
	Elines      []models.IcingaEline
	Open        func(ctx context.Context, addr, community string) (snmpQuerier, error)
	Submit      resultSubmitter
	// EOSShow overrides the Arista eAPI call. Nil uses show patch panel.
	EOSShow eosShowFunc
}

PollOptions controls one factum2-icinga poll run. Open and Submit are set by tests. A nil Open uses SNMPv2c. A nil Submit uses the command pipe when CommandPipe is set, otherwise the Icinga API. Elines is the applied ELINE inventory. Poll fills it from the Factum API.

type Response

type Response struct {
	Status  string `json:"status"`
	Message string `json:"message"`
	Data    any    `json:"data"`
}

type ServiceState

type ServiceState struct {
	HostName             string
	Name                 string
	Acknowledgement      int
	State                int
	LastHardState        int
	LastHardStateChanged time.Time
	Output               string
	Notes                string
}

ServiceState is the parsed, factum-relevant subset of an Icinga Service object.

type ServiceStateResult

type ServiceStateResult struct {
	Error   float32        `json:"error"`
	Status  string         `json:"status"`
	Results []ServiceState `json:"results"`
}

Jump to

Keyboard shortcuts

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