modulepackage
0.0.0-20200317094704-954f851c25d8
Repository: https://github.com/vadimipatov/go-zabbix.git
Documentation: pkg.go.dev
# README
go-zabbix
Go bindings for the Zabbix API
Overview
This project provides bindings to interoperate between programs written in Go language and the Zabbix monitoring API.
A number of Zabbix API bindings already exist for Go with varying levels of
maturity. This project aims to provide an alternative implementation which is
stable, fast, and allows for loose typing (using types such as interface{}
or
map[string]interface{}
) as well as strong types (such as Host
or Event
).
The package aims to have comprehensive coverage of Zabbix API methods from v1.8 through to v3.0 without introducing limitations to the native API methods.
Getting started
package main
import (
"fmt"
"time"
"github.com/cavaliercoder/go-zabbix"
)
func main() {
// Default approach - without session caching
session, err := zabbix.NewSession("http://zabbix/api_jsonrpc.php", "Admin", "zabbix")
if err != nil {
panic(err)
}
// Use session builder with caching.
// You can use own cache by implementing SessionAbstractCache interface
cache := zabbix.NewSessionFileCache().SetFilePath("./zabbix_session")
session, err := zabbix.CreateClient("http://zabbix/api_jsonrpc.php").
WithCache(cache).
WithCredentials("Admin", "zabbix").
WithTimeout(5 * time.Second).
Connect()
fmt.Printf("Connected to Zabbix API v%s", session.Version())
}
License
Released under the GNU GPL License
# Functions
CreateClient creates a Zabbix API client builder.
NewRequest returns a new Request given an API method name, and optional request body parameters.
NewSession returns a new Session given an API connection URL and an API username and password.
NewSessionFileCache creates a new instance of session file system cache.
# Constants
ActionEvalTypeAnd indicated that an Action will evaluate its conditions using AND bitwise logic.
ActionEvalTypeAndOr indicated that an Action will evaluate its conditions using AND/OR bitwise logic.
ActionEvalTypeOr indicated that an Action will evaluate its conditions using OR bitwise logic.
AlertCommandStatusAgentUnavailable indicates that an Alert of type AlertTypeRemoteCommand failed to run as the Zabbix Agent was unavailable.
AlertCommandStatusRun indicates that an Alert of type AlertTypeRemoteCommand has been run.
AlertMessageStatusFailed indicates that an Alert of type AlertTypeMessage failed to send.
AlertMessageStatusNotSent indicates that an Alert of type AlertTypeMessage has not been sent yet.
AlertMessageStatusSent indicates that an Alert of type AlertTypeMessage has been sent successfully.
AlertTypeMessage indicates that an Alert is a notification message.
AlertTypeRemoteCommand indicates that an Alert is a remote command call.
DiscoveryEventValueDiscovered indicates that the Host or Service related to an Event with Source type EventSourceDiscoveryRule is in a "Discovered" state.
DiscoveryEventValueDown indicates that the Host or Service related to an Event with Source type EventSourceDiscoveryRule is in a "Down" state.
DiscoveryEventValueLost indicates that the Host or Service related to an Event with Source type EventSourceDiscoveryRule is in a "Lost" state.
DiscoveryEventValueUp indicates that the Host or Service related to an Event with Source type EventSourceDiscoveryRule is in an "Up" state.
EventObjectTypeAutoRegisteredHost indicates that an Event with Source type EventSourceAutoRegistration is related to an auto-registered Host.
EventObjectTypeDiscoveredHost indicates that an Event with Source type EventSourceDiscoveryRule is related to a discovered Host.
EventObjectTypeDiscoveredService indicates that an Event with Source type EventSourceDiscoveryRule is related to a discovered Service.
EventObjectTypeItem indicates that an Event with Source type EventSourceInternal is related to an Item.
EventObjectTypeLLDRule indicates that an Event with Source type EventSourceInternal is related to a low-level Discovery Rule.
EventObjectTypeTrigger indicates that an Event with Source type EventSourceTrigger or EventSourceInternal is related to a Trigger.
EventSourceAutoRegistration indicates that an Event was created by an active Host registration rule.
EventSourceDiscoveryRule indicates than an Event was created by a Discovery Rule.
EventSourceInternal indicates that an Event was created by an Internal Event.
EventSourceTrigger indicates that an Event was created by a Trigger.
No description provided by the author
No description provided by the author
No description provided by the author
HostgroupInternalNo indicates that a Hostgroup is used not internally by the system.
HostgroupInternalYes indicates that a Hostgroup is used internally by the system.
HostgroupSourceDiscovery indicates that a Hostgroup was created by Host discovery.
HostgroupSourcePlain indicates that a Hostgroup was created in the normal way.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
HostSourceDefault indicates that a Host was created in the normal way.
HostSourceDiscovery indicates that a Host was created by Host discovery.
No description provided by the author
No description provided by the author
InternalEventValueNormal indicates that the Object related to an Event with Source type EventSourceInternal is in a "Normal" state.
InternalEventValueNotSupported indicates that the Object related to an Event with Source type EventSourceInternal is in an "Unknown" or "Not supported" state.
SelectCount may be given as a SelectQuery for supported search parameters to return only the number of available search results, instead of the search result details.
SelectExtendedOutput may be given as a SelectQuery in search parameters to return all available feilds for all objects in the search results.
SortOrderAscending is a valid value for GetParameters.SortOrder and causes an API query to return all results sorted in ascending order by the fields specified in GetParmeters.SortField.
SortOrderDescending is a valid value for GetParameters.SortOrder and causes an API query to return all results sorted in descending order by the fields specified in GetParmeters.SortField.
TriggerAlarmStateOK means a normal trigger state.
TriggerAlarmStateProblem normally means that something happened.
TriggerEventValueOK indicates that the Object related to an Event with Source type EventSourceTrigger is in an "OK" state.
TriggerEventValueProblem indicates that the Object related to an Event with Source type EventSourceTrigger is in a "Problem" state.
TriggerSeverityAverage is Average severity.
TriggerSeverityDisaster is Disaster severity.
TriggerSeverityHigh is High severity.
TriggerSeverityInformation is Information severity.
TriggerSeverityNotClassified is Not classified severity.
TriggerSeverityWarning is Warning severity.
TriggerStateNormal means normal trigger state.
TriggerStateUnknown means unknown trigger state.
# Variables
ErrNotFound describes an empty result set for an API call.
# Structs
Action represents a Zabbix Action returned from the Zabbix API.
ActionCondition is action condition.
ActionGetParams is query params for action.get call.
ActionOperation is action operation.
Alert represents a Zabbix Alert returned from the Zabbix API.
AlertGetParams is query params for alert.get call.
APIError represents a Zabbix API error.
ClientBuilder is Zabbix API client builder.
Event represents a Zabbix Event returned from the Zabbix API.
EventGetParams is query params for event.get call.
GetParameters represents the common parameters for all API Get methods.
Host represents a Zabbix Host returned from the Zabbix API.
No description provided by the author
HostGetParams represent the parameters for a `host.get` API call.
Hostgroup represents a Zabbix Hostgroup Object returned from the Zabbix API (see zabbix documentation).
HostgroupGetParams represent the parameters for a `hostgroup.get` API call (see zabbix documentation).
HostInterface represents a Zabbix HostInterface returned from the Zabbix API.
HostInterfaceGetParams represent the parameters for a `hostinterface.get` API call.
HostMacro represents a Zabbix Host Macro returned from the Zabbix API.
HostResponse represent host action response body.
No description provided by the author
A Request represents a JSON-RPC request to be sent by a client.
Response represents the response from a JSON-RPC API request.
A Session is an authenticated Zabbix JSON-RPC API client.
SessionFileCache is Zabbix session filesystem cache.
No description provided by the author
TemplateGetParams represent the parameters for a `template.get` API call.
Trigger represents a Zabbix Trigger returned from the Zabbix API.
TriggerGetParams is params for trigger.get query.
TriggerTag is trigger tag.
UserMacroGetParams represent the parameters for a `usermacro.get` API call (see zabbix documentation).
UserMacroResponse represent usermacro action response body.
# Interfaces
SelectQuery represents the query data type for a Zabbix API call.
SessionAbstractCache represents abstract Zabbix session cache backend.
# Type aliases
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
SelectFields may be given as a SelectQuery in search parameters where each member string is the name of a JSON field which should be returned for each search result.
No description provided by the author