2 -- ion/mod_statusbar/ion-statusd/statusd_load.lua
4 -- Copyright (c) Tuomo Valkonen 2004-2006.
6 -- Ion is free software; you can redistribute it and/or modify it under
7 -- the terms of the GNU Lesser General Public License as published by
8 -- the Free Software Foundation; either version 2.1 of the License, or
9 -- (at your option) any later version.
13 -- We should really use getloadavg(3) instead and move the meter to
14 -- Ion side to get properly up-to-date loads. But until such an export
15 -- is made, and we use potentially blocking files and external programs,
16 -- this meter must be in ion-statusd.
20 update_interval=10*1000,
22 important_threshold=1.5,
23 critical_threshold=4.0
26 local settings=table.join(statusd.get_config("load"), defaults)
30 local function get_hint(v)
33 if v>settings.critical_threshold then
35 elseif v>settings.important_threshold then
46 return string.format("%0.2f", l)
50 local function update_load()
51 local lds = statusd.getloadavg()
52 f1, f5, f15 = fmt(lds["1min"]), fmt(lds["5min"]), fmt(lds["15min"])
53 statusd.inform("load", f1..", "..f5..", "..f15)
54 statusd.inform("load_hint", get_hint(lds[settings.load_hint]))
55 statusd.inform("load_1min", f1)
56 statusd.inform("load_1min_hint", get_hint(lds["1min"]))
57 statusd.inform("load_5min", f5)
58 statusd.inform("load_5min_hint", get_hint(lds["5min"]))
59 statusd.inform("load_15min", f15)
60 statusd.inform("load_15min_hint", get_hint(lds["15min"]))
61 load_timer:set(settings.update_interval, update_load)
65 --statusd.inform("load_template", "0.00, 0.00, 0.00");
67 load_timer=statusd.create_timer()