[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [PATCH 2/2] virt-top: add memory stats to --csv mode.



>From 1df6f9f6cc95a5a3cb4800fe17a50d3a4e656c91 Mon Sep 17 00:00:00 2001
From: KAMEZAWA Hiroyuki <kamezawa bluextal (none)>
Date: Wed, 16 Feb 2011 05:04:42 +0900
Subject: [PATCH 2/2] add memory stats to --csv mode.

 In csv mode, memory usage in kbytes and %mem against total system
 memory is shown.

Signed-off-by: KAMEZAWA Hiroyuki <kamezawa hiroyu jp fujitsu com>
---
 virt-top/virt-top.pod |    8 ++++++++
 virt-top/virt_top.ml  |    8 ++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/virt-top/virt-top.pod b/virt-top/virt-top.pod
index 3a955ac..132cbe3 100755
--- a/virt-top/virt-top.pod
+++ b/virt-top/virt-top.pod
@@ -122,6 +122,10 @@ I<output.csv.00>, I<output.csv.01> etc.
 
 Disable domain CPU stats in CSV output.
 
+=item B<--no-csv-mem>
+
+Disable domain Memory stats in CSV output.
+
 =item B<--no-csv-block>
 
 Disable domain block device stats in CSV output.
@@ -346,6 +350,10 @@ Enables CSV output to the named file.
 
 Enable or disable domain CPU stats in CSV output.
 
+=itme B<csv-mem> I<true|false>
+
+Enable or disable domain Memory stats in CSV output.
+
 =item B<csv-block> I<true|false>
 
 Enable or disable domain block device stats in CSV output.
diff --git a/virt-top/virt_top.ml b/virt-top/virt_top.ml
index 3c6f47d..f833465 100644
--- a/virt-top/virt_top.ml
+++ b/virt-top/virt_top.ml
@@ -126,6 +126,7 @@ let uri = ref None
 let debug_file = ref ""
 let csv_enabled = ref false
 let csv_cpu = ref true
+let csv_mem = ref true
 let csv_block = ref true
 let csv_net = ref true
 let init_file = ref DefaultInitFile
@@ -178,6 +179,8 @@ let start_up () =
       "file " ^ s_"Log statistics to CSV file";
     "--no-csv-cpu", Arg.Clear csv_cpu,
       " " ^ s_"Disable CPU stats in CSV";
+    "--no-csv-mem", Arg.Clear csv_mem,
+      " " ^ s_"Diaable Memory stats in CSV";
     "--no-csv-block", Arg.Clear csv_block,
       " " ^ s_"Disable block device stats in CSV";
     "--no-csv-net", Arg.Clear csv_net,
@@ -233,6 +236,7 @@ OPTIONS" in
       | _, "debug", filename -> debug_file := filename
       | _, "csv", filename -> set_csv filename
       | _, "csv-cpu", b -> csv_cpu := bool_of_string b
+      | _, "csv-mem", b -> csv_mem := bool_of_string b
       | _, "csv-block", b -> csv_block := bool_of_string b
       | _, "csv-net", b -> csv_net := bool_of_string b
       | _, "batch", b -> batch_mode := bool_of_string b
@@ -1238,6 +1242,7 @@ let write_csv_header () =
       (* These fields are repeated for each domain: *)
     [ "Domain ID"; "Domain name"; ] @
     (if !csv_cpu then [ "CPU (ns)"; "%CPU"; ] else []) @
+    (if !csv_mem then [ "Mem (bytes)"; "%Mem";] else []) @
     (if !csv_block && not !block_in_bytes
        then [ "Block RDRQ"; "Block WRRQ"; ] else []) @
     (if !csv_block && !block_in_bytes
@@ -1295,6 +1300,9 @@ let append_csv
 	(if !csv_cpu then [
 	   string_of_float rd.rd_cpu_time; string_of_float rd.rd_percent_cpu
 	 ] else []) @
+        (if !csv_mem then [
+            Int64.to_string rd.rd_mem_bytes; Int64.to_string rd.rd_mem_percent
+         ] else []) @
 	(if !csv_block then [
 	   string_of_int64_option rd.rd_block_rd_info;
 	   string_of_int64_option rd.rd_block_wr_info;
-- 
1.7.1



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]