gozbx

package module
v0.0.0-...-686b254 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

README

gozbx

Go zabbix API client.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveAvailableEnum

type ActiveAvailableEnum uint8
const (
	Unknown     ActiveAvailableEnum = 0
	Available   ActiveAvailableEnum = 1
	Unavailable ActiveAvailableEnum = 2
)

type CommonGetParams

type CommonGetParams struct {
	CountOutput   bool           `json:"countOutput,omitempty"`   // Return the number of records in the result instead of the actual data
	Editable      bool           `json:"editable,omitempty"`      // If set to true return only objects that the user has write permissions to.
	ExcludeSearch bool           `json:"excludeSearch,omitempty"` // Return results that do not match the criteria given in the search parameter.
	Filter        map[string]any `json:"filter,omitempty"`        // Filter the result.
	Limit         int            `json:"limit,omitempty"`         // Limit the number of records returned.
	Output        []string       `json:"output,omitempty"`        // Return only the given fields in the result.
	PreserveKeys  bool           `json:"preservekeys,omitempty"`  // Use IDs as keys in the resulting array.
	Search        []string       `json:"search,omitempty"`        // Search for records that match the given criteria.
	SearchByAny   bool           `json:"searchByAny,omitempty"`   // Search for records that match any of the given criteria.
	Sort          []string       `json:"sort,omitempty"`          // Sort the result.
}

type GroupId

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

type HosGroupImpl

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

func (*HosGroupImpl) Create

func (hg *HosGroupImpl) Create(params HostGroupCreate) (rsp string, err error)

func (*HosGroupImpl) Delete

func (hg *HosGroupImpl) Delete(hostgroupIds []string) (rsp []string, err error)

func (*HosGroupImpl) Get

func (hg *HosGroupImpl) Get(params HostGroupGet) (res []HostGroupModel, err error)

func (*HosGroupImpl) MassAdd

func (hg *HosGroupImpl) MassAdd(params HostGroupMassAdd) (rsp *HostGroupIdResponse, err error)

func (*HosGroupImpl) MassRemove

func (hg *HosGroupImpl) MassRemove(params HostGroupMassRemove) (rsp *HostGroupIdResponse, err error)

func (*HosGroupImpl) MassUpdate

func (hg *HosGroupImpl) MassUpdate(params HostGroupMassUpdate) (rsp *HostGroupIdResponse, err error)

func (*HosGroupImpl) Update

func (hg *HosGroupImpl) Update(params HostGroupUpdate) (rsp string, err error)

type HostCreate

type HostCreate struct {
	Groups         []GroupId         `json:"groups"`
	Host           string            `json:"host"`
	Name           string            `json:"name,omitempty"`
	Interfaces     []InterfaceCreate `json:"interfaces"`
	Tags           []Tag             `json:"tags,omitempty"`
	Templates      []TemplatedId     `json:"templates"`
	Macros         []Macro           `json:"macros,omitempty"`
	Inventory      map[string]string `json:"inventory,omitempty"`
	TLSAccepted    uint8             `json:"tls_accepted,omitempty"`
	TLSConnect     uint8             `json:"tls_connect,omitempty"`
	TLSPSKIdentity string            `json:"tls_psk_identity,omitempty"`
	TSLPSK         string            `json:"tls_psk,omitempty"`
	MoniteredBy    MonitoredByEnum   `json:"monitored_by,omitempty"`
	ProxyId        string            `json:"proxyid,omitempty"`
	ProxyGroupId   string            `json:"proxy_groupid,omitempty"`
}

type HostGet

type HostGet struct {
	CommonGetParams
	HostIds        []string `json:"hostids,omitempty"`
	MaintenanceIds []string `json:"maintenanceids,omitempty"`
	TriggerIds     []string `json:"triggerids,omitempty"`
}

type HostGroupCreate

type HostGroupCreate struct {
	Host string    `json:"name"`
	Uuid uuid.UUID `json:"uuid,omitempty"`
}

type HostGroupGet

type HostGroupGet struct {
	CommonGetParams
	GroupIds       []string `json:"groupids,omitempty"`       // Return only host groups with the given host group IDs.
	HostIds        []string `json:"hostids,omitempty"`        // Return only host groups that contain the given hosts.
	MaintenanceIds []string `json:"maintenanceids,omitempty"` // Return only host groups with the given maintenance IDs.
	TriggerIds     []string `json:"triggerids,omitempty"`     // Return only host groups that contain the given triggers.
}

type HostGroupIdResponse

type HostGroupIdResponse struct {
	GroupIds []string `json:"groupids"`
}

type HostGroupMassAdd

type HostGroupMassAdd struct {
	Groups []GroupId `json:"groups"`
	Host   []HostId  `json:"hosts"`
}

This method allows to simultaneously add multiple related objects to all the given host groups.

type HostGroupMassRemove

type HostGroupMassRemove struct {
	HostGroupMassAdd
}

