zabbix

package
v1.0.0-rc1.0...-e18caea Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashString

func HashString(text string) string

HashString converts the given text string to hash string

func IsCachedRequest

func IsCachedRequest(method string) bool

Types

type Application

type Application struct {
	Name string `json:"name"`
	ID   string `json:"applicationid"`
}

type Group

type Group struct {
	Name string `json:"name"`
	ID   string `json:"groupid"`
}

type History

type History []HistoryPoint

type HistoryPoint

type HistoryPoint struct {
	ItemID string  `json:"itemid,omitempty"`
	Clock  int64   `json:"clock,omitempty,string"`
	Value  float64 `json:"value,omitempty,string"`
	NS     int64   `json:"ns,omitempty,string"`
}

type Host

type Host struct {
	Name string `json:"name"`
	Host string `json:"host"`
	ID   string `json:"hostid"`
}

type Item

type Item struct {
	ID         string     `json:"itemid,omitempty"`
	Key        string     `json:"key_,omitempty"`
	Name       string     `json:"name,omitempty"`
	ValueType  int        `json:"value_type,omitempty,string"`
	HostID     string     `json:"hostid,omitempty"`
	Hosts      []ItemHost `json:"hosts,omitempty"`
	Status     string     `json:"status,omitempty"`
	State      string     `json:"state,omitempty"`
	Delay      string     `json:"delay,omitempty"`
	Units      string     `json:"units,omitempty"`
	ValueMapID string     `json:"valuemapid,omitempty"`
	Tags       []ItemTag  `json:"tags,omitempty"`
}

func (*Item) ExpandItemName

func (item *Item) ExpandItemName() string

type ItemHost

type ItemHost struct {
	ID   string `json:"hostid,omitempty"`
	Name string `json:"name,omitempty"`
}

type ItemTag

type ItemTag struct {
	Tag   string `json:"tag,omitempty"`
	Value string `json:"value,omitempty"`
}

type Items

type Items []Item

type Trend

type Trend []TrendPoint

type TrendPoint

type TrendPoint struct {
	ItemID   string `json:"itemid,omitempty"`
	Clock    int64  `json:"clock,omitempty,string"`
	Num      string `json:"num,omitempty"`
	ValueMin string `json:"value_min,omitempty"`
	ValueAvg string `json:"value_avg,omitempty"`
	ValueMax string `json:"value_max,omitempty"`
}

type ValueMap

type ValueMap struct {
	ID       string         `json:"valuemapid"`
	Name     string         `json:"name"`
	Mappings []ValueMapping `json:"mappings"`
}

type ValueMapping

type ValueMapping struct {
	Value    string `json:"value"`
	NewValue string `json:"newvalue"`
}

type Zabbix

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

Zabbix is a wrapper for Zabbix API. It wraps Zabbix API queries and performs authentication, adds caching, deduplication and other performance optimizations.

func MockZabbixClient

func MockZabbixClient(dsInfo *backend.DataSourceInstanceSettings, body string, statusCode int) (*Zabbix, error)

func MockZabbixClientResponse

func MockZabbixClientResponse(client *Zabbix, body string, statusCode int) (*Zabbix, error)

func New

New returns new instance of Zabbix client.

func (*Zabbix) Authenticate

func (zabbix *Zabbix) Authenticate(ctx context.Context) error

func (*Zabbix) GetAPI

func (zabbix *Zabbix) GetAPI() *zabbixapi.ZabbixAPI

func (*Zabbix) GetAllApps

func (ds *Zabbix) GetAllApps(ctx context.Context, hostids []string) ([]Application, error)

func (*Zabbix) GetAllGroups

func (ds *Zabbix) GetAllGroups(ctx context.Context) ([]Group, error)

func (*Zabbix) GetAllHosts

func (ds *Zabbix) GetAllHosts(ctx context.Context, groupids []string) ([]Host, error)

func (*Zabbix) GetAllItems

func (ds *Zabbix) GetAllItems(ctx context.Context, hostids []string, appids []string, itemtype string, showDisabled bool, itemTagFilter string) ([]*Item, error)

