Skip to content

Commit 6d210ad

Browse files
author
Markus Hube
committed
formating accoding to shfmt and stylua
Signed-off-by: Markus Hube <[email protected]~>
1 parent 3a81db1 commit 6d210ad

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

utils/prometheus-node-exporter-lua/files/etc/init.d/prometheus-node-exporter-lua

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ start_service() {
1919
config_get port "main" listen_port 9100
2020

2121
[ "$interface" = "*" ] || {
22-
network_get_ipaddr bind4 "$interface"
22+
network_get_ipaddr bind4 "$interface"
2323
network_get_ipaddr6 bind6 "$interface"
2424
[ -n "$bind4$bind6" ] || {
2525
_log "defering start until listen interface $interface becomes ready"
2626
return 0
2727
}
28-
}
28+
}
2929

3030
procd_open_instance
3131

@@ -46,8 +46,7 @@ start_service() {
4646
procd_close_instance
4747
}
4848

49-
service_triggers()
50-
{
49+
service_triggers() {
5150
local interface
5251

5352
procd_add_reload_trigger "prometheus-node-exporter-lua"

utils/prometheus-node-exporter-lua/files/usr/bin/prometheus-node-exporter-lua

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function get_contents(filename)
2222
local f = io.open(filename, "rb")
2323
local contents = ""
2424
if f then
25-
contents = f:read "*a"
25+
contents = f:read("*a")
2626
f:close()
2727
end
2828

@@ -34,8 +34,8 @@ end
3434
function print_metric(metric, labels, value)
3535
local label_string = ""
3636
if labels then
37-
for label,value in pairs(labels) do
38-
label_string = label_string .. label .. '="' .. value .. '",'
37+
for label, value in pairs(labels) do
38+
label_string = label_string .. label .. '="' .. value .. '",'
3939
end
4040
label_string = "{" .. string.sub(label_string, 1, -2) .. "}"
4141
end
@@ -67,10 +67,10 @@ end
6767
function run_all_collectors(collectors)
6868
local metric_duration = metric("node_scrape_collector_duration_seconds", "gauge")
6969
local metric_success = metric("node_scrape_collector_success", "gauge")
70-
for _,cname in pairs(collectors) do
70+
for _, cname in pairs(collectors) do
7171
if col_mods[cname] ~= nil then
7272
local duration, success = timed_scrape(col_mods[cname])
73-
local labels = {collector=cname}
73+
local labels = { collector = cname }
7474
metric_duration(labels, duration)
7575
metric_success(labels, success)
7676
end
@@ -80,7 +80,7 @@ end
8080
-- Web server-specific functions
8181

8282
function handle_request(env)
83-
if env.PATH_INFO ~= '/metrics' then
83+
if env.PATH_INFO ~= "/metrics" then
8484
uhttpd.send("Status: 404 Not Found\r\n")
8585
uhttpd.send("Server: lua-metrics\r\n")
8686
uhttpd.send("Content-Type: text/plain\r\n\r\n")
@@ -91,7 +91,7 @@ function handle_request(env)
9191
uhttpd.send("Content-Type: text/plain; version=0.0.4\r\n\r\n")
9292
local cols = {}
9393
for c in env.QUERY_STRING:gmatch("collect[^=]*=([^&]+)") do
94-
cols[#cols+1] = c
94+
cols[#cols + 1] = c
9595
end
9696
if #cols == 0 then
9797
cols = col_names
@@ -107,12 +107,14 @@ col_names = {}
107107
ls_fd = io.popen("ls -1 /usr/lib/lua/prometheus-collectors/*.lua")
108108
for c in ls_fd:lines() do
109109
c = c:match("([^/]+)%.lua$")
110-
col_mods[c] = require('prometheus-collectors.'..c)
111-
col_names[#col_names+1] = c
110+
col_mods[c] = require("prometheus-collectors." .. c)
111+
col_names[#col_names + 1] = c
112112
end
113113
ls_fd:close()
114114

115-
output = function (str) uhttpd.send(str.."\n") end
115+
output = function(str)
116+
uhttpd.send(str .. "\n")
117+
end
116118

117119
if arg ~= nil then
118120
output = print

0 commit comments

Comments
 (0)