commit: 9fd7c64f2e415074fa769621319eaee8d6183e2c
parent: 2980cbbc95f8ea2dab667c508af5eed183297337
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Sat, 8 Sep 2018 20:59:29 +0200
[Clairvoyance]: Add load_average and hostname
Diffstat:
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/lib/clairvoyance.ex b/lib/clairvoyance.ex
@@ -12,7 +12,9 @@ defmodule Clairvoyance do
services: services(),
filesystems: filesystems(),
memory: memory(),
- timestamp: timestamp()
+ timestamp: timestamp(),
+ load_average: load_average(),
+ hostname: hostname()
}
end
@@ -61,4 +63,14 @@ defmodule Clairvoyance do
DateTime.utc_now
|> DateTime.to_unix
end
+
+ def load_average() do
+ [:cpu_sup.avg1, :cpu_sup.avg5, :cpu_sup.avg15]
+ |> Enum.map(fn avg -> avg/256*100 end)
+ end
+
+ def hostname() do
+ :net_adm.localhost
+ |> List.to_string()
+ end
end