|
|
056839 |
From 10660e29ea19a0e290e28afe0425f63afd0abd58 Mon Sep 17 00:00:00 2001
|
|
|
263533 |
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
263533 |
Date: Mon, 27 Mar 2017 21:22:52 +0100
|
|
|
056839 |
Subject: [PATCH 15/23] Move block_in_bytes entirely to the presentation layer.
|
|
|
263533 |
|
|
|
263533 |
Simplifies and updates commit dbef8dd3bf00417e75a12c851b053e49c9e1a79e.
|
|
|
263533 |
---
|
|
|
263533 |
src/collect.ml | 19 +++----------------
|
|
|
263533 |
src/collect.mli | 6 +-----
|
|
|
263533 |
src/csv_output.ml | 14 ++++++++++----
|
|
|
263533 |
src/csv_output.mli | 2 +-
|
|
|
263533 |
src/redraw.ml | 10 +++++++---
|
|
|
263533 |
src/stream_output.ml | 14 ++++++++++----
|
|
|
263533 |
src/top.ml | 4 ++--
|
|
|
263533 |
7 files changed, 34 insertions(+), 35 deletions(-)
|
|
|
263533 |
|
|
|
263533 |
diff --git a/src/collect.ml b/src/collect.ml
|
|
|
263533 |
index f856067..448ce8c 100644
|
|
|
263533 |
--- a/src/collect.ml
|
|
|
263533 |
+++ b/src/collect.ml
|
|
|
263533 |
@@ -57,12 +57,8 @@ and rd_active = {
|
|
|
263533 |
(* The following are since the last slice, or None if cannot be calc'd: *)
|
|
|
263533 |
rd_block_rd_reqs : int64 option; (* Number of block device read rqs. *)
|
|
|
263533 |
rd_block_wr_reqs : int64 option; (* Number of block device write rqs. *)
|
|
|
263533 |
- rd_block_rd_bytes : int64 option; (* Number of bytes block device read *)
|
|
|
263533 |
- rd_block_wr_bytes : int64 option; (* Number of bytes block device write *)
|
|
|
263533 |
- (* _info fields includes the number considering --block_in_bytes option *)
|
|
|
263533 |
- rd_block_rd_info : int64 option; (* Block device read info for user *)
|
|
|
263533 |
- rd_block_wr_info : int64 option; (* Block device read info for user *)
|
|
|
263533 |
-
|
|
|
263533 |
+ rd_block_rd_bytes : int64 option; (* Number of bytes block device read *)
|
|
|
263533 |
+ rd_block_wr_bytes : int64 option; (* Number of bytes block device write *)
|
|
|
263533 |
rd_net_rx_bytes : int64 option; (* Number of bytes received. *)
|
|
|
263533 |
rd_net_tx_bytes : int64 option; (* Number of bytes transmitted. *)
|
|
|
263533 |
}
|
|
|
263533 |
@@ -114,7 +110,7 @@ let last_pcpu_usages = Hashtbl.create 13
|
|
|
263533 |
let clear_pcpu_display_data () =
|
|
|
263533 |
Hashtbl.clear last_pcpu_usages
|
|
|
263533 |
|
|
|
263533 |
-let collect (conn, _, _, _, _, node_info, _, _) block_in_bytes =
|
|
|
263533 |
+let collect (conn, _, _, _, _, node_info, _, _) =
|
|
|
263533 |
(* Number of physical CPUs (some may be disabled). *)
|
|
|
263533 |
let nr_pcpus = C.maxcpus_of_node_info node_info in
|
|
|
263533 |
|
|
|
263533 |
@@ -178,7 +174,6 @@ let collect (conn, _, _, _, _, node_info, _, _) block_in_bytes =
|
|
|
263533 |
rd_mem_bytes = 0L; rd_mem_percent = 0L;
|
|
|
263533 |
rd_block_rd_reqs = None; rd_block_wr_reqs = None;
|
|
|
263533 |
rd_block_rd_bytes = None; rd_block_wr_bytes = None;
|
|
|
263533 |
- rd_block_rd_info = None; rd_block_wr_info = None;
|
|
|
263533 |
rd_net_rx_bytes = None; rd_net_tx_bytes = None;
|
|
|
263533 |
})
|
|
|
263533 |
with
|
|
|
263533 |
@@ -256,14 +251,6 @@ let collect (conn, _, _, _, _, node_info, _, _) block_in_bytes =
|
|
|
263533 |
rd_block_rd_bytes = Some read_bytes;
|
|
|
263533 |
rd_block_wr_bytes = Some write_bytes;
|
|
|
263533 |
} in
|
|
|
263533 |
- let rd = { rd with
|
|
|
263533 |
- rd_block_rd_info =
|
|
|
263533 |
- if block_in_bytes then
|
|
|
263533 |
- rd.rd_block_rd_bytes else rd.rd_block_rd_reqs;
|
|
|
263533 |
- rd_block_wr_info =
|
|
|
263533 |
- if block_in_bytes then
|
|
|
263533 |
- rd.rd_block_wr_bytes else rd.rd_block_wr_reqs;
|
|
|
263533 |
- } in
|
|
|
263533 |
name, Active rd
|
|
|
263533 |
(* For all other domains we can't calculate it, so leave as None. *)
|
|
|
263533 |
| rd -> rd
|
|
|
263533 |
diff --git a/src/collect.mli b/src/collect.mli
|
|
|
263533 |
index 440859b..9ad3dcb 100644
|
|
|
263533 |
--- a/src/collect.mli
|
|
|
263533 |
+++ b/src/collect.mli
|
|
|
263533 |
@@ -48,10 +48,6 @@ and rd_active = {
|
|
|
263533 |
rd_block_wr_reqs : int64 option; (* Number of block device write rqs. *)
|
|
|
263533 |
rd_block_rd_bytes : int64 option; (* Number of bytes block device read *)
|
|
|
263533 |
rd_block_wr_bytes : int64 option; (* Number of bytes block device write *)
|
|
|
263533 |
- (* _info fields includes the number considering --block_in_bytes option *)
|
|
|
263533 |
- rd_block_rd_info : int64 option; (* Block device read info for user *)
|
|
|
263533 |
- rd_block_wr_info : int64 option; (* Block device read info for user *)
|
|
|
263533 |
-
|
|
|
263533 |
rd_net_rx_bytes : int64 option; (* Number of bytes received. *)
|
|
|
263533 |
rd_net_tx_bytes : int64 option; (* Number of bytes transmitted. *)
|
|
|
263533 |
}
|
|
|
263533 |
@@ -75,7 +71,7 @@ type pcpu_stats = {
|
|
|
263533 |
rd_pcpu_pcpus_cpu_time : float array
|
|
|
263533 |
}
|
|
|
263533 |
|
|
|
263533 |
-val collect : Types.setup -> bool -> stats
|
|
|
263533 |
+val collect : Types.setup -> stats
|
|
|
263533 |
(** Collect statistics. *)
|
|
|
263533 |
|
|
|
263533 |
val collect_pcpu : stats -> pcpu_stats
|
|
|
263533 |
diff --git a/src/csv_output.ml b/src/csv_output.ml
|
|
|
263533 |
index 9496ca8..f23d673 100644
|
|
|
263533 |
--- a/src/csv_output.ml
|
|
|
263533 |
+++ b/src/csv_output.ml
|
|
|
263533 |
@@ -56,6 +56,7 @@ let write_csv_header (csv_cpu, csv_mem, csv_block, csv_net) block_in_bytes =
|
|
|
263533 |
(* Write summary data to CSV file. *)
|
|
|
263533 |
let append_csv (_, _, _, _, _, node_info, hostname, _) (* setup *)
|
|
|
263533 |
(csv_cpu, csv_mem, csv_block, csv_net)
|
|
|
263533 |
+ block_in_bytes
|
|
|
263533 |
{ rd_doms = doms;
|
|
|
263533 |
rd_printable_time = printable_time;
|
|
|
263533 |
rd_nr_pcpus = nr_pcpus; rd_total_cpu = total_cpu;
|
|
|
263533 |
@@ -104,10 +105,15 @@ let append_csv (_, _, _, _, _, node_info, hostname, _) (* setup *)
|
|
|
263533 |
(if csv_mem then [
|
|
|
263533 |
Int64.to_string rd.rd_mem_bytes; Int64.to_string rd.rd_mem_percent
|
|
|
263533 |
] else []) @
|
|
|
263533 |
- (if csv_block then [
|
|
|
263533 |
- string_of_int64_option rd.rd_block_rd_info;
|
|
|
263533 |
- string_of_int64_option rd.rd_block_wr_info;
|
|
|
263533 |
- ] else []) @
|
|
|
263533 |
+ (if csv_block then
|
|
|
263533 |
+ if block_in_bytes then [
|
|
|
263533 |
+ string_of_int64_option rd.rd_block_rd_bytes;
|
|
|
263533 |
+ string_of_int64_option rd.rd_block_wr_bytes;
|
|
|
263533 |
+ ] else [
|
|
|
263533 |
+ string_of_int64_option rd.rd_block_rd_reqs;
|
|
|
263533 |
+ string_of_int64_option rd.rd_block_wr_reqs;
|
|
|
263533 |
+ ]
|
|
|
263533 |
+ else []) @
|
|
|
263533 |
(if csv_net then [
|
|
|
263533 |
string_of_int64_option rd.rd_net_rx_bytes;
|
|
|
263533 |
string_of_int64_option rd.rd_net_tx_bytes;
|
|
|
263533 |
diff --git a/src/csv_output.mli b/src/csv_output.mli
|
|
|
263533 |
index d5eab0f..4064be5 100644
|
|
|
263533 |
--- a/src/csv_output.mli
|
|
|
263533 |
+++ b/src/csv_output.mli
|
|
|
263533 |
@@ -24,4 +24,4 @@ val csv_write : (string list -> unit) ref
|
|
|
263533 |
|
|
|
263533 |
val write_csv_header : bool * bool * bool * bool -> bool -> unit
|
|
|
263533 |
|
|
|
263533 |
-val append_csv : Types.setup -> bool * bool * bool * bool -> Collect.stats -> unit
|
|
|
263533 |
+val append_csv : Types.setup -> bool * bool * bool * bool -> bool -> Collect.stats -> unit
|
|
|
263533 |
diff --git a/src/redraw.ml b/src/redraw.ml
|
|
|
263533 |
index 9ce889b..0403158 100644
|
|
|
263533 |
--- a/src/redraw.ml
|
|
|
263533 |
+++ b/src/redraw.ml
|
|
|
263533 |
@@ -155,8 +155,12 @@ let redraw display_mode sort_order
|
|
|
263533 |
| (name, Active rd) :: doms ->
|
|
|
263533 |
if lineno < lines then (
|
|
|
263533 |
let state = show_state rd.rd_info.D.state in
|
|
|
263533 |
- let rd_req = Show.int64_option rd.rd_block_rd_info in
|
|
|
263533 |
- let wr_req = Show.int64_option rd.rd_block_wr_info in
|
|
|
263533 |
+ let rd_info =
|
|
|
263533 |
+ if block_in_bytes then Show.int64_option rd.rd_block_rd_bytes
|
|
|
263533 |
+ else Show.int64_option rd.rd_block_rd_reqs in
|
|
|
263533 |
+ let wr_info =
|
|
|
263533 |
+ if block_in_bytes then Show.int64_option rd.rd_block_wr_bytes
|
|
|
263533 |
+ else Show.int64_option rd.rd_block_wr_reqs in
|
|
|
263533 |
let rx_bytes = Show.int64_option rd.rd_net_rx_bytes in
|
|
|
263533 |
let tx_bytes = Show.int64_option rd.rd_net_tx_bytes in
|
|
|
263533 |
let percent_cpu = Show.percent rd.rd_percent_cpu in
|
|
|
263533 |
@@ -166,7 +170,7 @@ let redraw display_mode sort_order
|
|
|
263533 |
|
|
|
263533 |
let line =
|
|
|
263533 |
sprintf "%5d %c %s %s %s %s %s %s %s %s"
|
|
|
263533 |
- rd.rd_domid state rd_req wr_req rx_bytes tx_bytes
|
|
|
263533 |
+ rd.rd_domid state rd_info wr_info rx_bytes tx_bytes
|
|
|
263533 |
percent_cpu percent_mem time name in
|
|
|
263533 |
let line = pad cols line in
|
|
|
263533 |
mvaddstr lineno 0 line;
|
|
|
263533 |
diff --git a/src/stream_output.ml b/src/stream_output.ml
|
|
|
263533 |
index bf7b114..c3af99b 100644
|
|
|
263533 |
--- a/src/stream_output.ml
|
|
|
263533 |
+++ b/src/stream_output.ml
|
|
|
263533 |
@@ -59,10 +59,16 @@ let append_stream (_, _, _, _, _, node_info, hostname, _) (* setup *)
|
|
|
263533 |
let dump_domain = fun name rd
|
|
|
263533 |
-> begin
|
|
|
263533 |
let state = Screen.show_state rd.rd_info.D.state in
|
|
|
263533 |
- let rd_req = if rd.rd_block_rd_info = None then " 0"
|
|
|
263533 |
- else Show.int64_option rd.rd_block_rd_info in
|
|
|
263533 |
- let wr_req = if rd.rd_block_wr_info = None then " 0"
|
|
|
263533 |
- else Show.int64_option rd.rd_block_wr_info in
|
|
|
263533 |
+ let rd_req =
|
|
|
263533 |
+ if rd.rd_block_rd_reqs = None then " 0"
|
|
|
263533 |
+ else
|
|
|
263533 |
+ if block_in_bytes then Show.int64_option rd.rd_block_rd_bytes
|
|
|
263533 |
+ else Show.int64_option rd.rd_block_rd_reqs in
|
|
|
263533 |
+ let wr_req =
|
|
|
263533 |
+ if rd.rd_block_wr_reqs = None then " 0"
|
|
|
263533 |
+ else
|
|
|
263533 |
+ if block_in_bytes then Show.int64_option rd.rd_block_wr_bytes
|
|
|
263533 |
+ else Show.int64_option rd.rd_block_wr_reqs in
|
|
|
263533 |
let rx_bytes = if rd.rd_net_rx_bytes = None then " 0"
|
|
|
263533 |
else Show.int64_option rd.rd_net_rx_bytes in
|
|
|
263533 |
let tx_bytes = if rd.rd_net_tx_bytes = None then " 0"
|
|
|
263533 |
diff --git a/src/top.ml b/src/top.ml
|
|
|
263533 |
index 204f3b6..e2a93d6 100644
|
|
|
263533 |
--- a/src/top.ml
|
|
|
263533 |
+++ b/src/top.ml
|
|
|
263533 |
@@ -319,7 +319,7 @@ let rec main_loop ((_, batch_mode, script_mode, csv_enabled, stream_mode, _, _,
|
|
|
263533 |
|
|
|
263533 |
while not !quit do
|
|
|
263533 |
(* Collect stats. *)
|
|
|
263533 |
- let state = collect setup !block_in_bytes in
|
|
|
263533 |
+ let state = collect setup in
|
|
|
263533 |
let pcpu_display =
|
|
|
263533 |
if !display_mode = PCPUDisplay then Some (collect_pcpu state)
|
|
|
263533 |
else None in
|
|
|
263533 |
@@ -331,7 +331,7 @@ let rec main_loop ((_, batch_mode, script_mode, csv_enabled, stream_mode, _, _,
|
|
|
263533 |
|
|
|
263533 |
(* Update CSV file. *)
|
|
|
263533 |
if csv_enabled then
|
|
|
263533 |
- Csv_output.append_csv setup csv_flags state;
|
|
|
263533 |
+ Csv_output.append_csv setup csv_flags !block_in_bytes state;
|
|
|
263533 |
|
|
|
263533 |
(* Append to stream output file. *)
|
|
|
263533 |
if stream_mode then
|
|
|
263533 |
--
|
|
|
056839 |
2.31.1
|
|
|
263533 |
|