Categorygithub.com/mrgolangv/nxs-go-zabbix/v6
modulepackage
6.0.5
Repository: https://github.com/mrgolangv/nxs-go-zabbix.git
Documentation: pkg.go.dev

# README

nxs-go-zabbix

This Go package provides access to Zabbix API v5.0. Also see older versions in other branches.

At the time not all Zabbix API methods are implemented, but work in progress.

Install

go get github.com/nixys/nxs-go-zabbix/v5

Example of usage

You may find more examples in unit-tests in this repository

Get all hosts on Zabbix server:

package main

import (
	"fmt"
	"os"

	"github.com/nixys/nxs-go-zabbix/v5"
)

func zabbixLogin(z *zabbix.Context, zbxHost, zbxUsername, zbxPassword string) {

	if err := z.Login(zbxHost, zbxUsername, zbxPassword); err != nil {
		fmt.Println("Login error:", err)
		os.Exit(1)
	} else {
		fmt.Println("Login: success")
	}
}

func zabbixLogout(z *zabbix.Context) {

	if err := z.Logout(); err != nil {
		fmt.Println("Logout error:", err)
		os.Exit(1)
	} else {
		fmt.Println("Logout: success")
	}
}

func main() {

	var z zabbix.Context

	/* Get variables from environment to login to Zabbix server */
	zbxHost := os.Getenv("ZABBIX_HOST")
	zbxUsername := os.Getenv("ZABBIX_USERNAME")
	zbxPassword := os.Getenv("ZABBIX_PASSWORD")
	if zbxHost == "" || zbxUsername == "" || zbxPassword == "" {
		fmt.Println("Login error: make sure environment variables `ZABBIX_HOST`, `ZABBIX_USERNAME` and `ZABBIX_PASSWORD` are defined")
		os.Exit(1)
	}

	/* Login to Zabbix server */
	zabbixLogin(&z, zbxHost, zbxUsername, zbxPassword)
	defer zabbixLogout(&z)

	/* Get all hosts */
	hObjects, _, err := z.HostGet(zabbix.HostGetParams{
		GetParameters: zabbix.GetParameters{
			Output: zabbix.SelectExtendedOutput,
		},
	})
	if err != nil {
		fmt.Println("Hosts get error:", err)
		return
	}

	/* Print names of retrieved hosts */
	fmt.Println("Hosts list:")
	for _, h := range hObjects {
		fmt.Println("-", h.Host)
	}
}

Run:

ZABBIX_HOST="https://zabbix.yourdomain.com/api_jsonrpc.php" ZABBIX_USERNAME="Admin" ZABBIX_PASSWORD="PASSWORD" go run main.go

# Constants

