payment: note that Stripe has instituted an additional 1% fee for non-US cards
[hcoop/portal.git] / stats.sml
index 72b5836..e8a9edf 100644 (file)
--- a/stats.sml
+++ b/stats.sml
@@ -1,8 +1,8 @@
 structure Stats :> STATS =
 struct
-   val webbw = "/etc/stats/webbw"
-   val webbw_last = "/etc/stats/webbw.last"
-   val webbw_last2 = "/etc/stats/webbw.last2"
+   val webbw = Config.statsRoot ^ "webbw"
+   val webbw_last = Config.statsRoot ^ "webbw.last"
+   val webbw_last2 = Config.statsRoot ^ "webbw.last2"
 
    type host = {ssl : bool,
                hostname : string,
@@ -89,7 +89,18 @@ struct
           before TextIO.closeIn inf
        end
 
-    type disk = {uname : string,
+   fun getWebbwUser {user, last} =
+       let
+          val {vhosts, users, ...} = getWebbw last
+       in
+          case List.find (fn {user = u, ...} => u = user) users of
+              NONE => {total = 0, vhosts = []}
+            | SOME {hosts, size, ...} =>
+              {total = size, vhosts = List.filter (fn {host, ...} => List.exists (fn host' => host' = host) hosts) vhosts}
+       end
+          
+
+   type disk = {uname : string,
                 kbs : int}
 
     structure StringKey = struct
@@ -101,7 +112,7 @@ struct
 
     fun getDiskUsage () =
        let
-           val proc = Unix.execute ("/bin/sh", ["-c", "/usr/bin/vos listvol deleuze"])
+           val proc = Unix.execute ("/bin/sh", ["-c", "/usr/bin/vos listvol gibran"])
            val inf = Unix.textInstreamOf proc
 
            fun loop acc =