Merge pull request #8138 from TDT-AG/pr/20190206-collectd
collectd: enable lua support
This commit is contained in:
commit
6382a043b0
2 changed files with 55 additions and 3 deletions
|
@ -53,7 +53,6 @@ COLLECTD_PLUGINS_DISABLED:= \
|
||||||
ipvs \
|
ipvs \
|
||||||
java \
|
java \
|
||||||
log_logstash \
|
log_logstash \
|
||||||
lua \
|
|
||||||
lvm \
|
lvm \
|
||||||
lpar \
|
lpar \
|
||||||
madwifi \
|
madwifi \
|
||||||
|
@ -138,6 +137,7 @@ COLLECTD_PLUGINS_SELECTED:= \
|
||||||
iwinfo \
|
iwinfo \
|
||||||
load \
|
load \
|
||||||
logfile \
|
logfile \
|
||||||
|
lua \
|
||||||
match_empty_counter \
|
match_empty_counter \
|
||||||
match_hashed \
|
match_hashed \
|
||||||
match_regex \
|
match_regex \
|
||||||
|
@ -196,7 +196,11 @@ endef
|
||||||
|
|
||||||
define Package/collectd
|
define Package/collectd
|
||||||
$(call Package/collectd/Default)
|
$(call Package/collectd/Default)
|
||||||
DEPENDS:= +libpthread +zlib +libltdl +libip4tc
|
DEPENDS:= +libpthread \
|
||||||
|
+zlib \
|
||||||
|
+libltdl \
|
||||||
|
+libip4tc \
|
||||||
|
+PACKAGE_collectd-mod-lua:liblua
|
||||||
MENU:=1
|
MENU:=1
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
@ -226,7 +230,12 @@ CONFIGURE_ARGS+= \
|
||||||
CONFIGURE_VARS+= \
|
CONFIGURE_VARS+= \
|
||||||
CFLAGS="$$$$CFLAGS $(FPIC)" \
|
CFLAGS="$$$$CFLAGS $(FPIC)" \
|
||||||
LDFLAGS="$$$$LDFLAGS -lm -lz" \
|
LDFLAGS="$$$$LDFLAGS -lm -lz" \
|
||||||
KERNEL_DIR="$(LINUX_DIR)" \
|
KERNEL_DIR="$(LINUX_DIR)"
|
||||||
|
|
||||||
|
ifneq ($(CONFIG_PACKAGE_collectd-mod-lua),)
|
||||||
|
CONFIGURE_VARS+= \
|
||||||
|
LDFLAGS="$$$$LDFLAGS -llua"
|
||||||
|
endif
|
||||||
|
|
||||||
ifneq ($(CONFIG_PACKAGE_COLLECTD_ENCRYPTED_NETWORK),)
|
ifneq ($(CONFIG_PACKAGE_COLLECTD_ENCRYPTED_NETWORK),)
|
||||||
CONFIGURE_ARGS+= \
|
CONFIGURE_ARGS+= \
|
||||||
|
@ -360,6 +369,7 @@ $(eval $(call BuildPlugin,irq,interrupt usage input,irq,))
|
||||||
$(eval $(call BuildPlugin,iwinfo,libiwinfo wireless statistics,iwinfo,+PACKAGE_collectd-mod-iwinfo:libiwinfo))
|
$(eval $(call BuildPlugin,iwinfo,libiwinfo wireless statistics,iwinfo,+PACKAGE_collectd-mod-iwinfo:libiwinfo))
|
||||||
$(eval $(call BuildPlugin,load,system load input,load,))
|
$(eval $(call BuildPlugin,load,system load input,load,))
|
||||||
$(eval $(call BuildPlugin,logfile,log files output,logfile,))
|
$(eval $(call BuildPlugin,logfile,log files output,logfile,))
|
||||||
|
$(eval $(call BuildPlugin,lua,lua input/output,lua,+PACKAGE_collectd-mod-lua:liblua))
|
||||||
$(eval $(call BuildPlugin,match-empty-counter,empty-counter match,match_empty_counter,))
|
$(eval $(call BuildPlugin,match-empty-counter,empty-counter match,match_empty_counter,))
|
||||||
$(eval $(call BuildPlugin,match-hashed,hashed match,match_hashed,))
|
$(eval $(call BuildPlugin,match-hashed,hashed match,match_hashed,))
|
||||||
$(eval $(call BuildPlugin,match-regex,regex match,match_regex,))
|
$(eval $(call BuildPlugin,match-regex,regex match,match_regex,))
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
--- a/src/lua.c
|
||||||
|
+++ b/src/lua.c
|
||||||
|
@@ -281,9 +281,6 @@ static int lua_cb_register_read(lua_Stat
|
||||||
|
|
||||||
|
luaL_checktype(L, 1, LUA_TFUNCTION);
|
||||||
|
|
||||||
|
- char function_name[DATA_MAX_NAME_LEN];
|
||||||
|
- snprintf(function_name, sizeof(function_name), "lua/%s", lua_tostring(L, 1));
|
||||||
|
-
|
||||||
|
int callback_id = clua_store_callback(L, 1);
|
||||||
|
if (callback_id < 0)
|
||||||
|
return luaL_error(L, "%s", "Storing callback function failed");
|
||||||
|
@@ -298,6 +295,9 @@ static int lua_cb_register_read(lua_Stat
|
||||||
|
if (cb == NULL)
|
||||||
|
return luaL_error(L, "%s", "calloc failed");
|
||||||
|
|
||||||
|
+ char function_name[DATA_MAX_NAME_LEN];
|
||||||
|
+ snprintf(function_name, sizeof(function_name), "lua/%p", thread);
|
||||||
|
+
|
||||||
|
cb->lua_state = thread;
|
||||||
|
cb->callback_id = callback_id;
|
||||||
|
cb->lua_function_name = strdup(function_name);
|
||||||
|
@@ -325,9 +325,6 @@ static int lua_cb_register_write(lua_Sta
|
||||||
|
|
||||||
|
luaL_checktype(L, 1, LUA_TFUNCTION);
|
||||||
|
|
||||||
|
- char function_name[DATA_MAX_NAME_LEN] = "";
|
||||||
|
- snprintf(function_name, sizeof(function_name), "lua/%s", lua_tostring(L, 1));
|
||||||
|
-
|
||||||
|
int callback_id = clua_store_callback(L, 1);
|
||||||
|
if (callback_id < 0)
|
||||||
|
return luaL_error(L, "%s", "Storing callback function failed");
|
||||||
|
@@ -342,6 +339,9 @@ static int lua_cb_register_write(lua_Sta
|
||||||
|
if (cb == NULL)
|
||||||
|
return luaL_error(L, "%s", "calloc failed");
|
||||||
|
|
||||||
|
+ char function_name[DATA_MAX_NAME_LEN] = "";
|
||||||
|
+ snprintf(function_name, sizeof(function_name), "lua/%p", thread);
|
||||||
|
+
|
||||||
|
cb->lua_state = thread;
|
||||||
|
cb->callback_id = callback_id;
|
||||||
|
cb->lua_function_name = strdup(function_name);
|
Loading…
Reference in a new issue