Ad Widget

Collapse

Problems getting a Loadable Plugin to work

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • C.Morris
    Junior Member
    • Nov 2023
    • 9

    #1

    Problems getting a Loadable Plugin to work

    I'm having trouble with an example loadable plugin based on the Myip example.

    I was following the instructions here: (https://git.zabbix.com/projects/WEB/...gins/how_to.md) but with the following differences to the standard instructions:
    1. The instructions relate to a Unix environment - I'm running zabbix_agent2 on Windows Server 2022
    2. Our system is running on a network without access to the internet, so I downloaded the dependencies using 'go mod vendor' and transferred them over before building the .exe as described here: https://gist.github.com/gmolveau/f09...4d0579ba06ea96
    3. As the systems don't have access to the internet, I've stripped the plugin down so it simply returns a 'hello world' string (see the code below):
    I don't think it's related to this question: https://www.zabbix.com/forum/zabbix-...question-error, because of the differences listed above and the errors being output.

    The problem we have is when starting the agent2 after adding the new plugin to the configuration we get the following error:

    Click image for larger version

Name:	zabbix_agent2-01.png
Views:	317
Size:	150.0 KB
ID:	473752

    When started without the new plugin, the agent logfile appears normal. Nothing is added to the logfile when attempting to load the new plugin.

    I'm wondering if the versions of the plugin support files are incorrect for out zabbix version (captured in the screenshot below).

    Any thoughts or hints on how to fix this would be appreciated.

    Many thanks


    Code: main.go
    Code:
    package main
    
    import (
    "fmt"
    "git.zabbix.com/ap/plugin-support/plugin/container"
    "git.zabbix.com/ap/plugin-support/plugin"
    )
    
    type Plugin struct {
    plugin.Base
    }
    
    var impl Plugin
    
    func (p *Plugin) Export(key string, params []string, ctx plugin.ContextProvider) (result interface{}, err error) {
    return string("Hello World!"), nil
    }
    
    func init() {
    plugin.RegisterMetrics(&impl, "HelloWorld", "helloworld", "Return Hello World!.")
    }
    
    func main() {
    h, err := container.NewHandler(impl.Name())
    if err != nil {
    panic(fmt.Sprintf("Failed to create plugin handler: %s", err.Error()))
    }
    impl.Logger = &h
    
    err = h.Execute()
    if err != nil {
    panic(fmt.Sprintf("Failed to execute plugin handler: %s", err.Error()))
    }
    }​
    Code: go.mod
    Code:
    module helloworld
    
    go 1.21.3
    
    require git.zabbix.com/ap/plugin-support v1.2.1
    
    require github.com/natefinch/npipe v0.0.0-20160621034901-c1b8fa8bdcce // indirect


    Code: go.sum
    Code:
    git.zabbix.com/ap/plugin-support v1.2.1 h1:hinT04FY/4t6Hcx/Jvj2cyNggvfllQ2OvzyZCTf99o0=
    git.zabbix.com/ap/plugin-support v1.2.1/go.mod h1:R3QzQWgpxlA+ddJNkOhsPTcGOVtrR69WS0hXIsnBurY=
    github.com/natefinch/npipe v0.0.0-20160621034901-c1b8fa8bdcce h1:TqjP/BTDrwN7zP9xyXVuLsMBXYMt6LLYi55PlrIcq8U=
    github.com/natefinch/npipe v0.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:ifHPsLndGGzvgzcaXUvzmt6LxKT4pJ+uzEhtnMt+f7A=
    gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU=
    gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c=


    Click image for larger version

Name:	zabbix_agent2.conf.png
Views:	313
Size:	64.6 KB
ID:	473756

    Click image for larger version

Name:	helloworld.conf.png
Views:	310
Size:	39.8 KB
ID:	473757

    Click image for larger version

Name:	zabbix_agent2.version.png
Views:	312
Size:	270.2 KB
ID:	473758
    Attached Files
Working...