Fixes and performance improvements
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
function GetPollutionStats()
|
||||
function SendPollutionStats()
|
||||
if not (settings.global["factorio-prometheus-exporter-export_pollution_stats"].value) then
|
||||
return
|
||||
end
|
||||
@@ -15,12 +15,41 @@ function GetPollutionStats()
|
||||
end
|
||||
|
||||
for name, stat in pairs(pollution_input) do
|
||||
pollutionParts[#pollutionParts+1] = ("%s:in:%s:%d"):format(name,surface_name, stat)
|
||||
pollutionParts[#pollutionParts+1] = ("%s:in:%s:%d"):format(surface_name,name, stat)
|
||||
end
|
||||
|
||||
for name, stat in pairs(pollution_output) do
|
||||
pollutionParts[#pollutionParts+1] = ("%s:out:%s:%d"):format(name,surface_name, stat)
|
||||
pollutionParts[#pollutionParts+1] = ("%s:out:%s:%d"):format(surface_name,name, stat)
|
||||
end
|
||||
helpers.send_udp(udpAddress, table.concat(pollutionParts,"\n"),serverIndex)
|
||||
|
||||
end
|
||||
helpers.send_udp(udpAddress, table.concat(pollutionParts,"\n"),serverIndex)
|
||||
end
|
||||
|
||||
function SendKillStats()
|
||||
if not (settings.global["factorio-prometheus-exporter-export_kill_stats"].value) then
|
||||
return
|
||||
end
|
||||
local killParts = {}
|
||||
killParts[#killParts+1] = "---kill-stats---\n"
|
||||
for _,surface in pairs(game.surfaces) do
|
||||
local surface_name = surface.name
|
||||
|
||||
local kill_input = game.forces["player"].get_kill_count_statistics(surface_name).input_counts
|
||||
local kill_output = game.forces["player"].get_kill_count_statistics(surface_name).output_counts
|
||||
|
||||
if surface.platform ~= nil then
|
||||
surface_name = surface.platform.name
|
||||
end
|
||||
|
||||
for name, stat in pairs(kill_input) do
|
||||
killParts[#killParts+1] = ("%s:in:%s:%d"):format(surface_name,name, stat)
|
||||
end
|
||||
|
||||
for name, stat in pairs(kill_output) do
|
||||
killParts[#killParts+1] = ("%s:out:%s:%d"):format(surface_name,name, stat)
|
||||
end
|
||||
|
||||
end
|
||||
helpers.send_udp(udpAddress, table.concat(killParts,"\n"),serverIndex)
|
||||
end
|
||||
Reference in New Issue
Block a user