zabbix

package
v0.0.0-...-97b18e2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2022 License: Apache-2.0, BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Available   AvailableType = 1
	Unavailable AvailableType = 2

	Monitored   StatusType = 0
	Unmonitored StatusType = 1

	InventoryDisabled  InventoryType = -1
	InventoryManual    InventoryType = 0
	InventoryAutomatic InventoryType = 1
)
View Source
const (
	ZabbixAgent       ItemType = 0
	SNMPv1Agent       ItemType = 1
	ZabbixTrapper     ItemType = 2
	SimpleCheck       ItemType = 3
	SNMPv2Agent       ItemType = 4
	ZabbixInternal    ItemType = 5
	SNMPv3Agent       ItemType = 6
	ZabbixAgentActive ItemType = 7
	ZabbixAggregate   ItemType = 8
	WebItem           ItemType = 9
	ExternalCheck     ItemType = 10
	DatabaseMonitor   ItemType = 11
	IPMIAgent         ItemType = 12
	SSHAgent          ItemType = 13
	TELNETAgent       ItemType = 14
	Calculated        ItemType = 15
	JMXAgent          ItemType = 16

	Float     ValueType = 0
	Character ValueType = 1
	Log       ValueType = 2
	Unsigned  ValueType = 3
	Text      ValueType = 4

	Decimal     DataType = 0
	Octal       DataType = 1
	Hexadecimal DataType = 2
	Boolean     DataType = 3

	AsIs  DeltaType = 0
	Speed DeltaType = 1
	Delta DeltaType = 2
)
View Source
const (
	NotClassified PriorityType = 0
	Information   PriorityType = 1
	Warning       PriorityType = 2
	Average       PriorityType = 3
	High          PriorityType = 4
	Critical      PriorityType = 5

	Enabled  StatusType = 0
	Disabled StatusType = 1

	OK      ValueType = 0
	Problem ValueType = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	Auth   string      // auth token, filled by Login()
	Logger *log.Logger // request/response logger, nil by default
	// contains filtered or unexported fields
}

func NewAPI

func NewAPI(url string) (api *API)

Creates new API access object. Typical URL is http://host/api_jsonrpc.php or http://host/zabbix/api_jsonrpc.php. It also may contain HTTP basic auth username and password like http://username:password@host/api_jsonrpc.php.

func (*API) Call

func (api *API) Call(method string, params interface{}) (Response, error)

Calls specified API method. Uses api.Auth if not empty. err is something network or marshaling related. Caller should inspect response.Error to get API error.

func (*API) CallWithError

func (api *API) CallWithError(method string, params interface{}) (Response, error)

Uses Call() and then sets err to response.Error if former is nil and latter is not.

func (*API) HostGetByHost

func (api *API) HostGetByHost(host string) (*Host, error)

Gets host by Host only if there is exactly 1 matching host.

func (*API) HostGetById

func (api *API) HostGetById(id string) (*Host, error)

Gets host by Id only if there is exactly 1 matching host.

func (*API) HostGroupGetById

func (api *API) HostGroupGetById(id string) (*HostGroup, error)

Gets host group by Id only if there is exactly 1 matching host group.

func (*API) HostGroupsCreate

func (api *API) HostGroupsCreate(hostGroups HostGroups) error

Wrapper for hostgroup.create: https://www.zabbix.com/documentation/2.2/manual/appendix/api/hostgroup/create

func (*API) HostGroupsDelete

func (api *API) HostGroupsDelete(hostGroups HostGroups) error

Wrapper for hostgroup.delete: https://www.zabbix.com/documentation/2.2/manual/appendix/api/hostgroup/delete Cleans GroupId in all hostGroups elements if call succeed.

func (*API) HostGroupsDeleteByIds

func (api *API) HostGroupsDeleteByIds(ids []string) error

Wrapper for hostgroup.delete: https://www.zabbix.com/documentation/2.2/manual/appendix/api/hostgroup/delete

func (*API) HostGroupsGet

func (api *API) HostGroupsGet(params Params) (HostGroups, error)

Wrapper for hostgroup.get: https://www.zabbix.com/documentation/2.2/manual/appendix/api/hostgroup/get

func (*API) HostsCreate

func (api *API) HostsCreate(hosts Hosts) error

