mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-14 15:24:52 +09:00
Rewrite statistics export
Add automatic export of metrics from slaves to the master server. And rewrite the statistics export plugin to use this new system.
This commit is contained in:
1 parent
8229d1955c
commit
26eefb0476
19 files changed
+334
-226
No files matched your search
@@ -0,0 +1,39 @@
|
||||
local statistics = {
|
||||
"item_production_statistics",
|
||||
"fluid_production_statistics",
|
||||
"kill_count_statistics",
|
||||
"entity_build_count_statistics",
|
||||
}
|
||||
|
||||
local function export()
|
||||
local stats = {
|
||||
game_tick = game.tick,
|
||||
player_count = #game.connected_players,
|
||||
game_flow_statistics = {
|
||||
pollution_statistics = {
|
||||
input = game.pollution_statistics.input_counts,
|
||||
output = game.pollution_statistics.output_counts,
|
||||
},
|
||||
},
|
||||
force_flow_statistics = {}
|
||||
}
|
||||
for _, force in pairs(game.forces) do
|
||||
local flow_statistics = {}
|
||||
for _, statName in pairs(statistics) do
|
||||
flow_statistics[statName] = {
|
||||
input = force[statName].input_counts,
|
||||
output = force[statName].output_counts,
|
||||
}
|
||||
end
|
||||
stats.force_flow_statistics[force.name] = flow_statistics
|
||||
end
|
||||
|
||||
|
||||
rcon.print(game.table_to_json(stats))
|
||||
end
|
||||
|
||||
return {
|
||||
add_remote_interface = function()
|
||||
remote.add_interface("statistics_exporter", { export = export })
|
||||
end
|
||||
}
|
||||
Reference in new issue
Block a user