func (*Zabbix) GetApps

func (ds *Zabbix) GetApps(ctx context.Context, groupFilter string, hostFilter string, appFilter string) ([]Application, error)

func (*Zabbix) GetGroups

func (ds *Zabbix) GetGroups(ctx context.Context, groupFilter string) ([]Group, error)

func (*Zabbix) GetHistory

func (ds *Zabbix) GetHistory(ctx context.Context, items []*Item, timeRange backend.TimeRange) (History, error)

func (*Zabbix) GetHosts

func (ds *Zabbix) GetHosts(ctx context.Context, groupFilter string, hostFilter string) ([]Host, error)

func (*Zabbix) GetItemTags

func (ds *Zabbix) GetItemTags(ctx context.Context, groupFilter string, hostFilter string, tagFilter string) ([]ItemTag, error)

func (*Zabbix) GetItems

func (ds *Zabbix) GetItems(
	ctx context.Context,
	groupFilter string,
	hostFilter string,
	itemTagFilter string,
	itemFilter string,
	itemType string,
	showDisabled bool,
) ([]*Item, error)

func (*Zabbix) GetItemsBefore54

func (ds *Zabbix) GetItemsBefore54(
	ctx context.Context,
	groupFilter string,
	hostFilter string,
	appFilter string,
	itemFilter string,
	itemType string,
	showDisabled bool,
) ([]*Item, error)

func (*Zabbix) GetItemsByIDs

func (ds *Zabbix) GetItemsByIDs(ctx context.Context, itemids []string) ([]*Item, error)

func (*Zabbix) GetTrend

func (ds *Zabbix) GetTrend(ctx context.Context, items []*Item, timeRange backend.TimeRange) (Trend, error)

func (*Zabbix) GetValueMappings

func (ds *Zabbix) GetValueMappings(ctx context.Context) ([]ValueMap, error)

func (*Zabbix) GetVersion

func (ds *Zabbix) GetVersion(ctx context.Context) (int, error)

func (*Zabbix) Request

func (ds *Zabbix) Request(ctx context.Context, apiReq *ZabbixAPIRequest) (*simplejson.Json, error)

Request wraps request with cache

type ZabbixAPIParams

type ZabbixAPIParams = map[string]interface{}

type ZabbixAPIRequest

type ZabbixAPIRequest struct {
	Method string          `json:"method"`
	Params ZabbixAPIParams `json:"params,omitempty"`
}

func (*ZabbixAPIRequest) String

func (r *ZabbixAPIRequest) String() string

type ZabbixCache

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

ZabbixCache is a cache for datasource instance.

func NewZabbixCache

func NewZabbixCache(ttl time.Duration, cleanupInterval time.Duration) *ZabbixCache

NewZabbixCache creates a DatasourceCache with expiration(ttl) time and cleanupInterval.

func (*ZabbixCache) GetAPIRequest

func (c *ZabbixCache) GetAPIRequest(request *ZabbixAPIRequest) (interface{}, bool)

GetAPIRequest gets request response from cache

func (*ZabbixCache) SetAPIRequest

func (c *ZabbixCache) SetAPIRequest(request *ZabbixAPIRequest, response interface{})

SetAPIRequest writes request response to cache

type ZabbixDatasourceSettings

type ZabbixDatasourceSettings struct {
	Trends      bool
	TrendsFrom  time.Duration
	TrendsRange time.Duration
	CacheTTL    time.Duration
	Timeout     time.Duration

	DisableReadOnlyUsersAck bool `json:"disableReadOnlyUsersAck"`
}

type ZabbixDatasourceSettingsDTO

type ZabbixDatasourceSettingsDTO struct {
	Trends      bool   `json:"trends"`
	TrendsFrom  string `json:"trendsFrom"`
	TrendsRange string `json:"trendsRange"`
	CacheTTL    string `json:"cacheTTL"`
	Timeout     string `json:"timeout"`

	DisableReadOnlyUsersAck bool `json:"disableReadOnlyUsersAck"`
}

Jump to

Keyboard shortcuts

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