Wrapper for host.create: https://www.zabbix.com/documentation/2.2/manual/appendix/api/host/create

func (*API) HostsDelete

func (api *API) HostsDelete(hosts Hosts) error

Wrapper for host.delete: https://www.zabbix.com/documentation/2.2/manual/appendix/api/host/delete Cleans HostId in all hosts elements if call succeed.

func (*API) HostsDeleteByIds

func (api *API) HostsDeleteByIds(ids []string) error

Wrapper for host.delete: https://www.zabbix.com/documentation/2.2/manual/appendix/api/host/delete

func (*API) HostsGet

func (api *API) HostsGet(params Params) (Hosts, error)

Wrapper for host.get: https://www.zabbix.com/documentation/2.2/manual/appendix/api/host/get

func (*API) HostsGetByHostGroupIds

func (api *API) HostsGetByHostGroupIds(ids []string) (res Hosts, err error)

Gets hosts by host group Ids.

func (*API) HostsGetByHostGroups

func (api *API) HostsGetByHostGroups(hostGroups HostGroups) (res Hosts, err error)

Gets hosts by host groups.

func (*API) HostsUpdate

func (api *API) HostsUpdate(hosts Hosts) error

Wrapper for host.update: https://www.zabbix.com/documentation/2.2/manual/appendix/api/host/update

func (*API) ItemsCreate

func (api *API) ItemsCreate(items Items) error

Wrapper for item.create: https://www.zabbix.com/documentation/2.2/manual/appendix/api/item/create

func (*API) ItemsDelete

func (api *API) ItemsDelete(items Items) error

Wrapper for item.delete: https://www.zabbix.com/documentation/2.2/manual/appendix/api/item/delete Cleans ItemId in all items elements if call succeed.

func (*API) ItemsDeleteByIds

func (api *API) ItemsDeleteByIds(ids []string) error

Wrapper for item.delete: https://www.zabbix.com/documentation/2.2/manual/appendix/api/item/delete

func (*API) ItemsGet

func (api *API) ItemsGet(params Params) (Items, error)

Wrapper for item.get https://www.zabbix.com/documentation/2.2/manual/appendix/api/item/get

func (*API) ItemsUpdate

func (api *API) ItemsUpdate(items Items) error

Wrapper for item.update: https://www.zabbix.com/documentation/2.2/manual/appendix/api/item/update

func (*API) Login

func (api *API) Login(user, password string) (string, error)

Calls "user.login" API method and fills api.Auth field. This method modifies API structure and should not be called concurrently with other methods.

func (*API) SetClient

func (api *API) SetClient(c *http.Client)

Allows one to use specific http.Client, for example with InsecureSkipVerify transport.

func (*API) TriggersCreate

func (api *API) TriggersCreate(triggers Triggers) error

Wrapper for item.create: https://www.zabbix.com/documentation/2.2/manual/appendix/api/item/create

func (*API) TriggersDelete

func (api *API) TriggersDelete(triggers Triggers) error

Wrapper for item.delete: https://www.zabbix.com/documentation/2.2/manual/appendix/api/item/delete Cleans ItemId in all items elements if call succeed.

func (*API) TriggersDeleteByIds

func (api *API) TriggersDeleteByIds(ids []string) error

Wrapper for item.delete: https://www.zabbix.com/documentation/2.2/manual/appendix/api/item/delete

func (*API) TriggersGet

func (api *API) TriggersGet(params Params) (Triggers, error)

Wrapper for item.get https://www.zabbix.com/documentation/2.2/manual/appendix/api/item/get

func (*API) TriggersUpdate

func (api *API) TriggersUpdate(triggers Triggers) error

Wrapper for item.update: https://www.zabbix.com/documentation/2.2/manual/appendix/api/item/update

func (*API) Version

func (api *API) Version() (string, error)

Calls "APIInfo.version" API method. This method temporary modifies API structure and should not be called concurrently with other methods.

type AvailableType

type AvailableType int

type DataType

type DataType int

type DeltaType

type DeltaType int

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    string `json:"data"`
}

func (*Error) Error

func (e *Error) Error() string

type ExpectedMore

type ExpectedMore struct {
	Expected int
	Got      int
}

func (*ExpectedMore) Error

