Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load external plugins -- plugin: not implemented #7027

Closed
mildebrandt opened this issue Feb 14, 2020 · 6 comments
Closed

Unable to load external plugins -- plugin: not implemented #7027

mildebrandt opened this issue Feb 14, 2020 · 6 comments
Labels
discussion Topics for discussion docs Issues related to Telegraf documentation and configuration descriptions

Comments

@mildebrandt
Copy link

When attempting to load an external plugin, I get the following error message:

2020-02-14T23:23:54Z I! Loading external plugins from: /usr/lib/telegraf-plugins/
2020-02-14T23:23:54Z E! error loading /usr/lib/telegraf-plugins/telegraf-plugins.so: plugin: not implemented

I built telegraf with the goplugin build tag and built a sample external plugin based on https://github.com/danielnelson/telegraf-plugins.

Here are the instructions to reproduce the error, also outlined at https://github.com/mildebrandt/telegraf-plugins/blob/master/README.md:

build telegraf

go get github.com/influxdata/telegraf/
cd ~/go/src/github.com/influxdata/telegraf/
git checkout 1.13.3
make
./scripts/build.py --package --platform=linux --arch=amd64 --build-tags=goplugin

package telegraf in a container

go get github.com/mildebrandt/telegraf-plugins/
cd ~/go/src/github.com/mildebrandt/telegraf-plugins/
cp ~/go/src/github.com/influxdata/telegraf/build/telegraf_1.13.3-1_amd64.deb ./telegraf
make telegraf

run the plugin

make
docker run -it --rm --name=telegraf -v $PWD/telegraf.conf:/etc/telegraf/telegraf.conf:ro -v $PWD/telegraf-plugins.so:/usr/lib/telegraf-plugins/telegraf-plugins.so:ro telegraf:plugin-support --test
@mildebrandt
Copy link
Author

Hi @danielnelson , I tried to use your sample plugin code to try out external plugin support and ran into issues. Is it something I'm doing wrong?

@danielnelson
Copy link
Contributor

I think the package telegraf in a container section doesn't look right. Long term you will probably want a Dockerfile, but for testing you could mount the .deb into the official image with -v, then install your custom package and start telegraf:

dpkg -P telegraf
dpkg -i telegraf_1.13.3-1_amd64.deb
telegraf --test

Let me know the exact spot or error you get.

@mildebrandt
Copy link
Author

The make target, telegraf, uses a Dockerfile to install the .deb. The Dockerfile was taken from https://github.com/influxdata/influxdata-docker/tree/master/telegraf/1.13 and modified to use the local .deb copied from the output of the build telegraf step. I also modified the entrypoint.sh to specify the --plugin-directory:

#!/bin/bash
set -e

if [ "${1:0:1}" = '-' ]; then
    set -- telegraf --plugin-directory /usr/lib/telegraf-plugins/ "$@"
fi

exec "$@"

Hopefully that makes sense, and thanks for your help.

@mildebrandt
Copy link
Author

Sorry, it's probably not clear that I forked your repo and added a few things to make for easy reproduction. My repo is: https://github.com/mildebrandt/telegraf-plugins

@danielnelson
Copy link
Contributor

I think you need CGO_ENABLED=1 on the telegraf build, it turns out that this is required but doesn't appear to be enabled in the .deb checked in to your repo. This should be the default if you build on a Linux system.

golang/go#19569

@mildebrandt
Copy link
Author

Thanks @danielnelson , enabling cgo did work. Here's the updated process that works:

mkdir ~/golinux
docker run -it -e CGO_ENABLED=1 -v ~/golinux:/go --rm golang:1.13.8 /bin/bash
apt-get update
apt-get install go-dep ruby-dev build-essential rpm -y
gem install --no-document fpm
go get github.com/influxdata/telegraf/
cd /go/src/github.com/influxdata/telegraf/
git checkout 1.13.3
./scripts/build.py --package --platform=linux --arch=amd64 --build-tags=goplugin
go get github.com/mildebrandt/telegraf-plugins/
cd /go/src/github.com/mildebrandt/telegraf-plugins/
make
exit

cd ~/golinux/src/github.com/mildebrandt/telegraf-plugins/
cp ~/golinux/src/github.com/influxdata/telegraf/build/telegraf_1.13.3-1_amd64.deb ./telegraf
make telegraf
docker run -it --rm --name=telegraf -v $PWD/telegraf.conf:/etc/telegraf/telegraf.conf:ro -v $PWD/telegraf-plugins.so:/usr/lib/telegraf-plugins/telegraf-plugins.so:ro telegraf:plugin-support --test

Which gives the following output:

2020-02-15T18:42:51Z I! Loading external plugins from: /usr/lib/telegraf-plugins/
2020-02-15T18:42:52Z I! Starting Telegraf 1.13.3
2020-02-15T18:42:52Z I! Using config file: /etc/telegraf/telegraf.conf
> example,host=844c7979cfd8,source=844c7979cfd8 value=123i 1581792173000000000

Thanks for your help!

@danielnelson danielnelson added discussion Topics for discussion docs Issues related to Telegraf documentation and configuration descriptions labels Feb 18, 2020
balazsgrill added a commit to home2mqtt/wscgo that referenced this issue May 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Topics for discussion docs Issues related to Telegraf documentation and configuration descriptions
Projects
None yet
Development

No branches or pull requests

2 participants