2 -- ion/mod_statusbar/ion-statusd/statusd_load.lua
4 -- Copyright (c) Tuomo Valkonen 2004-2009.
6 -- See the included file LICENSE for details.
10 -- We should really use getloadavg(3) instead and move the meter to
11 -- Ion side to get properly up-to-date loads. But until such an export
12 -- is made, and we use potentially blocking files and external programs,
13 -- this meter must be in ion-statusd.
17 update_interval
=10*1000,
19 important_threshold
=1.5,
20 critical_threshold
=4.0
23 local settings
=table.join(statusd
.get_config("load"), defaults
)
27 local function get_hint(v
)
30 if v
>settings
.critical_threshold
then
32 elseif v
>settings
.important_threshold
then
43 return string.format("%0.2f", l
)
47 local function update_load()
48 local lds
= statusd
.getloadavg()
49 f1
, f5
, f15
= fmt(lds
["1min"]), fmt(lds
["5min"]), fmt(lds
["15min"])
50 statusd
.inform("load", f1
..", "..f5
..", "..f15
)
51 statusd
.inform("load_hint", get_hint(lds
[settings
.load_hint
]))
52 statusd
.inform("load_1min", f1
)
53 statusd
.inform("load_1min_hint", get_hint(lds
["1min"]))
54 statusd
.inform("load_5min", f5
)
55 statusd
.inform("load_5min_hint", get_hint(lds
["5min"]))
56 statusd
.inform("load_15min", f15
)
57 statusd
.inform("load_15min_hint", get_hint(lds
["15min"]))
58 load_timer
:set(settings
.update_interval
, update_load
)
62 --statusd.inform("load_template", "0.00, 0.00, 0.00");
64 load_timer
=statusd
.create_timer()