From abaca50b5775bfe18104580598877312ee8876d3 Mon Sep 17 00:00:00 2001 From: Sven Roederer Date: Mon, 10 Jun 2019 15:13:43 +0200 Subject: [PATCH 1/2] librouteros: add package librouteros is a library to communicate with RouterOS, the operating system of MikroTik's RouterBoards. It uses the API port provided by those systems to connect and talk to the devices. API connections must be explicitly enabled. To do so, issue the following command: > /ip service enable api Signed-off-by: Sven Roederer --- libs/librouteros/Makefile | 54 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 libs/librouteros/Makefile diff --git a/libs/librouteros/Makefile b/libs/librouteros/Makefile new file mode 100644 index 000000000..2908de077 --- /dev/null +++ b/libs/librouteros/Makefile @@ -0,0 +1,54 @@ +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=librouteros +PKG_SOURCE_DATE:=2018-07-19 +PKG_SOURCE_VERSION:=c485c777ffbbbd87c3d72d843af36ba016803cae +PKG_RELEASE:=1 + +PKG_MAINTAINER:=Sven Roederer +PKG_LICENSE:=ISC +PKG_LICENSE_FILES:=COPYING + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_DATE).tar.gz +PKG_SOURCE_URL:=https://codeload.github.com/octo/librouteros/tar.gz/$(PKG_SOURCE_VERSION)? +PKG_HASH:=427e071fe270ff6c08e32a10e5beff2add4205e6c864b142f950efdb8d2245a4 +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_SOURCE_VERSION) + +PKG_FIXUP:=autoreconf +PKG_INSTALL:=1 +PKG_BUILD_PARALLEL:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/librouteros + TITLE:=A library that talks to MikroTik devices. + URL:=https://octo.github.io/librouteros/ + SECTION:=libs + CATEGORY:=Libraries +endef + +define Package/librouteros/description + librouteros is a library to communicate with RouterOS, the operating system of MikroTik's RouterBoards. + It uses the API port provided by those systems to connect and talk to the devices. librouteros is a + low-level library in that it abstracts the network protocol used but has next to no knowledge about the + commands and responses available +endef + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_INSTALL_DIR)/usr/include/routeros_*.h $(1)/usr/include/ + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/librouteros.{a,la,so*} $(1)/usr/lib/ +endef + +define Package/librouteros/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/librouteros.so.* $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,librouteros)) From 4261f45734d13eb0f2b552b84cf2fac6d7875a6e Mon Sep 17 00:00:00 2001 From: Sven Roederer Date: Mon, 10 Jun 2019 15:18:26 +0200 Subject: [PATCH 2/2] collectd: build RouterOS modules This allows collectd to get data of Mikrotik devices in a improved way than via SNMP. Signed-off-by: Sven Roederer --- utils/collectd/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils/collectd/Makefile b/utils/collectd/Makefile index b1f26cf54..94511271e 100644 --- a/utils/collectd/Makefile +++ b/utils/collectd/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=collectd PKG_VERSION:=5.9.0 -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=https://collectd.org/files/ \ @@ -83,7 +83,6 @@ COLLECTD_PLUGINS_DISABLED:= \ pinba \ python \ redis \ - routeros \ rrdcached \ serial \ sigrok \ @@ -165,6 +164,7 @@ COLLECTD_PLUGINS_SELECTED:= \ powerdns \ processes \ protocols \ + routeros \ rrdtool \ sensors \ snmp \ @@ -406,6 +406,7 @@ $(eval $(call BuildPlugin,postgresql,PostgreSQL status input,postgresql,+PACKAGE $(eval $(call BuildPlugin,powerdns,PowerDNS server status input,powerdns,)) $(eval $(call BuildPlugin,processes,process status input,processes,+PACKAGE_collectd-mod-processes:libmnl)) $(eval $(call BuildPlugin,protocols,network protocols input,protocols,)) +$(eval $(call BuildPlugin,routeros,MikroTik RouterOS input,routeros,+PACKAGE_collectd-mod-routeros:librouteros)) $(eval $(call BuildPlugin,rrdtool,RRDtool output,rrdtool,+PACKAGE_collectd-mod-rrdtool:librrd1)) $(eval $(call BuildPlugin,sensors,lm_sensors input,sensors,+PACKAGE_collectd-mod-sensors:libsensors)) $(eval $(call BuildPlugin,snmp,SNMP input,snmp,+PACKAGE_collectd-mod-snmp:libnetsnmp))