prometheus-node-exporter-lua: use io.lines(), remove line_split

Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com>
This commit is contained in:
Etienne Champetier
2017-12-08 19:03:37 -08:00
parent 84023027a2
commit ed7d60d871
4 changed files with 17 additions and 35 deletions

View File

@@ -8,27 +8,16 @@
socket = require("socket")
-- Allow us to call unpack under both lua5.1 and lua5.2+
local unpack = unpack or table.unpack
-- Parsing
function space_split(s)
elements = {}
local elements = {}
for element in s:gmatch("%S+") do
table.insert(elements, element)
end
return elements
end
function line_split(s)
elements = {}
for element in s:gmatch("[^\n]+") do
table.insert(elements, element)
end
return elements
end
function get_contents(filename)
local f = io.open(filename, "rb")
local contents = ""