Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
2
Task/Host-introspection/OCaml/host-introspection-1.ocaml
Normal file
2
Task/Host-introspection/OCaml/host-introspection-1.ocaml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
Printf.printf "%d\n" Sys.word_size; (* Print word size *)
|
||||
Printf.printf "%s\n" Sys.os_type; (* Print operating system *)
|
||||
2
Task/Host-introspection/OCaml/host-introspection-2.ocaml
Normal file
2
Task/Host-introspection/OCaml/host-introspection-2.ocaml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(* Print endianness *)
|
||||
Printf.printf "%s\n" (if Sys.big_endian then "big endian" else "little endian");
|
||||
8
Task/Host-introspection/OCaml/host-introspection-3.ocaml
Normal file
8
Task/Host-introspection/OCaml/host-introspection-3.ocaml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
let uname arg =
|
||||
let arg = if arg = "" then "-" else arg in
|
||||
let ic = Unix.open_process_in ("uname -" ^ arg) in
|
||||
(input_line ic)
|
||||
;;
|
||||
|
||||
# uname "sm";;
|
||||
- : string = "Linux i686"
|
||||
34
Task/Host-introspection/OCaml/host-introspection-4.ocaml
Normal file
34
Task/Host-introspection/OCaml/host-introspection-4.ocaml
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
(* Reading all the lines from a file.
|
||||
If the loop is implemented by a recursive auxiliary function, the try...with breaks
|
||||
tail recursion if not written carefully *)
|
||||
let lines name =
|
||||
let f = open_in name
|
||||
and r = ref []
|
||||
in
|
||||
(try
|
||||
while true do
|
||||
r := (input_line f)::!r
|
||||
done
|
||||
with End_of_file -> close_in f);
|
||||
(List.rev !r)
|
||||
;;
|
||||
|
||||
# lines "/proc/meminfo";;
|
||||
- : string list =
|
||||
["MemTotal: 2075240 kB"; "MemFree: 469964 kB";
|
||||
"Buffers: 34512 kB"; "Cached: 1296380 kB";
|
||||
"SwapCached: 96 kB"; "Active: 317484 kB";
|
||||
"Inactive: 1233500 kB"; "HighTotal: 1178432 kB";
|
||||
"HighFree: 45508 kB"; "LowTotal: 896808 kB";
|
||||
"LowFree: 424456 kB"; "SwapTotal: 2650684 kB";
|
||||
"SwapFree: 2650588 kB"; "Dirty: 228 kB";
|
||||
"Writeback: 0 kB"; "AnonPages: 220036 kB";
|
||||
"Mapped: 67160 kB"; "Slab: 41540 kB";
|
||||
"SReclaimable: 34872 kB"; "SUnreclaim: 6668 kB";
|
||||
"PageTables: 1880 kB"; "NFS_Unstable: 0 kB";
|
||||
"Bounce: 0 kB"; "WritebackTmp: 0 kB";
|
||||
"CommitLimit: 3688304 kB"; "Committed_AS: 549912 kB";
|
||||
"VmallocTotal: 114680 kB"; "VmallocUsed: 5172 kB";
|
||||
"VmallocChunk: 109320 kB"; "HugePages_Total: 0";
|
||||
"HugePages_Free: 0"; "HugePages_Rsvd: 0";
|
||||
"HugePages_Surp: 0"; "Hugepagesize: 4096 kB"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue