summaryrefslogtreecommitdiff
path: root/wm/ion3-devel/patches/patch-ad
blob: dd72069b195d10d59b94ae7c82924f62917f8d3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
$NetBSD: patch-ad,v 1.3 2006/08/14 22:42:04 wiz Exp $

--- mod_statusbar/ion-statusd/statusd_load.lua.orig	2006-05-24 16:23:26.000000000 +0000
+++ mod_statusbar/ion-statusd/statusd_load.lua
@@ -42,7 +42,7 @@ end
 local function get_load_uptime()
     local f=io.popen('uptime', 'r')
     if not f then
-        return "??"
+        return ""
     end
     local s=f:read('*l')
     f:close()
@@ -50,11 +50,30 @@ local function get_load_uptime()
     return (load or "")
 end
 
+local function get_load_sysctl()
+    local f=io.popen('sysctl -n vm.loadavg', 'r')
+    if not f then
+        return ""
+    end
+    local s=f:read('*l')
+    f:close()
+    local st, en, load=string.find(s, '^\{? ?(%d+%.%d+) %d+%.%d+ %d+%.%d+ ?\}?$')
+    return (load or "")
+end
+
+local function get_load_na()
+    return "(n/a)"
+end
+
 local function detect_load_fn()
     if get_load_proc()~="" then
         return get_load_proc
-    else
+    elseif get_load_uptime()~="" then
         return get_load_uptime
+    elseif get_load_sysctl()~="" then
+        return get_load_sysctl
+    else
+        return get_load_na
     end
 end