telegraf: Add package for telegraf
authorJonathan Pagel <jonny_tischbein@systemli.org>
Wed, 28 Jul 2021 07:33:15 +0000 (09:33 +0200)
committerNick Hainke <vincent@systemli.org>
Wed, 20 Oct 2021 16:58:03 +0000 (18:58 +0200)
Telegraf is a plugin-driven agent for collecting and sending metrics
and events. It supports various inputs (including prometheus
endpoints) and is able to send data into InfluxDB.
https://www.influxdata.com/time-series-platform/telegraf/

Signed-off-by: Jonathan Pagel <jonny_tischbein@systemli.org>
utils/telegraf/Makefile [new file with mode: 0644]
utils/telegraf/files/etc/init.d/telegraf [new file with mode: 0755]
utils/telegraf/variant-small/plugins/aggregators/all/all.go [new file with mode: 0644]
utils/telegraf/variant-small/plugins/inputs/all/all.go [new file with mode: 0644]
utils/telegraf/variant-small/plugins/outputs/all/all.go [new file with mode: 0644]
utils/telegraf/variant-small/plugins/processors/all/all.go [new file with mode: 0644]

diff --git a/utils/telegraf/Makefile b/utils/telegraf/Makefile
new file mode 100644 (file)
index 0000000..3bb9f1d
--- /dev/null
@@ -0,0 +1,84 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=telegraf
+PKG_VERSION:=1.19.1
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://codeload.github.com/influxdata/telegraf/tar.gz/v$(PKG_VERSION)?
+PKG_HASH:=cec43bb0acfff8b4c963ffec6e3eab44ffb52c8f34e6a697207977cfd05882aa
+
+PKG_MAINTAINER:=Jonathan Pagel <jonny_tischbein@systemli.org>
+PKG_LICENSE:=MIT
+PKG_LICENSE_FILES:=LICENSE
+
+PKG_BUILD_DEPENDS:=golang/host
+PKG_BUILD_PARALLEL:=1
+PKG_USE_MIPS16:=0
+
+GO_PKG:=github.com/influxdata/telegraf
+GO_PKG_BUILD_PKG:=github.com/influxdata/telegraf/cmd/telegraf
+GO_PKG_LDFLAGS_X:=main.version=$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+include ../../lang/golang/golang-package.mk
+
+define Package/telegraf/Default
+       SECTION:=utils
+       CATEGORY:=Utilities
+       TITLE:=Telegraf
+       DEPENDS:=$(GO_ARCH_DEPENDS)
+endef
+
+define Package/telegraf-full
+       $(call Package/telegraf/Default)
+       TITLE+= (Full)
+       VARIANT:=full
+endef
+
+define Package/telegraf
+       $(call Package/telegraf/Default)
+       TITLE+= (Small)
+       VARIANT:=small
+endef
+
+define Package/telegraf/description/Default
+       Telegraf is a plugin-driven agent for collecting and sending metrics and events.
+       It supports various inputs (including prometheus endpoints) and is able to send data into InfluxDB.
+endef
+
+define Package/telegraf/description
+       $(call Package/telegraf/description/Default)
+       (Small build. Most plugins excluded)
+endef
+
+define Package/telegraf-full/description
+       $(call Package/telegraf/description/Default)
+       (Full build. including all plugins)
+endef
+
+define Build/Prepare
+       $(call Build/Prepare/Default)
+ifeq ($(BUILD_VARIANT),small)
+       $(CP) ./variant-$(BUILD_VARIANT)/* $(PKG_BUILD_DIR)/
+endif
+endef
+
+define Package/telegraf/install
+       $(call GoPackage/Package/Install/Bin,$(1))
+       $(INSTALL_DIR) $(1)/etc/init.d $(1)/etc/config
+       $(INSTALL_BIN) ./files/etc/init.d/telegraf $(1)/etc/init.d/telegraf
+       $(INSTALL_DATA) $(PKG_BUILD_DIR)/etc/telegraf.conf $(1)/etc/config/telegraf.conf
+endef
+
+define Package/telegraf-full/install
+       $(call Package/telegraf/install,$(1))
+endef
+
+$(eval $(call GoBinPackage,telegraf))
+$(eval $(call BuildPackage,telegraf))
+
+$(eval $(call GoBinPackage,telegraf-full))
+$(eval $(call BuildPackage,telegraf-full))
diff --git a/utils/telegraf/files/etc/init.d/telegraf b/utils/telegraf/files/etc/init.d/telegraf
new file mode 100755 (executable)
index 0000000..9faef66
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh /etc/rc.common
+
+USE_PROCD=1
+
+START=95
+STOP=01
+
+start_service() {
+    procd_open_instance
+    procd_set_param command /usr/bin/telegraf --config /etc/config/telegraf.conf
+    procd_set_param stdout 1
+    procd_set_param stderr 1
+    procd_close_instance
+}
diff --git a/utils/telegraf/variant-small/plugins/aggregators/all/all.go b/utils/telegraf/variant-small/plugins/aggregators/all/all.go
new file mode 100644 (file)
index 0000000..001f130
--- /dev/null
@@ -0,0 +1,5 @@
+package all
+
+import (
+       //Blank imports for plugins to register themselves
+)
diff --git a/utils/telegraf/variant-small/plugins/inputs/all/all.go b/utils/telegraf/variant-small/plugins/inputs/all/all.go
new file mode 100644 (file)
index 0000000..1b30a03
--- /dev/null
@@ -0,0 +1,30 @@
+package all
+
+import (
+       //Blank imports for plugins to register themselves
+       _ "github.com/influxdata/telegraf/plugins/inputs/cpu"
+       _ "github.com/influxdata/telegraf/plugins/inputs/ethtool"
+       _ "github.com/influxdata/telegraf/plugins/inputs/internal"
+       _ "github.com/influxdata/telegraf/plugins/inputs/interrupts"
+       _ "github.com/influxdata/telegraf/plugins/inputs/ipset"
+       _ "github.com/influxdata/telegraf/plugins/inputs/iptables"
+       _ "github.com/influxdata/telegraf/plugins/inputs/kernel"
+       _ "github.com/influxdata/telegraf/plugins/inputs/mem"
+       _ "github.com/influxdata/telegraf/plugins/inputs/net"
+       _ "github.com/influxdata/telegraf/plugins/inputs/net_response"
+       _ "github.com/influxdata/telegraf/plugins/inputs/ping"
+       _ "github.com/influxdata/telegraf/plugins/inputs/processes"
+       _ "github.com/influxdata/telegraf/plugins/inputs/procstat"
+       _ "github.com/influxdata/telegraf/plugins/inputs/prometheus"
+       _ "github.com/influxdata/telegraf/plugins/inputs/sensors"
+       _ "github.com/influxdata/telegraf/plugins/inputs/snmp"
+       _ "github.com/influxdata/telegraf/plugins/inputs/socket_listener"
+       _ "github.com/influxdata/telegraf/plugins/inputs/swap"
+       _ "github.com/influxdata/telegraf/plugins/inputs/syslog"
+       _ "github.com/influxdata/telegraf/plugins/inputs/system"
+       _ "github.com/influxdata/telegraf/plugins/inputs/tail"
+       _ "github.com/influxdata/telegraf/plugins/inputs/tcp_listener"
+       _ "github.com/influxdata/telegraf/plugins/inputs/udp_listener"
+       _ "github.com/influxdata/telegraf/plugins/inputs/wireguard"
+       _ "github.com/influxdata/telegraf/plugins/inputs/wireless"
+)
diff --git a/utils/telegraf/variant-small/plugins/outputs/all/all.go b/utils/telegraf/variant-small/plugins/outputs/all/all.go
new file mode 100644 (file)
index 0000000..f0b7694
--- /dev/null
@@ -0,0 +1,12 @@
+package all
+
+import (
+       //Blank imports for plugins to register themselves
+       _ "github.com/influxdata/telegraf/plugins/outputs/exec"
+       _ "github.com/influxdata/telegraf/plugins/outputs/file"
+       _ "github.com/influxdata/telegraf/plugins/outputs/graphite"
+       _ "github.com/influxdata/telegraf/plugins/outputs/http"
+       _ "github.com/influxdata/telegraf/plugins/outputs/influxdb"
+       _ "github.com/influxdata/telegraf/plugins/outputs/prometheus_client"
+       _ "github.com/influxdata/telegraf/plugins/outputs/syslog"
+)
diff --git a/utils/telegraf/variant-small/plugins/processors/all/all.go b/utils/telegraf/variant-small/plugins/processors/all/all.go
new file mode 100644 (file)
index 0000000..001f130
--- /dev/null
@@ -0,0 +1,5 @@
+package all
+
+import (
+       //Blank imports for plugins to register themselves
+)