func (e *ExpectedMore) Error() string

type ExpectedOneResult

type ExpectedOneResult int

func (*ExpectedOneResult) Error

func (e *ExpectedOneResult) Error() string

type Host

type Host struct {
	HostId    string        `json:"hostid,omitempty"`
	Host      string        `json:"host"`
	Available AvailableType `json:"available"`
	Error     string        `json:"error"`
	Name      string        `json:"name"`
	Status    StatusType    `json:"status"`

	InventoryMode InventoryType     `json:"inventory_mode"`
	Inventory     map[string]string `json:"inventory"`

	// Fields below used only when creating hosts
	GroupIds   HostGroupIds   `json:"groups,omitempty"`
	Interfaces HostInterfaces `json:"interfaces,omitempty"`
}

https://www.zabbix.com/documentation/2.2/manual/appendix/api/host/definitions

type HostGroup

type HostGroup struct {
	GroupId  string       `json:"groupid,omitempty"`
	Name     string       `json:"name"`
	Internal InternalType `json:"internal,omitempty"`
}

https://www.zabbix.com/documentation/2.2/manual/appendix/api/hostgroup/definitions

type HostGroupId

type HostGroupId struct {
	GroupId string `json:"groupid"`
}

type HostGroupIds

type HostGroupIds []HostGroupId

type HostGroups

type HostGroups []HostGroup

type HostInterface

type HostInterface struct {
	DNS   string        `json:"dns"`
	IP    string        `json:"ip"`
	Main  int           `json:"main"`
	Port  string        `json:"port"`
	Type  InterfaceType `json:"type"`
	UseIP int           `json:"useip"`
}

https://www.zabbix.com/documentation/2.2/manual/appendix/api/hostinterface/definitions

type HostInterfaces

type HostInterfaces []HostInterface

type Hosts

type Hosts []Host

type InterfaceType

type InterfaceType int
const (
	Agent InterfaceType = 1
	SNMP  InterfaceType = 2
	IPMI  InterfaceType = 3
	JMX   InterfaceType = 4
)

type InternalType

type InternalType int
const (
	NotInternal InternalType = 0
	Internal    InternalType = 1
)

type InventoryType

type InventoryType int

type Item

type Item struct {
	ItemId       string    `json:"itemid,omitempty"`
	Delay        int       `json:"delay"`
	HostId       string    `json:"hostid"`
	InterfaceId  string    `json:"interfaceid,omitempty"`
	Key          string    `json:"key_"`
	Name         string    `json:"name"`
	Type         ItemType  `json:"type"`
	ValueType    ValueType `json:"value_type"`
	DataType     DataType  `json:"data_type"`
	Delta        DeltaType `json:"delta"`
	Description  string    `json:"description"`
	Error        string    `json:"error"`
	History      string    `json:"history,omitempty"`
	Trends       string    `json:"trends,omitempty"`
	TrapperHosts string    `json:"trapper_hosts,omitempty"`
}

https://www.zabbix.com/documentation/2.2/manual/appendix/api/item/definitions

type ItemType

type ItemType int

type Items

type Items []Item

func (Items) ByKey

func (items Items) ByKey() map[string]Item

Converts slice to map by key. Panics if there are duplicate keys.

type Params

type Params map[string]interface{}

type PriorityType

type PriorityType int

type Response

type Response struct {
	Jsonrpc string      `json:"jsonrpc"`
	Error   *Error      `json:"error"`
	Result  interface{} `json:"result"`
	Id      int32       `json:"id"`
}

type StatusType

type StatusType int

type Tag

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

type Trigger

type Trigger struct {
	TriggerId   string       `json:"triggerid,omitempty"`
	Description string       `json:"description"`
	Expression  string       `json:"expression"`
	Comments    string       `json:"comments"`
	URL         string       `json:"url"`
	ManualClose int32        `json:"manual_close"`
	Value       ValueType    `json:",omitempty"`
	Priority    PriorityType `json:"priority"`
	Status      StatusType   `json:"status"`
	Tags        []Tag        `json:"tags"`
}

https://www.zabbix.com/documentation/2.2/manual/appendix/api/item/definitions

type Triggers

type Triggers []Trigger

type ValueType

type ValueType int

Jump to

Keyboard shortcuts

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