provisioner

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StateName = map[State]string{
	StateNew:     "New",
	StateUpdated: "Updated",
	StateEqual:   "Equal",
	StateOld:     "Old",
}

Functions

func GetZabbixPriority

func GetZabbixPriority(severity string) zabbix.PriorityType

Types

type CustomApplication

type CustomApplication struct {
	State State
	zabbix.Application
}

type CustomHost

type CustomHost struct {
	State State
	zabbix.Host
	HostGroups   map[string]struct{}
	Applications map[string]*CustomApplication
	Items        map[string]*CustomItem
	Triggers     map[string]*CustomTrigger
}

func (*CustomHost) AddApplication

func (host *CustomHost) AddApplication(application *CustomApplication)

func (*CustomHost) AddItem

func (host *CustomHost) AddItem(item *CustomItem)

func (*CustomHost) AddTrigger

func (host *CustomHost) AddTrigger(trigger *CustomTrigger)

func (*CustomHost) Equal

func (i *CustomHost) Equal(j *CustomHost) bool

func (*CustomHost) GetApplicationsByState

func (host *CustomHost) GetApplicationsByState() (applicationsByState map[State]zabbix.Applications)

func (*CustomHost) GetItemsByState

func (host *CustomHost) GetItemsByState() (itemsByState map[State]zabbix.Items)

func (*CustomHost) GetTriggersByState

func (host *CustomHost) GetTriggersByState() (triggersByState map[State]zabbix.Triggers)

func (*CustomHost) PropagateCreatedApplications

func (host *CustomHost) PropagateCreatedApplications(applications zabbix.Applications)

type CustomHostGroup

type CustomHostGroup struct {
	State State
	zabbix.HostGroup
}

type CustomItem

type CustomItem struct {
	State State
	zabbix.Item
	Applications map[string]struct{}
}

func (*CustomItem) Equal

func (i *CustomItem) Equal(j *CustomItem) bool

type CustomTrigger

type CustomTrigger struct {
	State State
	zabbix.Trigger
}

func (*CustomTrigger) Equal

func (i *CustomTrigger) Equal(j *CustomTrigger) bool

type CustomZabbix

type CustomZabbix struct {
	Hosts      map[string]*CustomHost
	HostGroups map[string]*CustomHostGroup
}

func (*CustomZabbix) AddHost

func (z *CustomZabbix) AddHost(host *CustomHost) (updatedHost *CustomHost)

func (*CustomZabbix) AddHostGroup

func (z *CustomZabbix) AddHostGroup(hostGroup *CustomHostGroup)

func (*CustomZabbix) GetHostGroupsByState

func (z *CustomZabbix) GetHostGroupsByState() (hostGroupsByState map[State]zabbix.HostGroups)

func (*CustomZabbix) GetHostsByState

func (z *CustomZabbix) GetHostsByState() (hostByState map[State]zabbix.Hosts)

func (*CustomZabbix) PropagateCreatedHostGroups

func (zabbix *CustomZabbix) PropagateCreatedHostGroups(hostGroups zabbix.HostGroups)

func (*CustomZabbix) PropagateCreatedHosts

func (zabbix *CustomZabbix) PropagateCreatedHosts(hosts zabbix.Hosts)

type HostConfig

type HostConfig struct {
	Name                    string            `yaml:"name"`
	HostGroups              []string          `yaml:"hostGroups"`
	Tag                     string            `yaml:"tag"`
	DeploymentStatus        string            `yaml:"deploymentStatus"`
	ItemDefaultApplication  string            `yaml:"itemDefaultApplication"`
	ItemDefaultHistory      string            `yaml:"itemDefaultHistory"`
	ItemDefaultTrends       string            `yaml:"itemDefaultTrends"`
	ItemDefaultTrapperHosts string            `yaml:"itemDefaultTrapperHosts"`
	HostAlertsDir           string            `yaml:"alertsDir"`
	TriggerTags             map[string]string `yaml:"triggerTags"`
}

func LoadHostConfigFromFile

func LoadHostConfigFromFile(filename string) ([]HostConfig, error)

type PrometheusAlertRules

type PrometheusAlertRules struct {
	Groups []struct {
		Rules []PrometheusRule `yaml:"rules"`
	} `yaml:"groups"`
}

type PrometheusRule

type PrometheusRule struct {
	Name        string            `yaml:"alert"`
	Annotations map[string]string `yaml:"annotations"`
	Expression  string            `yaml:"expr"`
	Labels      map[string]string `yaml:"labels"`
}

func LoadPrometheusRulesFromDir

func LoadPrometheusRulesFromDir(dir string) ([]PrometheusRule, error)

type Provisioner

type Provisioner struct {
	*CustomZabbix
	// contains filtered or unexported fields
}

func New

func New(prometheusUrl, keyPrefix, url, user, password string, hosts []HostConfig) (*Provisioner, error)

func (*Provisioner) ApplyChanges

func (p *Provisioner) ApplyChanges() error

func (*Provisioner) LoadDataFromZabbix

func (p *Provisioner) LoadDataFromZabbix() error

Update created hosts with the current state in Zabbix

func (*Provisioner) LoadRulesFromPrometheus

func (p *Provisioner) LoadRulesFromPrometheus(hostConfig HostConfig) error

Create hosts structures and populate them from Prometheus rules

func (*Provisioner) Run

func (p *Provisioner) Run() error

type State

type State int
const (
	StateNew State = iota
	StateUpdated
	StateEqual
	StateOld
)

Jump to

Keyboard shortcuts

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