[Mod] MTStat - server monitoring over http [mtstat]

Post Reply
timdorohin
New member
Posts: 7
Joined: Mon Sep 03, 2018 09:47
IRC: timdorohin

[Mod] MTStat - server monitoring over http [mtstat]

by timdorohin » Post

Image

MTStat - mod providing server status (number of players, average load, max_lag, memory usage) in JSON over http
You can use it with your monitoring system, host your own back-end instance that provide web page with interactive charts or use back-end that i host at http://mtstat.us.openode.io/ - ask in topic or PM me if you want your server monitored.

Depends: nothing, but it runs on Linux-based servers only.
Source: https://github.com/timdorohin/mtstat
Download: https://github.com/timdorohin/mtstat/archive/master.zip
Back-end source: https://github.com/timdorohin/mtstat-server
License: GPLv3

Requires adding to trusted mods and installed luasocket library!
Attachments
thumbnail.png
thumbnail.png (14.32 KiB) Viewed 521 times
Last edited by timdorohin on Sat Sep 15, 2018 20:55, edited 4 times in total.

User avatar
rubenwardy
Moderator
Posts: 6978
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: [Mod] MTStat - server status over http [mtstat]

by rubenwardy » Post

Don't tell people to disable security, this is very very very bad and never justified. Instead, use the mod whitelisting method. Your mod already supports this, the documentation is just wrong
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

timdorohin
New member
Posts: 7
Joined: Mon Sep 03, 2018 09:47
IRC: timdorohin

Re: [Mod] MTStat - server status over http [mtstat]

by timdorohin » Post

rubenwardy wrote:Don't tell people to disable security, this is very very very bad and never justified. Instead, use the mod whitelisting method. Your mod already supports this, the documentation is just wrong
Enabled mods security (mtstat added to trusted!)

Code: Select all

2018-09-14 18:31:27: ERROR[Main]: ModError: Failed to load and run script from /home/tim/.minetest/mods/mtstat/init.lua:
2018-09-14 18:31:27: ERROR[Main]: require() is disabled when mod security is on.
2018-09-14 18:31:27: ERROR[Main]: stack traceback:
2018-09-14 18:31:27: ERROR[Main]:       [C]: in function 'require'
2018-09-14 18:31:27: ERROR[Main]:       /usr/share/lua/5.1/socket.lua:10: in main chunk
2018-09-14 18:31:27: ERROR[Main]:       [C]: in function 'require'
2018-09-14 18:31:27: ERROR[Main]:       /home/tim/.minetest/mods/mtstat/init.lua:42: in main chunk
2018-09-14 18:31:27: ERROR[Main]: Check debug.txt for details.
It looks like a bug, so temporary i just disabled mod security. Yes, i know that this is bad idea, but i haven't found another workaround yet.

User avatar
rubenwardy
Moderator
Posts: 6978
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: [Mod] MTStat - server status over http [mtstat]

by rubenwardy » Post

You need to use the insecure environment version of require
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

timdorohin
New member
Posts: 7
Joined: Mon Sep 03, 2018 09:47
IRC: timdorohin

Re: [Mod] MTStat - server status over http [mtstat]

by timdorohin » Post

rubenwardy wrote:You need to use the insecure environment version of require
Piece of my code:

Code: Select all

local insecure = minetest.request_insecure_environment()
assert(insecure, "Add mtstat mod to trusted!")

... (skipped irrelevant parts)

local socket = insecure.require('socket') -- fails there.
assert(socket, 'Disable mod security!')
UPD: found how to work around this after reading irc mod code:

Code: Select all

old_require = require				-- Hacky hack
require = insecure.require			-- Setting global require to insecure 'cause
local socket = require('socket')	-- When we try to load any lib that uses require() itself
require = old_require -- We will get errors otherwise

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 31 guests