marionnet-dev team mailing list archive
-
marionnet-dev team
-
Mailing list archive
-
Message #00681
[Branch ~marionnet-drivers/ocamlbricks/trunk] Rev 386: Added the module `Linux' exploiting some Linux OS specific features. For instance, with respect t...
------------------------------------------------------------
revno: 386
committer: Jean-Vincent Loddo <loddo@xxxxxxxxxxxxxxxxxxxx>
branch nick: ocamlbricks
timestamp: Fri 2013-11-15 19:07:07 +0100
message:
Added the module `Linux' exploiting some Linux OS specific features. For instance, with respect to the other Unix OS, we suppose to be able to get information from /proc/<PID>/ directories. Currently only the submodule `Process' is defined. With this module we can obtain statistics about the running processes (implemented reading files /proc/<PID>/stat). Both a full parsing and a simplified parsing are defined for these files. The result of the full parsing is the quite complicated (44 fields) data structure `Linux.Process.stat', while the result of the simplified parsing is the quick-and-easy object-oriented data structure < pid:int; comm:string; state:char; ppid:int; pgrp:int; session:int; tty_nr:int; tpgid:int; other_fields:string >. Some functions are provided to calculate the descendance of a process in an efficient way (as list or as a forest).
module Process : sig
(** Status information about the process. Implemented reading the file [/proc/<PID>/stat]. *)
val stat : pid -> stat option
(** Status information about the process (simplified object-oriented data structure).
Implemented as [stat] reading the file [/proc/<PID>/stat]. *)
val easy_stat : pid -> easy_stat option
(** Get statistics of all currently running processes. *)
val get_stats : unit -> stat list
(** Get statistics of all currently running processes (using the simplified structure). *)
val get_easy_stats : unit -> easy_stat list
(** {2 Descendants' PID}*)
(** Get the children PID list of the caller (by default) or the provided [~pid]. *)
val get_children : ?pid:int -> unit -> pid list
(** Get the PID list of the descendants of the caller (by default) or the provided [~pid]. *)
val get_descendants : ?pid:int -> unit -> pid list
(** Get the PID hierarchy (forest) of the descendants of the caller (by default) or the provided [~pid]. *)
val get_descendants_as_forest : ?pid:int -> unit -> pid Forest.t
(** {2 Descendants' statistics}*)
(** Get the statistics list of the descendants of the caller (by default) or the provided [~pid]. *)
val get_descendant_stats : ?pid:int -> unit -> stat list
(** Get the statistics list of the descendants of the caller (by default) or the provided [~pid] (using the simplified structure). *)
val get_descendant_easy_stats : ?pid:int -> unit -> easy_stat list
(** Get the statistics hierarchy (forest) of the descendants of the caller (by default) or the provided [~pid]. *)
val get_descendant_stats_as_forest : ?pid:int -> unit -> stat Forest.t
(** Get the statistics hierarchy (forest) of the descendants of the caller (by default) or the provided [~pid] (using the simplified structure). *)
val get_descendant_easy_stats_as_forest : ?pid:int -> unit -> easy_stat Forest.t
end (* Linux.Process *)
type stat = {
pid : int; (* %d (1) *)
comm : string; (* %s (2) *)
state : char; (* %c (3) *)
ppid : int; (* %d (4) *)
pgrp : int; (* %d (5) *)
session : int; (* %d (6) *)
tty_nr : int; (* %d (7) *)
tpgid : int; (* %d (8) *)
flags : int; (* %u (%lu before Linux 2.6.22) (9) *)
minflt : int64; (* %lu (10) *)
cminflt : int64; (* %lu (11) *)
majflt : int64; (* %lu (12) *)
cmajflt : int64; (* %lu (13) *)
utime : int64; (* %lu (14) *)
stime : int64; (* %lu (15) *)
cutime : int64; (* %ld (16) *)
cstime : int64; (* %ld (17) *)
priority : int64; (* %ld (18) *)
nice : int64; (* %ld (19) *)
num_threads : int64; (* %ld (20) *)
itrealvalue : int64; (* %ld (21) *)
starttime : int64; (* %llu (was %lu before Linux 2.6) (22) *)
vsize : int64; (* %lu (23) *)
rss : int64; (* %ld (24) *)
rsslim : int64 option; (* %lu (25) *)
startcode : int64; (* %lu (26) *)
endcode : int64; (* %lu (27) *)
startstack : int64; (* %lu (28) *)
kstkesp : int64; (* %lu (29) *)
kstkeip : int64; (* %lu (30) *)
signal : int64; (* %lu (31) *)
blocked : int64; (* %lu (32) *)
sigignore : int64; (* %lu (33) *)
sigcatch : int64; (* %lu (34) *)
wchan : int64 option; (* %lu (35) *)
nswap : int64; (* %lu (36) *)
cnswap : int64; (* %lu (37) *)
exit_signal : int; (* %d (since Linux 2.1.22) (38) *)
processor : int; (* %d (since Linux 2.2.8) (39) *)
rt_priority : int; (* %u (since Linux 2.5.19; was %lu before Linux 2.6.22) (40) *)
policy : int; (* %u (since Linux 2.5.19; was %lu before Linux 2.6.22) (41) *)
delayacct_blkio_ticks : int64; (* %llu (since Linux 2.6.18) (42) *)
guest_time : int64; (* %lu (since Linux 2.6.24) (43) *)
cguest_time : int64; (* %ld (since Linux 2.6.24) (44) *)
} (* type stat *)
added:
SHELL/linux.ml
SHELL/linux.mli
modified:
SHELL/shell.ml
SHELL/shell.mli
ocamlbricks.mllib
ocamlbricks.odocl
--
lp:ocamlbricks
https://code.launchpad.net/~marionnet-drivers/ocamlbricks/trunk
Your team marionnet-dev is subscribed to branch lp:ocamlbricks.
To unsubscribe from this branch go to https://code.launchpad.net/~marionnet-drivers/ocamlbricks/trunk/+edit-subscription