This method allows to remove related objects from multiple host groups.

type HostGroupMassUpdate

type HostGroupMassUpdate struct {
	HostGroupMassAdd
}

This method allows to replace hosts and templates with the specified ones in multiple host groups.

type HostGroupModel

type HostGroupModel struct {
	GroupId string `json:"groupid"`
	Name    string `json:"name"`
	Flags   int    `json:"flags"` // 0: a plain hostgroup 4: discovered hostgroup
	Uuid    string `json:"uuid"`
}

type HostGroupUpdate

type HostGroupUpdate struct {
	GroupId string `json:"groupid"`
	Name    string `json:"name,omitempty"`
	Flags   int    `json:"flags,omitempty"`
	Uuid    string `json:"uuid,omitempty"`
}

type HostId

type HostId struct {
	HostId string `json:"hostid"`
}

type HostInterfaceAvailableEnum

type HostInterfaceAvailableEnum uint8
const (
	InterfaceUnknownType     HostInterfaceAvailableEnum = 0
	InterfaceAvailableType   HostInterfaceAvailableEnum = 1
	InterfaceUnAvailableType HostInterfaceAvailableEnum = 2
)

type HostInterfaceEnum

type HostInterfaceEnum uint8
const (
	AgentHostInterfaceType HostInterfaceEnum = 1
	SNMPHostInterfaceType  HostInterfaceEnum = 2
	IPMIHostInterfaceType  HostInterfaceEnum = 3
	JMXHostInterfaceType   HostInterfaceEnum = 4
)

type HostIpEnum

type HostIpEnum uint8
const (
	UseDNSType HostIpEnum = 0
	UseIPType  HostIpEnum = 1
)

type HostModel

type HostModel struct {
	HostID          string              `json:"hostid,omitempty"`
	Host            string              `json:"host"`
	Description     string              `json:"description,omitempty"`
	MonitoredBy     []string            `json:"monitored_by,omitempty"`
	ProxyId         string              `json:"proxyid,omitempty"`
	ProxyGroupId    string              `json:"proxy_groupid,omitempty"`
	Status          HostStatusEnum      `json:"status,omitempty"`
	ActiveAvailable ActiveAvailableEnum `json:"active_available,omitempty"`
	AssginedProxyID string              `json:"assigned_proxyid,omitempty"` // ID of the proxy assigned by Zabbix server, if the host is monitored by a proxy group.
}

type HostStatusEnum

type HostStatusEnum uint8
const (
	Monitered   HostStatusEnum = 0
	Unmonitered HostStatusEnum = 1
)

type InterfaceCreate

type InterfaceCreate struct {
	Type    HostInterfaceEnum `json:"type"`
	Main    bool              `json:"main,omitempty"`
	UserIP  HostIpEnum        `json:"useip,omitempty"`
	DNS     string            `json:"dns,omitempty"`
	Port    uint              `json:"port,omitempty"`
	Details map[string]string `json:"details,omitempty"`
}

type Macro

type Macro struct {
	Macro_      string `json:"macro"`
	Value       string `json:"value"`
	Description string `json:"description,omitempty"`
}

type MonitoredByEnum

type MonitoredByEnum uint8
const (
	ZabbixServer     MonitoredByEnum = 0
	ZabbixProxy      MonitoredByEnum = 1
	ZabbixProxyGroup MonitoredByEnum = 2
)

type Request

type Request struct {
	JsonRpc string `json:"jsonrpc"`
	Method  string `json:"method"`
	Params  any    `json:"params"`
	Id      uint64 `json:"id"`
}

type Response

type Response struct {
	JsonRpc string      `json:"jsonrpc"`
	Result  any         `json:"result"`
	Error   ZbxApiError `json:"error"`
	Id      uint64      `json:"id"`
}

func (*Response) GetResult

func (rsp *Response) GetResult(v any) error

func (*Response) IsError

func (rsp *Response) IsError() error

type Tag

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

type TemplatedId

type TemplatedId struct {
	TemplatedId string `json:"templateid"`
}

type ZbxAPI

type ZbxAPI struct {
	HostGroup *HosGroupImpl
	// contains filtered or unexported fields
}

func (*ZbxAPI) Login

func (z *ZbxAPI) Login(username, password string) error

func (*ZbxAPI) NewZbxAPI

func (z *ZbxAPI) NewZbxAPI(url string) *ZbxAPI

func (*ZbxAPI) Rpc

func (z *ZbxAPI) Rpc(req *Request) (*Response, error)

func (*ZbxAPI) SetRetryCount

func (z *ZbxAPI) SetRetryCount(retry int)

func (*ZbxAPI) SetTimeout

func (z *ZbxAPI) SetTimeout(timeout int)

func (*ZbxAPI) SetToken

func (z *ZbxAPI) SetToken(token string)

type ZbxApiError

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

Jump to

Keyboard shortcuts

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