contains.
=.
>=.
in.
<=.
matches.
<>.
no.
not in.
does not match.
does not contain.
yes.
For `ActionFilterConditionObject` field: `ConditionType`.
For `ActionFilterConditionObject` field: `ConditionType`.
For `ActionFilterConditionObject` field: `ConditionType`.
For `ActionFilterConditionObject` field: `ConditionType`.
For `ActionFilterConditionObject` field: `ConditionType`.
For `ActionFilterConditionObject` field: `ConditionType`.
For `ActionFilterConditionObject` field: `ConditionType`.
For `ActionFilterConditionObject` field: `ConditionType`.
For `ActionFilterConditionObject` field: `ConditionType`.
For `ActionFilterConditionObject` field: `ConditionType`.
For `ActionFilterConditionObject` field: `ConditionType`.
For `ActionFilterConditionObject` field: `ConditionType`.
For `ActionFilterConditionObject` field: `ConditionType`.
For `ActionFilterConditionObject` field: `ConditionType`.
For `ActionFilterConditionObject` field: `ConditionType`.
For `ActionFilterConditionObject` field: `ConditionType`.
For `ActionFilterConditionObject` field: `ConditionType`.
For `ActionFilterConditionObject` field: `ConditionType`.
For `ActionFilterConditionObject` field: `ConditionType`.
For `ActionFilterConditionObject` field: `ConditionType`.
For `ActionFilterConditionObject` field: `ConditionType`.
For `ActionFilterConditionObject` field: `ConditionType`.
For `ActionFilterConditionObject` field: `ConditionType`.
For `ActionFilterConditionObject` field: `ConditionType`.
For `ActionFilterConditionObject` field: `ConditionType`.
For `ActionFilterObject` field: `EvalType`.
For `ActionFilterObject` field: `EvalType`.
For `ActionFilterObject` field: `EvalType`.
For `ActionFilterObject` field: `EvalType`.
For `ActionOperationCommandObject` field: `AuthType`.
For `ActionOperationCommandObject` field: `AuthType`.
For `ActionOperationCommandObject` field: `ExecuteOn`.
For `ActionOperationCommandObject` field: `ExecuteOn`.
For `ActionOperationCommandObject` field: `ExecuteOn`.
For `ActionOperationCommandObject` field: `Type`.
For `ActionOperationCommandObject` field: `Type`.
For `ActionOperationCommandObject` field: `Type`.
For `ActionOperationCommandObject` field: `Type`.
For `ActionOperationCommandObject` field: `Type`.
For `ActionOperationConditionObject` field: `Operator`.
For `ActionOperationConditionObject` field: `ConditionType`.
For `ActionOperationObject` field: `EvalType`.
For `ActionOperationObject` field: `EvalType`.
For `ActionOperationObject` field: `EvalType`.
For `ActionOperationMessageObject` field: `DefaultMsg`.
For `ActionOperationMessageObject` field: `DefaultMsg`.
For `ActionOperationObject` field: `OperationType`.
For `ActionOperationObject` field: `OperationType`.
For `ActionOperationObject` field: `OperationType`.
For `ActionOperationObject` field: `OperationType`.
For `ActionOperationObject` field: `OperationType`.
For `ActionOperationObject` field: `OperationType`.
For `ActionOperationObject` field: `OperationType`.
For `ActionOperationObject` field: `OperationType`.
For `ActionOperationObject` field: `OperationType`.
For `ActionOperationObject` field: `OperationType`.
For `ActionOperationObject` field: `OperationType`.
For `ActionObject` field: `PauseSuppressed`.
For `ActionObject` field: `PauseSuppressed`.
For `ActionRecoveryOperationObject` field: `OperationType `.
For `ActionRecoveryOperationObject` field: `OperationType `.
For `ActionRecoveryOperationObject` field: `OperationType `.
For `ActionObject` field: `Status`.
For `ActionObject` field: `Status`.
For `ActionUpdateOperationObject` field: `OperationType `.
For `ActionUpdateOperationObject` field: `OperationType `.
For `ActionUpdateOperationObject` field: `OperationType `.
For `GetParameters` field: `SortOrder`.
For `GetParameters` field: `SortOrder`.
For `HistoryGetParams` field: `History`.
For `HistoryGetParams` field: `History`.
For `HistoryGetParams` field: `History`.
For `HistoryGetParams` field: `History`.
For `HistoryGetParams` field: `History`.
For `HostObject` field: `Available`.
For `HostObject` field: `Available`.
For `HostObject` field: `Available`.
For `HostGetParams` field: `Evaltype`.
For `HostGetParams` field: `Evaltype`.
For `HostObject` field: `Flags`.
For `HostObject` field: `Flags`.
For `HostgroupObject` field: `Status`.
For `HostgroupObject` field: `Status`.
For `HostgroupObject` field: `Internal`.
For `HostgroupObject` field: `Internal`.
For `HostinterfaceDetailsTagObject` field: `AuthProtocol`.
For `HostinterfaceDetailsTagObject` field: `AuthProtocol`.
For `HostinterfaceDetailsTagObject` field: `Bulk`.
For `HostinterfaceDetailsTagObject` field: `Bulk`.
For `HostinterfaceDetailsTagObject` field: `PrivProtocol`.
For `HostinterfaceDetailsTagObject` field: `PrivProtocol`.
For `HostinterfaceDetailsTagObject` field: `SecurityLevel`.
For `HostinterfaceDetailsTagObject` field: `SecurityLevel`.
For `HostinterfaceDetailsTagObject` field: `SecurityLevel`.
For `HostinterfaceDetailsTagObject` field: `Version`.
For `HostinterfaceDetailsTagObject` field: `Version`.
For `HostinterfaceDetailsTagObject` field: `Version`.
For `HostinterfaceObject` field: `Main`.
For `HostinterfaceObject` field: `Main`.
For `HostinterfaceObject` field: `Type`.
For `HostinterfaceObject` field: `Type`.
For `HostinterfaceObject` field: `Type`.
For `HostinterfaceObject` field: `Type`.
For `HostinterfaceObject` field: `UseIP`.
For `HostinterfaceObject` field: `UseIP`.
For `HostObject` field: `Flags`.
For `HostObject` field: `Flags`.
For `HostObject` field: `Flags`.
For `HostObject` field: `IpmiAuthtype`.
For `HostObject` field: `IpmiAuthtype`.
For `HostObject` field: `IpmiAuthtype`.
For `HostObject` field: `IpmiAuthtype`.
For `HostObject` field: `IpmiAuthtype`.
For `HostObject` field: `IpmiAuthtype`.
For `HostObject` field: `IpmiAuthtype`.
For `HostObject` field: `IpmiAvailable`.
For `HostObject` field: `IpmiAvailable`.
For `HostObject` field: `IpmiAvailable`.
For `HostObject` field: `IpmiPrivilege`.
For `HostObject` field: `IpmiPrivilege`.
For `HostObject` field: `IpmiPrivilege`.
For `HostObject` field: `IpmiPrivilege`.
For `HostObject` field: `IpmiPrivilege`.
For `HostObject` field: `JmxAvailable`.
For `HostObject` field: `JmxAvailable`.
For `HostObject` field: `JmxAvailable`.
For `HostObject` field: `MaintenanceStatus`.
For `HostObject` field: `MaintenanceStatus`.
For `HostObject` field: `MaintenanceType`.
For `HostObject` field: `MaintenanceType`.
For `HostObject` field: `SnmpAvailable`.
For `HostObject` field: `SnmpAvailable`.
For `HostObject` field: `SnmpAvailable`.
For `HostObject` field: `Status`.
For `HostObject` field: `Status`.
For `HostTag` field: `Operator`.
For `HostTag` field: `Operator`.
For `MediaObject` field: `Active`.
For `MediaObject` field: `Active`.
For `MediatypeObject` field: `ContentType`.
For `MediatypeObject` field: `ContentType`.
For `MediatypeObject` field: `Type`.
For `MediatypeMessageTemplateObject` field: `EventSource`.
For `MediatypeMessageTemplateObject` field: `EventSource`.
For `MediatypeMessageTemplateObject` field: `EventSource`.
For `MediatypeMessageTemplateObject` field: `EventSource`.
For `MediatypeMessageTemplateObject` field: `Recovery`.
For `MediatypeMessageTemplateObject` field: `Recovery`.
For `MediatypeMessageTemplateObject` field: `Recovery`.
For `MediatypeObject` field: `ProcessTags`.
For `MediatypeObject` field: `ProcessTags`.
For `MediatypeObject` field: `Type`.
For `MediatypeObject` field: `Status`.
For `MediatypeObject` field: `ShowEventMenu`.
For `MediatypeObject` field: `ShowEventMenu`.
For `MediatypeObject` field: `Type`.
For `MediatypeObject` field: `SMTPAuthentication`.
For `MediatypeObject` field: `SMTPAuthentication`.
For `MediatypeObject` field: `SMTPSecurity`.
For `MediatypeObject` field: `SMTPSecurity`.
For `MediatypeObject` field: `SMTPSecurity`.
For `MediatypeObject` field: `SMTPVerifyHost`.
For `MediatypeObject` field: `SMTPVerifyHost`.
For `MediatypeObject` field: `SMTPVerifyPeer`.
For `MediatypeObject` field: `SMTPVerifyPeer`.
For `MediatypeObject` field: `Status`.
For `MediatypeObject` field: `Type`.
Zabbix select constants.
Zabbix select constants.
For `TemplateGetParams` field: `Evaltype`.
For `TemplateGetParams` field: `Evaltype`.
For `TemplateTag` field: `Operator`.
For `TemplateTag` field: `Operator`.
For `HostObject` field: `TLSAccept`.
For `HostObject` field: `TLSAccept`.
For `HostObject` field: `TLSAccept`.
For `HostObject` field: `TLSConnect`.
For `HostObject` field: `TLSConnect`.
For `HostObject` field: `TLSConnect`.
For `UserObject` field: `AutoLogin`.
For `UserObject` field: `AutoLogin`.
For `UsergroupObject` field: `DebugMode`.
For `UsergroupObject` field: `DebugMode`.
For `UsergroupObject` field: `GuiAccess`.
For `UsergroupObject` field: `GuiAccess`.
For `UsergroupObject` field: `GuiAccess`.
For `UsergroupObject` field: `GuiAccess`.
For `UsergroupPermissionObject` field: `Permission`.
For `UsergroupPermissionObject` field: `Permission`.
For `UsergroupPermissionObject` field: `Permission`.
For `UsergroupObject` field: `UsersStatus`.
For `UsergroupObject` field: `UsersStatus`.
For `UsermacroObject` field: `Type`.
For `UsermacroObject` field: `Type`.
For `UserObject` field: `Theme`.
For `UserObject` field: `Theme`.
For `UserObject` field: `Theme`.
For `UserObject` field: `Type`.
For `UserObject` field: `Type`.
For `UserObject` field: `Type`.

