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/jcracchiolo-tc/go-zabbix-api`
Getting started
package main import ( "fmt" "github.com/jcracchiolo-tc/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 ¶
- 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) DiscoveryRulesCreate(rules LLDRules) error
- func (api *API) DiscoveryRulesDelete(rules LLDRules) (err error)
- func (api *API) DiscoveryRulesDeletesByIDs(ids []string) (err error)
- func (api *API) DiscoveryRulesDeletesIDs(ids []string) (drulsids []interface{}, err error)
- func (api *API) DiscoveryRulesGet(params Params) (res LLDRules, err error)
- func (api *API) DiscoveryRulesGetByID(id string) (res *LLDRule, err error)
- func (api *API) DiscoveryRulesUpdate(rules LLDRules) 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) ItemPrototypeGetByID(id string) (res *ItemPrototype, err error)
- func (api *API) ItemPrototypesCreate(items ItemPrototypes) (err error)
- func (api *API) ItemPrototypesDelete(items ItemPrototypes) (err error)
- func (api *API) ItemPrototypesDeleteByIds(ids []string) (err error)
- func (api *API) ItemPrototypesDeleteIDs(ids []string) (itemids1 []interface{}, err error)
- func (api *API) ItemPrototypesGet(params Params) (res ItemPrototypes, err error)
- func (api *API) ItemPrototypesUpdate(items ItemPrototypes) (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) Login(user, password string) (auth string, err error)
- func (api *API) Logout() (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) SetClient(c *http.Client)
- func (api *API) TemplateGetByID(id string) (template *Template, err error)
- func (api *API) TemplateGroupGetByID(id string) (res *TemplateGroup, err error)
- func (api *API) TemplateGroupsCreate(TemplateGroups TemplateGroups) (err error)
- func (api *API) TemplateGroupsDelete(TemplateGroups TemplateGroups) (err error)
- func (api *API) TemplateGroupsDeleteByIds(ids []string) (err error)
- func (api *API) TemplateGroupsGet(params Params) (res TemplateGroups, err error)
- func (api *API) TemplateGroupsUpdate(TemplateGroups TemplateGroups) (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) TriggerGetByID(id string) (res *Trigger, err error)
- func (api *API) TriggerPrototypeGetByID(id string) (res *TriggerPrototype, err error)
- func (api *API) TriggerPrototypesCreate(triggers TriggerPrototypes) (err error)
- func (api *API) TriggerPrototypesDelete(triggers TriggerPrototypes) (err error)
- func (api *API) TriggerPrototypesDeleteByIds(ids []string) (err error)
- func (api *API) TriggerPrototypesDeleteIDs(ids []string) (triggerids []interface{}, err error)
- func (api *API) TriggerPrototypesGet(params Params) (res TriggerPrototypes, err error)
- func (api *API) TriggerPrototypesUpdate(triggers TriggerPrototypes) (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) Version() (v string, err error)
- type Application
- type Applications
- type AvailableType
- type DataType
- type DeltaType
- type Error
- type ExpectedMore
- type ExpectedOneResult
- type Host
- type HostGroup
- type HostGroupID
- type HostGroupIDs
- type HostGroups
- type HostInterface
- type HostInterfaces
- type Hosts
- type InterfaceType
- type InternalType
- type Item
- type ItemPrototype
- type ItemPrototypes
- type ItemType
- type Items
- type LLDRule
- type LLDRuleFilter
- type LLDRules
- type LLDRulesFilterCondition
- type LLDRulesFilterConditions
- type Macro
- type Macros
- type Params
- type RawResponse
- type Response
- type SeverityType
- type StatusType
- type Template
- type TemplateGroup
- type TemplateGroups
- type TemplateID
- type TemplateIDs
- type Templates
- type Trigger
- type TriggerFunction
- type TriggerFunctions
- type TriggerPrototype
- type TriggerPrototypes
- type Triggers
- type ValueType
Constants ¶
This section is empty.
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 // contains filtered or unexported fields }
API use to store connection information
func New ¶
New 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) DiscoveryRulesCreate ¶
DiscoveryRulesCreate Wrapper for discoveryrule.create https://www.zabbix.com/documentation/3.2/manual/api/reference/discoveryrule/create
func (*API) DiscoveryRulesDelete ¶
DiscoveryRulesDelete Wrapper for discoveryrule.delete Cleans ItemID in all discovery rule element if call succeed. https://www.zabbix.com/documentation/3.2/manual/api/reference/discoveryrule/delete
func (*API) DiscoveryRulesDeletesByIDs ¶
DiscoveryRulesDeletesByIDs Wrapper for discorveryrule.delete Delete the discovery rule with the given ids https://www.zabbix.com/documentation/3.2/manual/api/reference/discoveryrule/delete
func (*API) DiscoveryRulesDeletesIDs ¶
DiscoveryRulesDeletesIDs Wrapper for discorveryrule.delete Delete the item and return the id of the deleted item https://www.zabbix.com/documentation/3.2/manual/api/reference/discoveryrule/delete
func (*API) DiscoveryRulesGet ¶
DiscoveryRulesGet Wrapper for discoveryrule.get https://www.zabbix.com/documentation/3.2/manual/api/reference/discoveryrule/get
func (*API) DiscoveryRulesGetByID ¶
DiscoveryRulesGetByID Gets discovery rule by id only if there is exactly 1 matching discovery rule.
func (*API) DiscoveryRulesUpdate ¶
DiscoveryRulesUpdate Wrapper for discoveryrule.update https://www.zabbix.com/documentation/3.2/manual/api/reference/discoveryrule/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) ItemPrototypeGetByID ¶
func (api *API) ItemPrototypeGetByID(id string) (res *ItemPrototype, err error)
ItemPrototypeGetByID Gets item by Id only if there is exactly 1 matching item.
func (*API) ItemPrototypesCreate ¶
func (api *API) ItemPrototypesCreate(items ItemPrototypes) (err error)
ItemPrototypesCreate Wrapper for item.create https://www.zabbix.com/documentation/3.2/manual/api/reference/itemprototype/create
func (*API) ItemPrototypesDelete ¶
func (api *API) ItemPrototypesDelete(items ItemPrototypes) (err error)
ItemPrototypesDelete Wrapper for item.delete Cleans ItemId in all items elements if call succeed. https://www.zabbix.com/documentation/3.2/manual/api/reference/itemprototype/delete
func (*API) ItemPrototypesDeleteByIds ¶
ItemPrototypesDeleteByIds Wrapper for item.delete https://www.zabbix.com/documentation/3.2/manual/api/reference/itemprototype/delete
func (*API) ItemPrototypesDeleteIDs ¶
ItemPrototypesDeleteIDs Wrapper for item.delete Delete the item prototype and return the id of the deleted item prototype https://www.zabbix.com/documentation/3.2/manual/api/reference/itemprototype/delete
func (*API) ItemPrototypesGet ¶
func (api *API) ItemPrototypesGet(params Params) (res ItemPrototypes, err error)
ItemPrototypesGet Wrapper for item.get https://www.zabbix.com/documentation/3.2/manual/api/reference/itemprototype/get
func (*API) ItemPrototypesUpdate ¶
func (api *API) ItemPrototypesUpdate(items ItemPrototypes) (err error)
ItemPrototypesUpdate Wrapper for item.update https://www.zabbix.com/documentation/3.2/manual/api/reference/itemprototype/update
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) 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) 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) TemplateGroupGetByID ¶
func (api *API) TemplateGroupGetByID(id string) (res *TemplateGroup, err error)
TemplateGroupGetByID Gets host group by Id only if there is exactly 1 matching host group. https://www.zabbix.com/documentation/6.2/en/manual/api/reference/templategroup/get
func (*API) TemplateGroupsCreate ¶
func (api *API) TemplateGroupsCreate(TemplateGroups TemplateGroups) (err error)
TemplateGroupsCreate Wrapper for templategroup.create https://www.zabbix.com/documentation/6.2/en/manual/api/reference/templategroup/create
func (*API) TemplateGroupsDelete ¶
func (api *API) TemplateGroupsDelete(TemplateGroups TemplateGroups) (err error)
TemplateGroupsDelete Wrapper for templategroup.delete Cleans GroupId in all TemplateGroups elements if call succeed. https://www.zabbix.com/documentation/6.2/en/manual/api/reference/templategroup/delete
func (*API) TemplateGroupsDeleteByIds ¶
TemplateGroupsDeleteByIds Wrapper for templategroup.delete https://www.zabbix.com/documentation/6.2/en/manual/api/reference/templategroup/delete
func (*API) TemplateGroupsGet ¶
func (api *API) TemplateGroupsGet(params Params) (res TemplateGroups, err error)
TemplateGroupsGet Wrapper for templategroup.get https://www.zabbix.com/documentation/6.2/en/manual/api/reference/templategroup/get
func (*API) TemplateGroupsUpdate ¶
func (api *API) TemplateGroupsUpdate(TemplateGroups TemplateGroups) (err error)
TemplateGroupsUpdate Wrapper for templategroup.update https://www.zabbix.com/documentation/6.2/en/manual/api/reference/templategroup/update
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) TriggerGetByID ¶
TriggerGetByID Gets trigger by Id only if there is exactly 1 matching host.
func (*API) TriggerPrototypeGetByID ¶
func (api *API) TriggerPrototypeGetByID(id string) (res *TriggerPrototype, err error)
TriggerPrototypeGetByID Gets trigger by Id only if there is exactly 1 matching trigger.
func (*API) TriggerPrototypesCreate ¶
func (api *API) TriggerPrototypesCreate(triggers TriggerPrototypes) (err error)
TriggerPrototypesCreate Wrapper for trigger.create https://www.zabbix.com/documentation/3.2/manual/api/reference/triggerprototype/create
func (*API) TriggerPrototypesDelete ¶
func (api *API) TriggerPrototypesDelete(triggers TriggerPrototypes) (err error)
TriggerPrototypesDelete Wrapper for trigger.delete Cleans TriggerID in all triggers elements if call succeed. https://www.zabbix.com/documentation/3.2/manual/api/reference/triggerprototype/delete
func (*API) TriggerPrototypesDeleteByIds ¶
TriggerPrototypesDeleteByIds Wrapper for trigger.delete https://www.zabbix.com/documentation/3.2/manual/api/reference/triggerprototype/delete
func (*API) TriggerPrototypesDeleteIDs ¶
TriggerPrototypesDeleteIDs Wrapper for trigger.delete return the id of the deleted trigger prototype https://www.zabbix.com/documentation/3.2/manual/api/reference/triggerprototype/delete
func (*API) TriggerPrototypesGet ¶
func (api *API) TriggerPrototypesGet(params Params) (res TriggerPrototypes, err error)
TriggerPrototypesGet Wrapper for trigger.get https://www.zabbix.com/documentation/3.2/manual/api/reference/triggerprototype/get
func (*API) TriggerPrototypesUpdate ¶
func (api *API) TriggerPrototypesUpdate(triggers TriggerPrototypes) (err error)
TriggerPrototypesUpdate Wrapper for trigger.update https://www.zabbix.com/documentation/3.2/manual/api/reference/triggerprototype/update
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
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 Host ¶
type Host struct { HostID string `json:"hostid,omitempty"` Host string `json:"host"` Description string `json:"description,omitempty"` Flags int `json:"flags,omitempty,string"` InventoryMode int `json:"inventory_mode,omitempty,string"` Available AvailableType `json:"available,string"` Error string `json:"error"` Name string `json:"name"` Status StatusType `json:"status,string"` // Fields below used only when creating hosts GroupIds HostGroupIDs `json:"groups,omitempty"` Interfaces HostInterfaces `json:"interfaces,omitempty"` TemplateIDs TemplateIDs `json:"templates,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"` Flags int `json:"flags,omitempty,string"` UUID string `json:"uuid,omitempty"` }
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 { DNS string `json:"dns"` IP string `json:"ip"` Main int `json:"main,string"` Port string `json:"port"` Type InterfaceType `json:"type,string"` UseIP int `json:"useip,string"` }
HostInterface represents zabbix host interface type https://www.zabbix.com/documentation/3.2/manual/api/reference/hostinterface/object
type HostInterfaces ¶
type HostInterfaces []HostInterface
HostInterfaces is an array of HostInterface
type InterfaceType ¶
type InterfaceType int
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 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"` // Fields below used only when creating applications ApplicationIds []string `json:"applications,omitempty"` ItemParent Hosts `json:"hosts"` }
Item represent Zabbix item object https://www.zabbix.com/documentation/3.2/manual/api/reference/item/object
type ItemPrototype ¶
type ItemPrototype struct { ItemID string `json:"itemid,omitempty"` // Readonly Delay string `json:"delay"` // Required HostID string `json:"hostid"` // Required InterfaceID string `json:"interfaceid"` // Required Key string `json:"key_"` // Required Name string `json:"name"` // Required Type ItemType `json:"type,string"` // Required ValueType ValueType `json:"value_type,string"` // Required RuleID string `json:"ruleid"` // Required for item prototype creation AuthType int `json:"authtype,omitempty,string"` DataType DataType `json:"data_type,omitempty,string"` DelayFlex string `json:"delay_flex,omitempty"` Delta DeltaType `json:"delta,omitempty,string"` Description string `json:"description,omitempty"` History string `json:"history,omitempty"` IpmiSensor string `json:"ipmi_sensor,omitempty"` Logtimefmt string `json:"logtimefmt,omitempty"` Multiplier string `json:"multiplier,omitempty"` Params string `json:"params,omitempty"` Password string `json:"password,omitempty"` Port string `json:"port,omitempty"` PrivateKey string `json:"privatekey,omitempty"` PublicKey string `json:"publickey,omitempty"` SnmpCommunity string `json:"snmp_community,omitempty"` SnmpOid string `json:"snmp_oid,omitempty"` Snmpv3Authpassphrase string `json:"snmpv3_authpassphrase,omitempty"` Snmpv3Authprotocol int `json:"snmpv3_authprotocol,omitempty,string"` Snmpv3Contextname string `json:"snmpv3_contextname,omitempty"` Snmpv3Privpassphrase string `json:"snmpv3_privpassphrase,omitempty"` Snmpv3Privprotocol int `json:"snmpv3_privprotocol,omitempty,string"` Snmpv3Securitylevel int `json:"snmpv3_securitylevel,omitempty,string"` Snmpv3Securityname string `json:"snmpv3_securityname,omitempty"` Status int `json:"status,string"` Templateid string `json:"templateid,omitempty"` TrapperHosts string `json:"trapper_hosts,omitempty"` Trends string `json:"trends,omitempty"` Units string `json:"units,omitempty"` Username string `json:"username,omitempty"` Valuemapid string `json:"valuemapid,omitempty"` DiscoveryRule LLDRule `json:"DiscoveryRule,omitempty"` Hosts Hosts `json:"hosts,omitempty"` }
ItemPrototype represent Zabbix item prototype object https://www.zabbix.com/documentation/3.2/manual/api/reference/itemprototype/object
type ItemPrototypes ¶
type ItemPrototypes []ItemPrototype
ItemPrototypes is an array of ItemPrototype
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 type (new in 2.2) SNMPTrap ItemType = 17 // DependentItem type (new in 3.4) DependentItem ItemType = 18 //HTTPAgent type (new in 4.0) HTTPAgent ItemType = 19 )
type LLDRule ¶
type LLDRule struct { ItemID string `json:"itemid,omitempty"` // Readonly Delay string `json:"delay"` // Required HostID string `json:"hostid"` // Required InterfaceID string `json:"interfaceid"` // Required Key string `json:"key_"` // Required Name string `json:"name"` // Required Type ItemType `json:"type,string"` // Required AuthType string `json:"authtype,omitempty"` DelayFlex string `json:"delay_flex,omitempty"` Description string `json:"description,omitempty"` Error string `json:"error,omitempty"` //Readonly IpmiSensor string `json:"ipmi_sensor,omitempty"` LifeTime string `json:"lifetime,omitempty"` Params string `json:"params,omitempty"` Password string `json:"password,omitempty"` Port string `json:"port,omitempty"` PrivateKey string `json:"privatekey,omitempty"` PublicKey string `json:"publickey,omitempty"` SnmpCommunity string `json:"snmp_community,omitempty"` SnmpOid string `json:"snmp_oid,omitempty"` Snmpv3Authpassphrase string `json:"snmpv3_authpassphrase,omitempty"` Snmpv3Authprotocol int `json:"snmpv3_authprotocol,omitempty,string"` Snmpv3Contextname string `json:"snmpv3_contextname,omitempty"` Snmpv3Privpassphrase string `json:"snmpv3_privpassphrase,omitempty"` Snmpv3Privprotocol int `json:"snmpv3_privprotocol,omitempty,string"` Snmpv3Securitylevel int `json:"snmpv3_securitylevel,omitempty,string"` Snmpv3Securityname string `json:"snmpv3_securityname,omitempty"` State int `json:"state,omitempty,string"` Status int `json:"status,omitempty,string"` Templateid string `json:"templateid,omitempty"` TrapperHosts string `json:"trapper_hosts,omitempty"` Username string `json:"username,omitempty"` Filter LLDRuleFilter `json:"filter"` }
LLDRule represent Zabbix low-level discovery rule(LLD rule) object https://www.zabbix.com/documentation/3.2/manual/api/reference/discoveryrule/object#lld_rule
type LLDRuleFilter ¶
type LLDRuleFilter struct { Conditions LLDRulesFilterConditions `json:"conditions"` // Required EvalType int `json:"evaltype,string"` // Required EvalFormula string `json:"eval_formula,omitempty"` Formula string `json:"formula,omitempty"` }
LLDRuleFilter represent zabbix low-level discovery rules filter(LLD rule filter) object https://www.zabbix.com/documentation/3.2/manual/api/reference/discoveryrule/object#lld_rule_filter
type LLDRulesFilterCondition ¶
type LLDRulesFilterCondition struct { LLDMacro string `json:"macro"` // Required Value string `json:"value"` // Required FormulaID string `json:"formulaid,omitempty"` Operator int `json:"operator,omitempty,string"` }
LLDRulesFilterCondition represent zabbix low-level discovery rules filter condition(LLD rule file condition) object https://www.zabbix.com/documentation/3.2/manual/api/reference/discoveryrule/object#lld_rule_filter_condition
type LLDRulesFilterConditions ¶
type LLDRulesFilterConditions []LLDRulesFilterCondition
LLDRulesFilterConditions is an array of LLDRulesFilterCondition
type Macro ¶
type Macro struct { MacroID string `json:"hostmacroids,omitempty"` HostID string `json:"hostid"` 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 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,omitempty"` LinkedTemplates Templates `json:"templates,omitempty"` TemplatesClear Templates `json:"templates_clear,omitempty"` LinkedHosts Hosts `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 TemplateGroup ¶
TemplateGroup represent Zabbix template group object, new in v6.2 https://www.zabbix.com/documentation/6.2/en/manual/api/reference/templategroup/object
type TemplateGroups ¶
type TemplateGroups []TemplateGroup
TemplateGroups is an array of TemplateGroup
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"` Priority SeverityType `json:"priority,string"` Status StatusType `json:"status,string"` Dependencies Triggers `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"` }
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 TriggerPrototype ¶
type TriggerPrototype struct { TriggerID string `json:"triggerid,omitempty"` // Readonly Description string `json:"description"` // Reqired Expression string `json:"expression"` // Required Commemts string `json:"comments,omitempty"` Priority SeverityType `json:"priority,omitempty,string"` Status StatusType `json:"status,omitempty,string"` TemplateID string `json:"templateid,omitempty"` // Readonly Type int `json:"type,omitempty,string"` URL string `json:"url,omitempty"` RecoveryMode int `json:"recovery_mode,omitempty,string"` RecoveryExpression string `json:"recovery_expression,omitempty"` CorrelationMode int `json:"correlation_mode,omitempty,string"` CorrelationTag string `json:"correlation_tag,omitempty"` ManualClose int `json:"manual_close,omitempty,string"` Dependencies TriggerPrototypes `json:"dependencies,omitempty"` Functions TriggerFunctions `json:"functions,omitempty"` // Return the hosts that the trigger prototype belongs to in the hosts property. ParentHosts Hosts `json:"hosts,omitempty"` }
TriggerPrototype represent Zabbix trigger prototype object https://www.zabbix.com/documentation/3.2/manual/api/reference/triggerprototype/object
type TriggerPrototypes ¶
type TriggerPrototypes []TriggerPrototype
TriggerPrototypes is an array of TriggerPrototype