experimental erlang driver
This commit is contained in:
1 parent
0cecd10a4d
commit
22c0d9e356
17 files changed
+858
-1
No files matched your search
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env escript
|
||||
|
||||
-include(sigar).
|
||||
|
||||
main(_) ->
|
||||
{ok, S} = sigar:start(),
|
||||
{ok, FsList} = sigar:file_system_list(S),
|
||||
lists:map(
|
||||
fun(Fs) ->
|
||||
io:format("~s ~n", [sigar:get_value(dir_name, Fs)]) end,
|
||||
FsList),
|
||||
sigar:stop(S).
|
||||
|
||||
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env escript
|
||||
|
||||
-include(sigar).
|
||||
|
||||
main(_) ->
|
||||
{ok, S} = sigar:start(),
|
||||
{ok, Mem} = sigar:mem(S),
|
||||
io:format("\tTotal\tUsed\tFree~n"),
|
||||
io:format("Mem: "),
|
||||
lists:map(
|
||||
fun(K) ->
|
||||
io:format("~w\t", [sigar:get_value(K, Mem)/1024]) end,
|
||||
[total, used, free]),
|
||||
io:format("~n"),
|
||||
{ok, Swap} = sigar:swap(S),
|
||||
io:format("Swap: "),
|
||||
lists:map(
|
||||
fun(K) ->
|
||||
io:format("~w\t", [sigar:get_value(K, Swap)/1024]) end,
|
||||
[total, used, free]),
|
||||
io:format("~n"),
|
||||
io:format("RAM: ~wMB~n", [sigar:get_value(ram, Mem)]),
|
||||
sigar:stop(S).
|
||||
|
||||
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env escript
|
||||
|
||||
-include(sigar).
|
||||
|
||||
main(_) ->
|
||||
{ok, S} = sigar:start(),
|
||||
{ok, Names} = sigar:net_interface_list(S),
|
||||
lists:map(
|
||||
fun(K) ->
|
||||
{ok, Ifconfig} = sigar:net_interface_config(S, K),
|
||||
io:format("~s ~s~n", [K, sigar:get_value(address, Ifconfig)]) end,
|
||||
Names),
|
||||
sigar:stop(S).
|
||||
|
||||
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env escript
|
||||
|
||||
-include(sigar).
|
||||
|
||||
main(_) ->
|
||||
{ok, S} = sigar:start(),
|
||||
{ok, Mem} = sigar:proc_mem(S, "$$"),
|
||||
io:format("Size\tResident~n"),
|
||||
lists:map(
|
||||
fun(K) ->
|
||||
io:format("~w\t", [sigar:get_value(K, Mem)/1024]) end,
|
||||
[size, resident]),
|
||||
io:format("~n"),
|
||||
sigar:stop(S).
|
||||
|
||||
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env escript
|
||||
|
||||
-include(sigar).
|
||||
|
||||
main(_) ->
|
||||
{ok, S} = sigar:start(),
|
||||
case sigar:loadavg(S) of
|
||||
{ok, Avg} ->
|
||||
lists:map(
|
||||
fun(A) ->
|
||||
io:format("~w% ", [A]) end,
|
||||
Avg);
|
||||
{error, Err} ->
|
||||
Err
|
||||
end,
|
||||
io:format("~n"),
|
||||
sigar:stop(S).
|
||||
|
||||
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env escript
|
||||
|
||||
-include(sigar).
|
||||
|
||||
main(_) ->
|
||||
{ok, S} = sigar:start(),
|
||||
{ok, List} = sigar:who_list(S),
|
||||
lists:map(
|
||||
fun(Who) ->
|
||||
lists:map(
|
||||
fun(K) ->
|
||||
io:format("~s\t", [sigar:get_value(K, Who)]) end,
|
||||
[user, device, host]),
|
||||
io:format("~n")
|
||||
end, List),
|
||||
sigar:stop(S).
|
||||
Reference in new issue
Block a user