# Variables

ErrNotFound describes an empty result set for an API call.

# Structs

ActionFilterConditionObject struct is used to store action filter conditions see: https://www.zabbix.com/documentation/5.0/manual/api/reference/action/object#action_filter_condition.
ActionFilterObject struct is used to store action filters see: https://www.zabbix.com/documentation/5.0/manual/api/reference/action/object#action_filter.
ActionGetParams struct is used for action get requests see: https://www.zabbix.com/documentation/5.0/manual/api/reference/action/get#parameters.
ActionObject struct is used to store action operations results see: https://www.zabbix.com/documentation/5.0/manual/api/reference/action/object#action.
ActionOpcommandGrpObject struct is used to store action opcommand groups.
ActionOpcommandHstObject struct is used to store action opcommand hosts.
ActionOperationCommandObject struct is used to store action operation commands see: https://www.zabbix.com/documentation/5.0/manual/api/reference/action/object#action_operation_command.
ActionOperationConditionObject struct is used to store action operation conditions see: https://www.zabbix.com/documentation/5.0/manual/api/reference/action/object#action_operation_condition.
ActionOperationMessageObject struct is used to store action operation messages see: https://www.zabbix.com/documentation/5.0/manual/api/reference/action/object#action_operation_message.
ActionOperationObject struct is used to store action operations see: https://www.zabbix.com/documentation/5.0/manual/api/reference/action/object#action_operation.
ActionOpgroupObject struct is used to store action opgroups.
ActionOpinventoryObject struct is used to store action opinventory.
ActionOpmessageGrpObject struct is used to store action opmessage groups.
ActionOpmessageUsrObject struct is used to store action opmessage users.
ActionOptemplateObject struct is used to store action optemplates.
ActionRecoveryOperationObject struct is used to store action recovery operations see: https://www.zabbix.com/documentation/5.0/manual/api/reference/action/object#action_recovery_operation.
ActionUpdateOperationObject struct is used to store action update operations see: https://www.zabbix.com/documentation/5.0/manual/api/reference/action/object#action_update_operation.
Context struct is used for store settings to communicate with Zabbix API.
GetParameters struct is used as embedded struct for some other structs within package see for details: https://www.zabbix.com/documentation/5.0/manual/api/reference_commentary#common_get_method_parameters.
HistoryFloatObject struct is used to store history float operations results see: https://www.zabbix.com/documentation/5.0/manual/api/reference/history/object#float_history.
HistoryGetParams struct is used for history get requests see: https://www.zabbix.com/documentation/5.0/manual/api/reference/history/get#parameters.
HistoryIntegerObject struct is used to store history integer operations results see: https://www.zabbix.com/documentation/5.0/manual/api/reference/history/object#integer_history.
HistoryLogObject struct is used to store history log operations results see: https://www.zabbix.com/documentation/5.0/manual/api/reference/history/object#log_history.
HistoryStringObject struct is used to store history string operations results see: https://www.zabbix.com/documentation/5.0/manual/api/reference/history/object#string_history.
HistoryTextObject struct is used to store history text operations results see: https://www.zabbix.com/documentation/5.0/manual/api/reference/history/object#text_history.
HostGetParams struct is used for host get requests see: https://www.zabbix.com/documentation/5.0/manual/api/reference/host/get#parameters.
HostgroupGetParams struct is used for hostgroup get requests see: https://www.zabbix.com/documentation/5.0/manual/api/reference/hostgroup/get#parameters.
HostgroupObject struct is used to store hostgroup operations results see: https://www.zabbix.com/documentation/5.0/manual/api/reference/hostgroup/object.
HostinterfaceDetailsTagObject struct is used to store hostinterface details see: https://www.zabbix.com/documentation/5.0/manual/api/reference/hostinterface/object#details_tag.
HostinterfaceGetParams struct is used for hostinterface get requests see: https://www.zabbix.com/documentation/5.0/manual/api/reference/hostinterface/get#parameters.
HostinterfaceObject struct is used to store hostinterface operations results see: https://www.zabbix.com/documentation/5.0/manual/api/reference/hostinterface/object#hostinterface.
HostObject struct is used to store host operations results see: https://www.zabbix.com/documentation/5.0/manual/api/reference/host/object#host.
HostTagObject struct is used to store host tag see: https://www.zabbix.com/documentation/5.0/manual/api/reference/host/object#host_tag.
Item represents a Zabbix Item returned from the Zabbix API.
No description provided by the author
MediaObject struct is used to store media operations results see: https://www.zabbix.com/documentation/5.0/manual/api/reference/user/object#media.
MediatypeGetParams struct is used for mediatype get requests see: https://www.zabbix.com/documentation/5.0/manual/api/reference/mediatype/get#parameters.
MediatypeMessageTemplateObject struct is used for mediatypes message template see: https://www.zabbix.com/documentation/5.0/manual/api/reference/mediatype/object#message_template.
MediatypeObject struct is used to store mediatype operations results see: https://www.zabbix.com/documentation/5.0/manual/api/reference/mediatype/object.
MediatypeWebhookParametersObject struct is used for mediatypes webhook parameters see: https://www.zabbix.com/documentation/5.0/manual/api/reference/mediatype/object#webhook_parameters.
TemplateGetParams struct is used for template get requests see: https://www.zabbix.com/documentation/5.0/manual/api/reference/template/get#parameters.
TemplateObject struct is used to store template operations results see: https://www.zabbix.com/documentation/5.0/manual/api/reference/template/object.
TemplateTagObject struct is used to store template tag data see: https://www.zabbix.com/documentation/5.0/manual/api/reference/template/object#template_tag.
UserDataObject struct is used to store authenticated user additional info see: https://www.zabbix.com/documentation/5.0/manual/api/reference/user/login#return_values.
UserGetParams struct is used for user get requests see: https://www.zabbix.com/documentation/5.0/manual/api/reference/user/get#parameters.
UsergroupGetParams struct is used for usergroup get requests see: https://www.zabbix.com/documentation/5.0/manual/api/reference/usergroup/get#parameters.
UsergroupObject struct is used to store usergroup operations results see: https://www.zabbix.com/documentation/5.0/manual/api/reference/usergroup/object#user_group.
UsergroupPermissionObject struct is used to store usergroup permissions see: https://www.zabbix.com/documentation/5.0/manual/api/reference/usergroup/object#permission.
UsergroupTagBasedPermissionObject struct is used to store usergroup tag based permission see: https://www.zabbix.com/documentation/5.0/manual/api/reference/usergroup/object#tag_based_permission.
UserLoginParams struct is used for login requests see: https://www.zabbix.com/documentation/5.0/manual/api/reference/user/login#parameters.
UsermacroGetParams struct is used for hostmacro get requests see: https://www.zabbix.com/documentation/5.0/manual/api/reference/usermacro/get#parameters.
UsermacroObject struct is used to store hostmacro and globalmacro operations results.
UserObject struct is used to store user operations results see: https://www.zabbix.com/documentation/5.0/manual/api/reference/user/object.

# Interfaces

SelectQuery is used as field type in some structs.

# Type aliases

SelectFields is used as field type in some structs.