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

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

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

by timdorohin » Fri Sep 14, 2018 12:38

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
(14.32 KiB) Not downloaded yet
Last edited by timdorohin on Sat Sep 15, 2018 20:55, edited 4 times in total.
 

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

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

by rubenwardy » Fri Sep 14, 2018 14:55

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
 

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

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

by timdorohin » Fri Sep 14, 2018 15:34

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: 5800
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
 

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

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

by timdorohin » Fri Sep 14, 2018 16:01

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
 


Return to Mod Releases



Who is online

Users browsing this forum: SiliconPenguin and 11 guests