Documentation
¶
Overview ¶
Package zabbix provides bindings to interoperate between programs written in Go language and the Zabbix monitoring API.
Tested on Zabbix 3.2 but should work since 2.0 version. This package aims to support multiple zabbix resources from its API like trigger, application, host group, host, item, template..
Install it: `go get github.com/kgeroczi/go-zabbix-api`
Getting started
package main import ( "fmt" "github.com/kgeroczi/go-zabbix-api" ) func main() { user := "MyZabbixUsername" pass := "MyZabbixPassword" api := zabbix.NewAPI("http://localhost/api_jsonrpc.php") api.Login(user, pass) res, err := api.Version() if err != nil { panic(err) } fmt.Printf("Connected to zabbix api v%s\n", res) }
Run test You should run tests before using this package – Zabbix API doesn't match documentation in few details, which are changing in patch releases. Tests are not expected to be destructive, but you are advised to run them against not-production instance or at least make a backup.
export TEST_ZABBIX_URL=http://localhost:8080/zabbix/api_jsonrpc.php export TEST_ZABBIX_USER=Admin export TEST_ZABBIX_PASSWORD=zabbix export TEST_ZABBIX_VERBOSE=1 go test -v
`TEST_ZABBIX_URL` may contain HTTP basic auth username and password: `http://username:password@host/api_jsonrpc.php`. Also, in some setups URL should be like `http://host/zabbix/api_jsonrpc.php`.
Index ¶
- Constants
- type API
- func (api *API) ApplicationGetByHostIDAndName(hostID, name string) (res *Application, err error)
- func (api *API) ApplicationGetByID(id string) (res *Application, err error)
- func (api *API) ApplicationsCreate(apps Applications) (err error)
- func (api *API) ApplicationsDelete(apps Applications) (err error)
- func (api *API) ApplicationsDeleteByIds(ids []string) (err error)
- func (api *API) ApplicationsGet(params Params) (res Applications, err error)
- func (api *API) Call(method string, params interface{}) (response Response, err error)
- func (api *API) CallWithError(method string, params interface{}) (response Response, err error)
- func (api *API) CallWithErrorParse(method string, params interface{}, result interface{}) (err error)
- func (api *API) GraphGetByID(id string) (res *Graph, err error)
- func (api *API) GraphProtoGetByID(id string) (res *Graph, err error)
- func (api *API) GraphProtosCreate(hostGroups Graphs) (err error)
- func (api *API) GraphProtosDelete(hostGroups Graphs) (err error)
- func (api *API) GraphProtosDeleteByIds(ids []string) (err error)
- func (api *API) GraphProtosGet(params Params) (res Graphs, err error)
- func (api *API) GraphProtosUpdate(hostGroups Graphs) (err error)
- func (api *API) GraphsCreate(hostGroups Graphs) (err error)
- func (api *API) GraphsDelete(hostGroups Graphs) (err error)
- func (api *API) GraphsDeleteByIds(ids []string) (err error)
- func (api *API) GraphsGet(params Params) (res Graphs, err error)
- func (api *API) GraphsUpdate(hostGroups Graphs) (err error)
- func (api *API) HostGetByHost(host string) (res *Host, err error)
- func (api *API) HostGetByID(id string) (res *Host, err error)
- func (api *API) HostGroupGetByID(id string) (res *HostGroup, err error)
- func (api *API) HostGroupsCreate(hostGroups HostGroups) (err error)
- func (api *API) HostGroupsDelete(hostGroups HostGroups) (err error)
- func (api *API) HostGroupsDeleteByIds(ids []string) (err error)
- func (api *API) HostGroupsGet(params Params) (res HostGroups, err error)
- func (api *API) HostGroupsUpdate(hostGroups HostGroups) (err error)
- func (api *API) HostsCreate(hosts Hosts) (err error)
- func (api *API) HostsDelete(hosts Hosts) (err error)
- func (api *API) HostsDeleteByIds(ids []string) (err error)
- func (api *API) HostsGet(params Params) (res Hosts, err error)
- func (api *API) HostsGetByHostGroupIds(ids []string) (res Hosts, err error)
- func (api *API) HostsGetByHostGroups(hostGroups HostGroups) (res Hosts, err error)
- func (api *API) HostsUpdate(hosts Hosts) (err error)
- func (api *API) ItemGetByID(id string) (res *Item, err error)
- func (api *API) ItemsCreate(items Items) (err error)
- func (api *API) ItemsDelete(items Items) (err error)
- func (api *API) ItemsDeleteByIds(ids []string) (err error)
- func (api *API) ItemsDeleteIDs(ids []string) (itemids []interface{}, err error)
- func (api *API) ItemsGet(params Params) (res Items, err error)
- func (api *API) ItemsGetByApplicationID(id string) (res Items, err error)
- func (api *API) ItemsUpdate(items Items) (err error)
- func (api *API) LLDDeleteByIds(ids []string) (err error)
- func (api *API) LLDDeleteIDs(ids []string) (itemids []interface{}, err error)
- func (api *API) LLDGetByID(id string) (res *LLDRule, err error)
- func (api *API) LLDsCreate(items LLDRules) (err error)
- func (api *API) LLDsDelete(items LLDRules) (err error)
- func (api *API) LLDsGet(params Params) (res LLDRules, err error)
- func (api *API) LLDsUpdate(items LLDRules) (err error)
- func (api *API) Login(user, password string) (auth string, err error)
- func (api *API) MacroGetByID(id string) (res *Macro, err error)
- func (api *API) MacrosCreate(macros Macros) error
- func (api *API) MacrosDelete(macros Macros) (err error)
- func (api *API) MacrosDeleteByIDs(ids []string) (err error)
- func (api *API) MacrosGet(params Params) (res Macros, err error)
- func (api *API) MacrosUpdate(macros Macros) (err error)
- func (api *API) ProtoItemGetByID(id string) (res *Item, err error)
- func (api *API) ProtoItemsCreate(items Items) (err error)
- func (api *API) ProtoItemsDelete(items Items) (err error)
- func (api *API) ProtoItemsDeleteByIds(ids []string) (err error)
- func (api *API) ProtoItemsDeleteIDs(ids []string) (itemids []interface{}, err error)
- func (api *API) ProtoItemsGet(params Params) (res Items, err error)
- func (api *API) ProtoItemsGetByApplicationID(id string) (res Items, err error)
- func (api *API) ProtoItemsUpdate(items Items) (err error)
- func (api *API) ProtoTriggerGetByID(id string) (res *Trigger, err error)
- func (api *API) ProtoTriggersCreate(triggers Triggers) (err error)
- func (api *API) ProtoTriggersDelete(triggers Triggers) (err error)
- func (api *API) ProtoTriggersDeleteByIds(ids []string) (err error)
- func (api *API) ProtoTriggersDeleteIDs(ids []string) (triggerids []interface{}, err error)
- func (api *API) ProtoTriggersGet(params Params) (res Triggers, err error)
- func (api *API) ProtoTriggersUpdate(triggers Triggers) (err error)
- func (api *API) ProxiesCreate(Proxies Proxies) (err error)
- func (api *API) ProxiesDelete(Proxies Proxies) (err error)
- func (api *API) ProxiesDeleteByIds(ids []string) (err error)
- func (api *API) ProxiesGet(params Params) (res Proxies, err error)
- func (api *API) ProxiesUpdate(Proxies Proxies) (err error)
- func (api *API) ProxyGetByID(id string) (res *Proxy, err error)
- func (api *API) SetClient(c *http.Client)
- func (api *API) TemplateGetByID(id string) (template *Template, err error)
- func (api *API) TemplatesCreate(templates Templates) (err error)
- func (api *API) TemplatesDelete(templates Templates) (err error)
- func (api *API) TemplatesDeleteByIds(ids []string) (err error)
- func (api *API) TemplatesGet(params Params) (res Templates, err error)
- func (api *API) TemplatesUpdate(templates Templates) (err error)
- func (api *API) Token(token string) (ok string, err error)
- func (api *API) TriggerGetByID(id string) (res *Trigger, err error)
- func (api *API) TriggersCreate(triggers Triggers) (err error)
- func (api *API) TriggersDelete(triggers Triggers) (err error)
- func (api *API) TriggersDeleteByIds(ids []string) (err error)
- func (api *API) TriggersDeleteIDs(ids []string) (triggerids []interface{}, err error)
- func (api *API) TriggersGet(params Params) (res Triggers, err error)
- func (api *API) TriggersUpdate(triggers Triggers) (err error)
- func (api *API) UserGetByID(id string) (res *User, err error)
- func (api *API) UserGroupGetByID(id string) (res *UserGroup, err error)
- func (api *API) UserGroupsCreate(UserGroups UserGroups) (err error)
- func (api *API) UserGroupsDelete(UserGroups UserGroups) (err error)
- func (api *API) UserGroupsDeleteByIds(ids []string) (err error)
- func (api *API) UserGroupsGet(params Params) (res UserGroups, err error)
- func (api *API) UserGroupsUpdate(UserGroups UserGroups) (err error)
- func (api *API) UsersCreate(Users Users) (err error)
- func (api *API) UsersDelete(Users Users) (err error)
- func (api *API) UsersDeleteByIds(ids []string) (err error)
- func (api *API) UsersGet(params Params) (res Users, err error)
- func (api *API) UsersUpdate(Users Users) (err error)
- func (api *API) Version() (v string, err error)
- type Application
- type Applications
- type AvailableType
- type Config
- type DataType
- type DeltaType
- type Error
- type ExpectedMore
- type ExpectedOneResult
- type Graph
- type GraphAxis
- type GraphItem
- type GraphItemDraw
- type GraphItemFunc
- type GraphItemSide
- type GraphItemType
- type GraphItems
- type GraphType
- type Graphs
- type Host
- type HostGroup
- type HostGroupID
- type HostGroupIDs
- type HostGroups
- type HostInterface
- type HostInterfaceDetail
- type HostInterfaceDetails
- type HostInterfaces
- type Hosts
- type HttpHeaders
- type InterfaceType
- type InternalType
- type Inventory
- type InventoryMode
- type Item
- type ItemType
- type Items
- type LLDEvalType
- type LLDMacroPath
- type LLDMacroPaths
- type LLDOperatorType
- type LLDRule
- type LLDRuleFilter
- type LLDRuleFilterCondition
- type LLDRuleFilterConditions
- type LLDRules
- type Macro
- type Macros
- type Params
- type Preprocessor
- type Preprocessors
- type Proxies
- type Proxy
- type RawResponse
- type Response
- type SeverityType
- type StatusType
- type Tag
- type Tags
- type Template
- type TemplateID
- type TemplateIDs
- type Templates
- type Trigger
- type TriggerFunction
- type TriggerFunctions
- type TriggerID
- type TriggerIDs
- type Triggers
- type User
- type UserGroup
- type UserGroupID
- type UserGroupPermission
- type UserGroups
- type UserID
- type Users
- type ValueType
Constants ¶
const ( GraphNormal GraphType = "0" GraphStacked GraphType = "1" GraphPie GraphType = "2" GraphExploded GraphType = "3" GraphAxisCalculated GraphAxis = "0" GraphAxisFixed GraphAxis = "1" GraphAxisItem GraphAxis = "2" GraphItemMin GraphItemFunc = "1" GraphItemAvg GraphItemFunc = "2" GraphItemMax GraphItemFunc = "4" GraphItemAll GraphItemFunc = "7" GraphItemLast GraphItemFunc = "9" GraphItemLine GraphItemDraw = "0" GraphItemFilled GraphItemDraw = "1" GraphItemBold GraphItemDraw = "2" GraphItemDot GraphItemDraw = "3" GraphItemDashed GraphItemDraw = "4" GraphItemGradient GraphItemDraw = "5" GraphItemSimple GraphItemType = "0" GraphItemSum GraphItemType = "2" GraphItemLeft GraphItemSide = "0" GraphItemRight GraphItemSide = "1" )
const ( LLDAndOr LLDEvalType = "0" LLDAnd LLDEvalType = "1" LLDOr LLDEvalType = "2" LLDCustom LLDEvalType = "3" LLDMatch LLDOperatorType = "8" LLDNotMatch LLDOperatorType = "9" )
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 UserAgent string Config Config // contains filtered or unexported fields }
API use to store connection information
func NewAPI ¶
NewAPI 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) ApplicationGetByHostIDAndName ¶
func (api *API) ApplicationGetByHostIDAndName(hostID, name string) (res *Application, err error)
ApplicationGetByHostIDAndName Gets application by host Id and name only if there is exactly 1 matching application.
func (*API) ApplicationGetByID ¶
func (api *API) ApplicationGetByID(id string) (res *Application, err error)
ApplicationGetByID Gets application by Id only if there is exactly 1 matching application.
func (*API) ApplicationsCreate ¶
func (api *API) ApplicationsCreate(apps Applications) (err error)
ApplicationsCreate Wrapper for application.create https://www.zabbix.com/documentation/3.2/manual/api/reference/application/create
func (*API) ApplicationsDelete ¶
func (api *API) ApplicationsDelete(apps Applications) (err error)
ApplicationsDelete Wrapper for application.delete: Cleans ApplicationID in all apps elements if call succeed. https://www.zabbix.com/documentation/2.2/manual/appendix/api/application/delete
func (*API) ApplicationsDeleteByIds ¶
ApplicationsDeleteByIds Wrapper for application.delete https://www.zabbix.com/documentation/2.2/manual/appendix/api/application/delete
func (*API) ApplicationsGet ¶
func (api *API) ApplicationsGet(params Params) (res Applications, err error)
ApplicationsGet Wrapper for application.get https://www.zabbix.com/documentation/3.2/manual/api/reference/application/get
func (*API) Call ¶
Call 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 ¶
CallWithError Uses Call() and then sets err to response.Error if former is nil and latter is not.
func (*API) CallWithErrorParse ¶
func (api *API) CallWithErrorParse(method string, params interface{}, result interface{}) (err error)
CallWithErrorParse Calls specified API method. Parse the response of the api in the result variable.
func (*API) GraphGetByID ¶
GraphGetByID Gets host group by Id only if there is exactly 1 matching host group.
func (*API) GraphProtoGetByID ¶
func (*API) GraphProtosCreate ¶
func (*API) GraphProtosDelete ¶
func (*API) GraphProtosDeleteByIds ¶
func (*API) GraphProtosUpdate ¶
func (*API) GraphsCreate ¶
GraphsCreate Wrapper for graph.create https://www.zabbix.com/documentation/3.2/manual/api/reference/graph/create
func (*API) GraphsDelete ¶
HostGroupsDelete Wrapper for hostgroup.delete Cleans GroupId in all hostGroups elements if call succeed. https://www.zabbix.com/documentation/3.2/manual/api/reference/hostgroup/delete
func (*API) GraphsDeleteByIds ¶
HostGroupsDeleteByIds Wrapper for hostgroup.delete https://www.zabbix.com/documentation/3.2/manual/api/reference/hostgroup/delete
func (*API) GraphsGet ¶
GraphsGet Wrapper for graph.get https://www.zabbix.com/documentation/3.2/manual/api/reference/graph/get
func (*API) GraphsUpdate ¶
GraphsUpdate Wrapper for graph.update https://www.zabbix.com/documentation/3.2/manual/api/reference/graph/update
func (*API) HostGetByHost ¶
HostGetByHost Gets host by Host only if there is exactly 1 matching host.
func (*API) HostGetByID ¶
HostGetByID Gets host by Id only if there is exactly 1 matching host.
func (*API) HostGroupGetByID ¶
HostGroupGetByID Gets host group by Id only if there is exactly 1 matching host group.
func (*API) HostGroupsCreate ¶
func (api *API) HostGroupsCreate(hostGroups HostGroups) (err error)
HostGroupsCreate Wrapper for hostgroup.create https://www.zabbix.com/documentation/3.2/manual/api/reference/hostgroup/create
func (*API) HostGroupsDelete ¶
func (api *API) HostGroupsDelete(hostGroups HostGroups) (err error)
HostGroupsDelete Wrapper for hostgroup.delete Cleans GroupId in all hostGroups elements if call succeed. https://www.zabbix.com/documentation/3.2/manual/api/reference/hostgroup/delete
func (*API) HostGroupsDeleteByIds ¶
HostGroupsDeleteByIds Wrapper for hostgroup.delete https://www.zabbix.com/documentation/3.2/manual/api/reference/hostgroup/delete
func (*API) HostGroupsGet ¶
func (api *API) HostGroupsGet(params Params) (res HostGroups, err error)
HostGroupsGet Wrapper for hostgroup.get https://www.zabbix.com/documentation/3.2/manual/api/reference/hostgroup/get
func (*API) HostGroupsUpdate ¶
func (api *API) HostGroupsUpdate(hostGroups HostGroups) (err error)
HostGroupsUpdate Wrapper for hostgroup.update https://www.zabbix.com/documentation/3.2/manual/api/reference/hostgroup/update
func (*API) HostsCreate ¶
HostsCreate Wrapper for host.create https://www.zabbix.com/documentation/3.2/manual/api/reference/host/create
func (*API) HostsDelete ¶
HostsDelete Wrapper for host.delete Cleans HostId in all hosts elements if call succeed. https://www.zabbix.com/documentation/3.2/manual/api/reference/host/delete
func (*API) HostsDeleteByIds ¶
HostsDeleteByIds Wrapper for host.delete https://www.zabbix.com/documentation/3.2/manual/api/reference/host/delete
func (*API) HostsGet ¶
HostsGet Wrapper for host.get https://www.zabbix.com/documentation/3.2/manual/api/reference/host/get
func (*API) HostsGetByHostGroupIds ¶
HostsGetByHostGroupIds Gets hosts by host group Ids.
func (*API) HostsGetByHostGroups ¶
func (api *API) HostsGetByHostGroups(hostGroups HostGroups) (res Hosts, err error)
HostsGetByHostGroups Gets hosts by host groups.
func (*API) HostsUpdate ¶
HostsUpdate Wrapper for host.update https://www.zabbix.com/documentation/3.2/manual/api/reference/host/update
func (*API) ItemGetByID ¶
ItemGetByID Gets item by Id only if there is exactly 1 matching host.
func (*API) ItemsCreate ¶
ItemsCreate Wrapper for item.create https://www.zabbix.com/documentation/3.2/manual/api/reference/item/create
func (*API) ItemsDelete ¶
ItemsDelete Wrapper for item.delete Cleans ItemId in all items elements if call succeed. https://www.zabbix.com/documentation/3.2/manual/api/reference/item/delete
func (*API) ItemsDeleteByIds ¶
ItemsDeleteByIds Wrapper for item.delete https://www.zabbix.com/documentation/3.2/manual/api/reference/item/delete
func (*API) ItemsDeleteIDs ¶
ItemsDeleteIDs Wrapper for item.delete Delete the item and return the id of the deleted item
func (*API) ItemsGet ¶
ItemsGet Wrapper for item.get https://www.zabbix.com/documentation/3.2/manual/api/reference/item/get
func (*API) ItemsGetByApplicationID ¶
ItemsGetByApplicationID Gets items by application Id.
func (*API) ItemsUpdate ¶
ItemsUpdate Wrapper for item.update https://www.zabbix.com/documentation/3.2/manual/api/reference/item/update
func (*API) LLDDeleteByIds ¶
ItemsDeleteByIds Wrapper for item.delete https://www.zabbix.com/documentation/3.2/manual/api/reference/item/delete
func (*API) LLDDeleteIDs ¶
ItemsDeleteIDs Wrapper for item.delete Delete the item and return the id of the deleted item
func (*API) LLDGetByID ¶
ItemGetByID Gets item by Id only if there is exactly 1 matching host.
func (*API) LLDsCreate ¶
ItemsCreate Wrapper for item.create https://www.zabbix.com/documentation/3.2/manual/api/reference/item/create
func (*API) LLDsDelete ¶
ItemsDelete Wrapper for item.delete Cleans ItemId in all items elements if call succeed. https://www.zabbix.com/documentation/3.2/manual/api/reference/item/delete
func (*API) LLDsGet ¶
ItemsGet Wrapper for item.get https://www.zabbix.com/documentation/3.2/manual/api/reference/item/get
func (*API) LLDsUpdate ¶
ItemsUpdate Wrapper for item.update https://www.zabbix.com/documentation/3.2/manual/api/reference/item/update
func (*API) Login ¶
Login 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) MacroGetByID ¶
MacroGetByID Get macro by macro ID if there is exactly 1 matching macro
func (*API) MacrosCreate ¶
MacrosCreate Wrapper for usermacro.create https://www.zabbix.com/documentation/3.2/manual/api/reference/usermacro/create
func (*API) MacrosDelete ¶
MacrosDelete Wrapper for usermacro.delete https://www.zabbix.com/documentation/3.2/manual/api/reference/usermacro/delete
func (*API) MacrosDeleteByIDs ¶
MacrosDeleteByIDs Wrapper for usermacro.delete Cleans MacroId in all macro elements if call succeed. https://www.zabbix.com/documentation/3.2/manual/api/reference/usermacro/delete
func (*API) MacrosGet ¶
MacrosGet Wrapper for usermacro.get https://www.zabbix.com/documentation/3.2/manual/api/reference/usermacro/get
func (*API) MacrosUpdate ¶
MacrosUpdate Wrapper for usermacro.update https://www.zabbix.com/documentation/3.2/manual/api/reference/usermacro/update
func (*API) ProtoItemsCreate ¶
func (*API) ProtoItemsDelete ¶
func (*API) ProtoItemsDeleteByIds ¶
func (*API) ProtoItemsDeleteIDs ¶
func (*API) ProtoItemsGetByApplicationID ¶
func (*API) ProtoItemsUpdate ¶
func (*API) ProtoTriggerGetByID ¶
func (*API) ProtoTriggersCreate ¶
func (*API) ProtoTriggersDelete ¶
func (*API) ProtoTriggersDeleteByIds ¶
func (*API) ProtoTriggersDeleteIDs ¶
func (*API) ProtoTriggersGet ¶
func (*API) ProtoTriggersUpdate ¶
func (*API) ProxiesCreate ¶
ProxiesCreate Wrapper for proxy.create https://www.zabbix.com/documentation/current/en/manual/api/reference/proxy/create
func (*API) ProxiesDelete ¶
ProxiesDelete Wrapper for proxy.delete Cleans ProxyID in all Proxies elements if call succeed. https://www.zabbix.com/documentation/current/en/manual/api/reference/proxy/delete
func (*API) ProxiesDeleteByIds ¶
ProxiesDeleteByIds Wrapper for proxy.delete https://www.zabbix.com/documentation/current/en/manual/api/reference/proxy/delete
func (*API) ProxiesGet ¶
ProxiesGet Wrapper for proxy.get https://www.zabbix.com/documentation/current/en/manual/api/reference/proxy/get
func (*API) ProxiesUpdate ¶
ProxiesUpdate Wrapper for proxy.update https://www.zabbix.com/documentation/current/en/manual/api/reference/proxy/update
func (*API) ProxyGetByID ¶
ProxyGetByID Gets user by Id only if there is exactly 1 matching proxy.
func (*API) SetClient ¶
SetClient Allows one to use specific http.Client, for example with InsecureSkipVerify transport.
func (*API) TemplateGetByID ¶
TemplateGetByID Gets template by Id only if there is exactly 1 matching template.
func (*API) TemplatesCreate ¶
TemplatesCreate Wrapper for template.create https://www.zabbix.com/documentation/3.2/manual/api/reference/template/create
func (*API) TemplatesDelete ¶
TemplatesDelete Wrapper for template.delete Cleans ApplicationID in all apps elements if call succeed. https://www.zabbix.com/documentation/3.2/manual/api/reference/template/delete
func (*API) TemplatesDeleteByIds ¶
TemplatesDeleteByIds Wrapper for template.delete Use template's id to delete the template https://www.zabbix.com/documentation/3.2/manual/api/reference/template/delete
func (*API) TemplatesGet ¶
TemplatesGet Wrapper for template.get https://www.zabbix.com/documentation/3.2/manual/api/reference/template/get
func (*API) TemplatesUpdate ¶
TemplatesUpdate Wrapper for template.update https://www.zabbix.com/documentation/3.2/manual/api/reference/template/update
func (*API) Token ¶
Set API token only This method modifies API structure and should not be called concurrently with other methods.
func (*API) TriggerGetByID ¶
TriggerGetByID Gets trigger by Id only if there is exactly 1 matching host.
func (*API) TriggersCreate ¶
TriggersCreate Wrapper for trigger.create https://www.zabbix.com/documentation/3.2/manual/api/reference/trigger/create
func (*API) TriggersDelete ¶
TriggersDelete Wrapper for trigger.delete Cleans ItemId in all triggers elements if call succeed. https://www.zabbix.com/documentation/3.2/manual/api/reference/trigger/delete
func (*API) TriggersDeleteByIds ¶
TriggersDeleteByIds Wrapper for trigger.delete https://www.zabbix.com/documentation/3.2/manual/api/reference/trigger/delete
func (*API) TriggersDeleteIDs ¶
TriggersDeleteIDs Wrapper for trigger.delete return the id of the deleted trigger
func (*API) TriggersGet ¶
TriggersGet Wrapper for trigger.get https://www.zabbix.com/documentation/3.2/manual/api/reference/trigger/get
func (*API) TriggersUpdate ¶
TriggersUpdate Wrapper for trigger.update https://www.zabbix.com/documentation/3.2/manual/api/reference/trigger/update
func (*API) UserGetByID ¶
UserGetByID Gets user by Id only if there is exactly 1 matching user.
func (*API) UserGroupGetByID ¶
UserGroupGetByID Gets usergroup by Id only if there is exactly 1 matching usergroup.
func (*API) UserGroupsCreate ¶
func (api *API) UserGroupsCreate(UserGroups UserGroups) (err error)
UserGroupsCreate Wrapper for usergroup.create https://www.zabbix.com/documentation/current/en/manual/api/reference/usergroup/create
func (*API) UserGroupsDelete ¶
func (api *API) UserGroupsDelete(UserGroups UserGroups) (err error)
UserGroupsDelete Wrapper for usergroup.delete Cleans UserGroupID in all UserGroups elements if call succeed. https://www.zabbix.com/documentation/current/en/manual/api/reference/usergroup/delete
func (*API) UserGroupsDeleteByIds ¶
UserGroupsDeleteByIds Wrapper for usergroup.delete https://www.zabbix.com/documentation/current/en/manual/api/reference/usergroup/delete
func (*API) UserGroupsGet ¶
func (api *API) UserGroupsGet(params Params) (res UserGroups, err error)
UserGroupsGet Wrapper for usergroup.get https://www.zabbix.com/documentation/current/en/manual/api/reference/usergroup/get
func (*API) UserGroupsUpdate ¶
func (api *API) UserGroupsUpdate(UserGroups UserGroups) (err error)
UserGroupsUpdate Wrapper for usergroup.update https://www.zabbix.com/documentation/current/en/manual/api/reference/usergroup/update
func (*API) UsersCreate ¶
UsersCreate Wrapper for user.create https://www.zabbix.com/documentation/current/en/manual/api/reference/user/create
func (*API) UsersDelete ¶
UsersDelete Wrapper for user.delete Cleans UserID in all Users elements if call succeed. https://www.zabbix.com/documentation/current/en/manual/api/reference/user/delete
func (*API) UsersDeleteByIds ¶
UsersDeleteByIds Wrapper for user.delete https://www.zabbix.com/documentation/current/en/manual/api/reference/user/delete
func (*API) UsersGet ¶
UsersGet Wrapper for user.get https://www.zabbix.com/documentation/current/en/manual/api/reference/user/get
func (*API) UsersUpdate ¶
UsersUpdate Wrapper for user.update https://www.zabbix.com/documentation/current/en/manual/api/reference/user/update
type Application ¶
type Application struct { ApplicationID string `json:"applicationid,omitempty"` HostID string `json:"hostid"` Name string `json:"name"` TemplateID string `json:"templateid,omitempty"` }
Application represent Zabbix application object https://www.zabbix.com/documentation/3.2/manual/api/reference/application/object
type AvailableType ¶
type AvailableType int
AvailableType (readonly) Availability of Zabbix agent see "available" in: https://www.zabbix.com/documentation/3.2/manual/api/reference/host/object
const ( // Unknown (default) Unknown AvailableType = 0 // Available host is available Available AvailableType = 1 Unavailable AvailableType = 2 )
type Error ¶
type Error struct { Code int `json:"code"` Message string `json:"message"` Data string `json:"data"` }
Error contains error data and code
type ExpectedMore ¶
ExpectedMore use to generate error when you expect more element
func (*ExpectedMore) Error ¶
func (e *ExpectedMore) Error() string
type ExpectedOneResult ¶
type ExpectedOneResult int
ExpectedOneResult use to generate error when you expect one result
func (*ExpectedOneResult) Error ¶
func (e *ExpectedOneResult) Error() string
type Graph ¶
type Graph struct { GraphID string `json:"graphid,omitempty"` Name string `json:"name"` Height string `json:"height"` Width string `json:"width"` Type GraphType `json:"graphtype,omitempty"` PercentLeft string `json:"percent_left,omitempty"` PercentRight string `json:"percent_right,omitempty"` Show3d string `json:"show_3d,omitempty"` ShowLegend string `json:"show_legend,omitempty"` ShowWorkPeriod string `json:"show_work_period,omitempty"` YMax string `json:"yaxismax,omitempty"` YMaxItemId string `json:"ymax_itemid,omitempty"` YMaxType GraphAxis `json:"ymax_type,omitempty"` YMin string `json:"yaxismin,omitempty"` YMinItemId string `json:"ymin_itemid,omitempty"` YMinType GraphAxis `json:"ymin_type,omitempty"` GraphItems GraphItems `json:"gitems,omitempty"` }
Graph represent Zabbix Graph object https://www.zabbix.com/documentation/3.2/manual/api/reference/graph/object
type GraphItem ¶
type GraphItem struct { GItemID string `json:"gitemid,omitempty"` GraphID string `json:"graphid,omitempty"` Color string `json:"color"` ItemID string `json:"itemid"` CalcFunc GraphItemFunc `json:"calc_fnc,omitempty"` DrawType GraphItemDraw `json:"drawtype,omitempty"` SortOrder string `json:"sortorder,omitempty"` Type GraphItemType `json:"type,omitempty"` YAxisSide GraphItemSide `json:"yaxisside,omitempty"` }
type GraphItemDraw ¶
type GraphItemDraw string
type GraphItemFunc ¶
type GraphItemFunc string
type GraphItemSide ¶
type GraphItemSide string
type GraphItemType ¶
type GraphItemType string
type GraphItems ¶
type GraphItems []GraphItem
type Host ¶
type Host struct { HostID string `json:"hostid,omitempty"` Host string `json:"host"` Available AvailableType `json:"available,string"` Error string `json:"error"` Name string `json:"name"` Status StatusType `json:"status,string"` UserMacros Macros `json:"macros,omitempty"` RawInventory json.RawMessage `json:"inventory,omitempty"` Inventory Inventory `json:"-"` RawInventoryMode *InventoryMode `json:"inventory_mode,string,omitempty"` InventoryMode InventoryMode `json:"-"` // Fields below used only when creating hosts GroupIds HostGroupIDs `json:"groups,omitempty"` Interfaces HostInterfaces `json:"interfaces,omitempty"` TemplateIDs TemplateIDs `json:"templates,omitempty"` TemplateIDsClear TemplateIDs `json:"templates_clear,omitempty"` // templates are read back from this one ParentTemplateIDs TemplateIDs `json:"parentTemplates,omitempty"` ProxyID string `json:"proxy_hostid,omitempty"` Tags Tags `json:"tags,omitempty"` }
Host represent Zabbix host object https://www.zabbix.com/documentation/3.2/manual/api/reference/host/object
type HostGroup ¶
type HostGroup struct { GroupID string `json:"groupid,omitempty"` Name string `json:"name"` Internal InternalType `json:"internal,omitempty,string"` }
HostGroup represent Zabbix host group object https://www.zabbix.com/documentation/3.2/manual/api/reference/hostgroup/object
type HostGroupID ¶
type HostGroupID struct {
GroupID string `json:"groupid"`
}
HostGroupID represent Zabbix GroupID
type HostInterface ¶
type HostInterface struct { InterfaceID string `json:"interfaceid,omitempty"` DNS string `json:"dns"` IP string `json:"ip"` Main string `json:"main"` Port string `json:"port"` Type InterfaceType `json:"type"` UseIP string `json:"useip"` RawDetails json.RawMessage `json:"details,omitempty"` Details *HostInterfaceDetail `json:"-"` }
HostInterface represents zabbix host interface type https://www.zabbix.com/documentation/3.2/manual/api/reference/hostinterface/object
type HostInterfaceDetail ¶
type HostInterfaceDetail struct { Version string `json:"version,omitempty"` Bulk string `json:"bulk,omitempty"` Community string `json:"community,omitempty"` SecurityName string `json:"securityname,omitempty"` SecurityLevel string `json:"securitylevel,omitempty"` AuthPassphrase string `json:"authpassphrase,omitempty"` PrivPassphrase string `json:"privpassphrase,omitempty"` AuthProtocol string `json:"authprotocol,omitempty"` PrivProtocol string `json:"privprotocol,omitempty"` ContextName string `json:"contextname,omitempty"` }
type HostInterfaceDetails ¶
type HostInterfaceDetails []HostInterfaceDetail
type HostInterfaces ¶
type HostInterfaces []HostInterface
HostInterfaces is an array of HostInterface
type HttpHeaders ¶
type InterfaceType ¶
type InterfaceType string
InterfaceType different interface type
const ( // Agent type Agent InterfaceType = "1" // SNMP type SNMP InterfaceType = "2" // IPMI type IPMI InterfaceType = "3" // JMX type JMX InterfaceType = "4" )
type InternalType ¶
type InternalType int
InternalType (readonly) Whether the group is used internally by the system. An internal group cannot be deleted. see "internal" in https://www.zabbix.com/documentation/3.2/manual/api/reference/hostgroup/object
const ( // NotInternal (default) not internal NotInternal InternalType = 0 // Internal internal Internal InternalType = 1 )
type Inventory ¶
https://www.zabbix.com/documentation/5.0/manual/api/reference/host/object#host_inventory
type InventoryMode ¶
type InventoryMode int
const ( InventoryDisabled InventoryMode = -1 InventoryManual InventoryMode = 0 InventoryAutomatic InventoryMode = 1 )
type Item ¶
type Item struct { ItemID string `json:"itemid,omitempty"` Delay string `json:"delay"` HostID string `json:"hostid"` InterfaceID string `json:"interfaceid,omitempty"` Key string `json:"key_"` Name string `json:"name"` Type ItemType `json:"type,string"` ValueType ValueType `json:"value_type,string"` // DataType DataType `json:"data_type,string"` // Delta DeltaType `json:"delta,string"` Description string `json:"description"` Error string `json:"error,omitempty"` History string `json:"history,omitempty"` Trends string `json:"trends,omitempty"` TrapperHosts string `json:"trapper_hosts,omitempty"` Params string `json:"params,omitempty"` // list of strings on set, but list of objects on get RawApplications json.RawMessage `json:"applications,omitempty"` Applications []string `json:"-"` Preprocessors Preprocessors `json:"preprocessing,omitempty"` // HTTP Agent Fields Url string `json:"url,omitempty"` RequestMethod string `json:"request_method,omitempty"` PostType string `json:"post_type,omitempty"` RetrieveMode string `json:"retrieve_mode,omitempty"` Posts string `json:"posts,omitempty"` StatusCodes string `json:"status_codes,omitempty"` Timeout string `json:"timeout,omitempty"` VerifyHost string `json:"verify_host,omitempty"` VerifyPeer string `json:"verify_peer,omitempty"` AuthType string `json:"authtype,omitempty"` Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` Headers HttpHeaders `json:"-"` RawHeaders json.RawMessage `json:"headers,omitempty"` Proxy string `json:"http_proxy,omitempty"` FollowRedirects string `json:"follow_redirects,omitempty"` // SNMP Fields SNMPOid string `json:"snmp_oid,omitempty"` SNMPCommunity string `json:"snmp_community,omitempty"` SNMPv3AuthPassphrase string `json:"snmpv3_authpassphrase,omitempty"` SNMPv3AuthProtocol string `json:"snmpv3_authprotocol,omitempty"` SNMPv3ContextName string `json:"snmpv3_contextname,omitempty"` SNMPv3PrivPasshrase string `json:"snmpv3_privpassphrase,omitempty"` SNMPv3PrivProtocol string `json:"snmpv3_privprotocol,omitempty"` SNMPv3SecurityLevel string `json:"snmpv3_securitylevel,omitempty"` SNMPv3SecurityName string `json:"snmpv3_securityname,omitempty"` // Dependent Fields MasterItemID string `json:"master_itemid,omitempty"` // Prototype RuleID string `json:"ruleid,omitempty"` DiscoveryRule *LLDRule `json:"discoveryRule,omitEmpty"` Tags Tags `json:"tags,omitempty"` }
Item represent Zabbix item object https://www.zabbix.com/documentation/3.2/manual/api/reference/item/object
type ItemType ¶
type ItemType int
ItemType type of the item
const ( // ZabbixAgent type ZabbixAgent ItemType = 0 // SNMPv1Agent type SNMPv1Agent ItemType = 1 // ZabbixTrapper type ZabbixTrapper ItemType = 2 // SimpleCheck type SimpleCheck ItemType = 3 // SNMPv2Agent type SNMPv2Agent ItemType = 4 // ZabbixInternal type ZabbixInternal ItemType = 5 // SNMPv3Agent type SNMPv3Agent ItemType = 6 // ZabbixAgentActive type ZabbixAgentActive ItemType = 7 // ZabbixAggregate type ZabbixAggregate ItemType = 8 // WebItem type WebItem ItemType = 9 // ExternalCheck type ExternalCheck ItemType = 10 // DatabaseMonitor type DatabaseMonitor ItemType = 11 //IPMIAgent type IPMIAgent ItemType = 12 // SSHAgent type SSHAgent ItemType = 13 // TELNETAgent type TELNETAgent ItemType = 14 // Calculated type Calculated ItemType = 15 // JMXAgent type JMXAgent ItemType = 16 SNMPTrap ItemType = 17 Dependent ItemType = 18 HTTPAgent ItemType = 19 SNMPAgent ItemType = 20 )
type LLDEvalType ¶
type LLDEvalType string
type LLDMacroPath ¶
type LLDMacroPaths ¶
type LLDMacroPaths []LLDMacroPath
type LLDOperatorType ¶
type LLDOperatorType string
type LLDRule ¶
type LLDRule struct { ItemID string `json:"itemid,omitempty"` Delay string `json:"delay"` HostID string `json:"hostid"` InterfaceID string `json:"interfaceid,omitempty"` Key string `json:"key_"` Name string `json:"name"` Type ItemType `json:"type,string"` // ValueType ValueType `json:"value_type,string"` // DataType DataType `json:"data_type,string"` // Delta DeltaType `json:"delta,string"` AuthType string `json:"authtype,omitempty"` DelayFlex string `json:"delay_flex,omitempty"` Description string `json:"description"` Error string `json:"error,omitempty"` IpmiSensor string `json:"ipmi_sensor,omitempty"` LifeTime string `json:"lifetime,omitempty"` Params string `json:"params,omitempty"` PrivateKey string `json:"privatekey,omitempty"` PublicKey string `json:"publickey,omitempty"` Status string `json:"status,omitempty"` TrapperHosts string `json:"trapper_hosts,omitempty"` MasterItemID string `json:"master_itemid,omitempty"` // ssh / telnet Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` Port string `json:"port,omitempty"` // HTTP Agent Fields Url string `json:"url,omitempty"` RequestMethod string `json:"request_method,omitempty"` AllowTraps string `json:"allow_traps,omitempty"` PostType string `json:"post_type,omitempty"` RetrieveMode string `json:"retrieve_mode,omitempty"` Posts string `json:"posts,omitempty"` StatusCodes string `json:"status_codes,omitempty"` Timeout string `json:"timeout,omitempty"` VerifyHost string `json:"verify_host,omitempty"` VerifyPeer string `json:"verify_peer,omitempty"` Headers HttpHeaders `json:"-"` RawHeaders json.RawMessage `json:"headers,omitempty"` Proxy string `json:"http_proxy,omitempty"` FollowRedirects string `json:"follow_redirects,omitempty"` // SNMP Fields SNMPOid string `json:"snmp_oid,omitempty"` SNMPCommunity string `json:"snmp_community,omitempty"` SNMPv3AuthPassphrase string `json:"snmpv3_authpassphrase,omitempty"` SNMPv3AuthProtocol string `json:"snmpv3_authprotocol,omitempty"` SNMPv3ContextName string `json:"snmpv3_contextname,omitempty"` SNMPv3PrivPasshrase string `json:"snmpv3_privpassphrase,omitempty"` SNMPv3PrivProtocol string `json:"snmpv3_privprotocol,omitempty"` SNMPv3SecurityLevel string `json:"snmpv3_securitylevel,omitempty"` SNMPv3SecurityName string `json:"snmpv3_securityname,omitempty"` Preprocessors Preprocessors `json:"preprocessing,omitempty"` Filter LLDRuleFilter `json:"filter"` MacroPaths LLDMacroPaths `json:"lld_macro_paths,omitempty"` }
Item represent Zabbix lld object https://www.zabbix.com/documentation/3.2/manual/api/reference/item/object
type LLDRuleFilter ¶
type LLDRuleFilter struct { Conditions LLDRuleFilterConditions `json:"conditions"` EvalType LLDEvalType `json:"evaltype"` EvalFormula string `json:"eval_formula,omitempty"` Formula string `json:"formula"` }
type LLDRuleFilterCondition ¶
type LLDRuleFilterCondition struct { Macro string `json:"macro"` Value string `json:"value"` FormulaID string `json:"formulaid,omitempty"` Operator LLDOperatorType `json:"operator,omitempty"` }
type LLDRuleFilterConditions ¶
type LLDRuleFilterConditions []LLDRuleFilterCondition
type Macro ¶
type Macro struct { MacroID string `json:"hostmacroids,omitempty"` HostID string `json:"hostid,omitempty"` MacroName string `json:"macro"` Value string `json:"value"` }
Macro represent Zabbix User MAcro object https://www.zabbix.com/documentation/3.2/manual/api/reference/usermacro/object
type Preprocessor ¶
type Preprocessors ¶
type Preprocessors []Preprocessor
type Proxy ¶
type Proxy struct { ProxyID string `json:"proxyid,omitempty"` Name string `json:"name"` OperatingMode int `json:"operating_mode,string"` Description string `json:"description,omitempty"` TLSConnect int `json:"tls_connect,omitempty,string"` TLSAccept int `json:"tls_accept,omitempty,string"` TLSIssuer string `json:"tls_issuer,omitempty"` TLSSubject string `json:"tls_subject,omitempty"` TLSPSKIdentity string `json:"tls_psk_identity,omitempty"` TLSPSK string `json:"tls_psk,omitempty"` ProxyAddress string `json:"proxy_address,omitempty"` }
Proxy represent Zabbix proxy object https://www.zabbix.com/documentation/current/en/manual/api/reference/proxy/object#proxy
type RawResponse ¶
type RawResponse struct { Jsonrpc string `json:"jsonrpc"` Error *Error `json:"error"` Result json.RawMessage `json:"result"` ID int32 `json:"id"` }
RawResponse format of zabbix api
type Response ¶
type Response struct { Jsonrpc string `json:"jsonrpc"` Error *Error `json:"error"` Result interface{} `json:"result"` ID int32 `json:"id"` }
Response format of zabbix api
type SeverityType ¶
type SeverityType int
SeverityType of a trigger Zabbix severity see : https://www.zabbix.com/documentation/3.2/manual/api/reference/trigger/object
const ( // NotClassified is Not classified severity NotClassified SeverityType = 0 // Information is Information severity Information SeverityType = 1 // Warning is Warning severity Warning SeverityType = 2 // Average is Average severity Average SeverityType = 3 // High is high severity High SeverityType = 4 // Critical is critical severity Critical SeverityType = 5 )
type StatusType ¶
type StatusType int
StatusType Status and function of the host. see "status" in: https://www.zabbix.com/documentation/3.2/manual/api/reference/host/object
const ( // Monitored monitored host(default) Monitored StatusType = 0 // Unmonitored unmonitored host Unmonitored StatusType = 1 )
const ( // Enabled trigger status enabled Enabled StatusType = 0 // Disabled trigger status disabled Disabled StatusType = 1 )
type Template ¶
type Template struct { TemplateID string `json:"templateid,omitempty"` Host string `json:"host"` Description string `json:"description,omitempty"` Name string `json:"name,omitempty"` Groups HostGroupIDs `json:"groups"` UserMacros Macros `json:"macros"` LinkedTemplates TemplateIDs `json:"templates,omitempty"` ParentTemplates TemplateIDs `json:"parentTemplates,omitempty"` TemplatesClear TemplateIDs `json:"templates_clear,omitempty"` LinkedHosts []string `json:"hosts,omitempty"` }
Template represent Zabbix Template type returned from Zabbix API https://www.zabbix.com/documentation/3.2/manual/api/reference/template/object
type TemplateID ¶
type TemplateID struct {
TemplateID string `json:"templateid"`
}
TemplateID use with host creation
type Trigger ¶
type Trigger struct { TriggerID string `json:"triggerid,omitempty"` Description string `json:"description"` Expression string `json:"expression"` Comments string `json:"comments"` Opdata string `json:"opdata,omitempty"` Type int `json:"type,string"` Url string `json:"url,omitempty"` RecoveryMode int `json:"recovery_mode,string"` RecoveryExpression string `json:"recovery_expression,omitempty"` CorrelationMode int `json:"correlation_mode,string"` CorrelationTag string `json:"correlation_tag,omitempty"` ManualClose int `json:"manual_close,string"` Priority SeverityType `json:"priority,string"` Status StatusType `json:"status,string"` Dependencies TriggerIDs `json:"dependencies,omitempty"` Functions TriggerFunctions `json:"functions,omitempty"` // Items contained by the trigger in the items property. ContainedItems Items `json:"items,omitempty"` // Hosts that the trigger belongs to in the hosts property. ParentHosts Hosts `json:"hosts,omitempty"` Tags Tags `json:"tags,omitempty"` }
Trigger represent Zabbix trigger object https://www.zabbix.com/documentation/3.2/manual/api/reference/trigger/object
type TriggerFunction ¶
type TriggerFunction struct { FunctionID string `json:"functionid"` ItemID string `json:"itemid"` Function string `json:"function"` Parameter string `json:"parameter"` }
TriggerFunction The function objects represents the functions used in the trigger expression
type TriggerFunctions ¶
type TriggerFunctions []TriggerFunction
TriggerFunctions is an array of TriggerFunction
type User ¶
type User struct { UserID string `json:"userid,omitempty"` Username string `json:"username"` Password string `json:"passwd"` RoleID string `json:"roleid"` Name string `json:"name"` Surname string `json:"surname"` Groups usergroupids `json:"usrgrps"` }
User represent Zabbix user object https://www.zabbix.com/documentation/current/en/manual/api/reference/user/object
type UserGroup ¶
type UserGroup struct { UserGroupID string `json:"usrgrpid,omitempty"` Name string `json:"name"` DebugMode int `json:"debug_mode,string"` GUIAccess int `json:"gui_access,string"` Status int `json:"users_status,string"` Permissions usergrouppermissions `json:"hostgroup_rights,omitempty"` }
UserGroupGroup represent Zabbix usergroup object https://www.zabbix.com/documentation/current/en/manual/api/reference/usergroup/object
type UserGroupID ¶
type UserGroupID struct {
UserGroupID string `json:"usrgrpid"`
}
UserGroupID represent Zabbix UserGroupID
type UserGroupPermission ¶
UserGroupPermission represents zabbix usergroup permission object https://www.zabbix.com/documentation/current/en/manual/api/reference/usergroup/object