1 -- Authors: Sadrul Habib Chowdhury <imadil@gmail.com>
2 -- License: Public domain
3 -- Last Changed: Unknown
8 -- Sadrul Habib Chowdhury (Adil)
9 -- imadil at gmail dot com
12 -- how often should the monitor be updated?
15 if not statusd_uptime
then
21 local timer
= nil -- the timer
24 -- update the uptime monitor
26 local function get_uptime_info()
27 local f
=io
.popen('uptime', 'r')
28 timer
:set(statusd_uptime
.interval
, get_uptime_info
)
30 statusd
.inform("uptime", "oops")
33 local s
=f
:read('*line')
36 s
= string.gsub(s
, ", +%d+ user.+", "") -- unnecessary
37 s
= string.gsub(s
, "%d+:%d+:%d+ up +", "") -- time is unnecessary
39 statusd
.inform("uptime", s
)
45 local function init_uptime_monitor()
46 timer
= statusd
.create_timer()
47 statusd
.inform("uptime_template", "xxxxxxxxxxxxxxx")