summaryrefslogtreecommitdiff
path: root/ouptime/ouptime.ml
blob: 41b497c8abf5186179bb948d35fba3744e1243ba (plain) (blame)
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
open Arg

let default_procfs_dir = "/Process"
let default_uptime_path = ref (String.concat "" (List.append [default_procfs_dir] ["/uptime"]))

let set_uptime_path dir = default_uptime_path := (String.concat "" (List.append [dir] ["/uptime"]))

let read_data filename = 
    let ic = open_in filename in 
    try
        let line = input_line ic in 
        close_in ic;
        (line)
    with e ->
        close_in_noerr ic;
        raise e

let main = 
begin
    (*
    Printf.printf "%s\n" !default_uptime_path;
    *)
    let speclist = 
    [
        ("-p",Arg.String (set_uptime_path),"Procfs directory")
    ]
    in let usage_msg = "ouptime - show system uptime"
    in Arg.parse speclist print_endline usage_msg;
    Printf.printf "%s\n" !default_uptime_path;
    let uptime_string = read_data !default_uptime_path in
    print_endline uptime_string;
end


let () = main