add parse scripts master
authorRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Mon, 22 Nov 2010 20:39:00 +0000 (22:39 +0200)
committerRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Mon, 22 Nov 2010 20:39:00 +0000 (22:39 +0200)
16 files changed:
parse/.gitignore [new file with mode: 0644]
parse/parse_all [new file with mode: 0755]
parse/parse_cpu_process [new file with mode: 0755]
parse/parse_cpu_system [new file with mode: 0755]
parse/parse_io_process [new file with mode: 0755]
parse/parse_io_system [new file with mode: 0755]
parse/parse_memory_process [new file with mode: 0755]
parse/parse_memory_system [new file with mode: 0755]
parse/parse_packets_in [new file with mode: 0755]
parse/parse_packets_out [new file with mode: 0755]
parse/parse_udp_in [new file with mode: 0755]
parse/parse_udp_out [new file with mode: 0755]
parse/r_parse_all [new file with mode: 0755]
parse/r_parse_cp.R [new file with mode: 0644]
parse/r_parse_mp.R [new file with mode: 0644]
parse/r_parse_udp.R [new file with mode: 0644]

diff --git a/parse/.gitignore b/parse/.gitignore
new file mode 100644 (file)
index 0000000..425cccf
--- /dev/null
@@ -0,0 +1,2 @@
+/log/
+/out/
diff --git a/parse/parse_all b/parse/parse_all
new file mode 100755 (executable)
index 0000000..c2b9fbb
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+if test $# -ne 1; then
+       echo "Usage: $0 input-log-file" 1>&2
+       exit 1
+fi
+
+input_log_file=$1
+
+./parse_memory_process < $input_log_file > mp_$input_log_file
+./parse_memory_system < $input_log_file > ms_$input_log_file
+./parse_cpu_process < $input_log_file > cp_$input_log_file
+./parse_cpu_system < $input_log_file > cs_$input_log_file
+./parse_io_process < $input_log_file > ip_$input_log_file
+./parse_io_system < $input_log_file > is_$input_log_file
+./parse_udp_in < $input_log_file > ui_$input_log_file
+./parse_udp_out < $input_log_file > uo_$input_log_file
+./parse_packets_in < $input_log_file > pi_$input_log_file
+./parse_packets_out < $input_log_file > po_$input_log_file
diff --git a/parse/parse_cpu_process b/parse/parse_cpu_process
new file mode 100755 (executable)
index 0000000..ecb8dbe
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+awk '
+BEGIN  {
+       count = 0
+       init = 1
+       printf "user\tsystem\tCPU\n"
+}
+
+/%CPU[ \t]+CPU[ \t]+Command/   {
+       count = 0
+       init = 0
+}
+
+{
+       count++
+       if (count == 2 && !init)
+               printf "%s\t%s\t%s\n", $4, $5, $6
+}
+'
diff --git a/parse/parse_cpu_system b/parse/parse_cpu_system
new file mode 100755 (executable)
index 0000000..74eaca2
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+awk '
+BEGIN  {
+       count = 0
+       init = 1
+       printf "user\tsystem\n"
+}
+
+/^avg-cpu/     {
+       count = 0
+       init = 0
+}
+
+{
+       count++
+       if (count == 2 && !init)
+               printf "%s\t%s\n", $1, $3
+}
+'
diff --git a/parse/parse_io_process b/parse/parse_io_process
new file mode 100755 (executable)
index 0000000..4fb14d7
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+awk '
+BEGIN  {
+       count = 0
+       init = 1
+       printf "kB_rd/s\tkB_wr/s\n"
+}
+
+/kB_rd\/s[ \t]+kB_wr\/s/       {
+       count = 0
+       init = 0
+}
+
+{
+       count++
+       if (count == 2 && !init)
+               printf "%s\t%s\n", $4, $5
+}
+'
diff --git a/parse/parse_io_system b/parse/parse_io_system
new file mode 100755 (executable)
index 0000000..801a85a
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+awk '
+BEGIN  {
+       count = 0
+       init = 1
+       printf "Blk_read/s\tBlk_wrtn/s\n"
+}
+
+/^Device:/     {
+       count = 0
+       init = 0
+}
+
+{
+       count++
+       if (count == 2 && !init)
+               printf "%s\t%s\n", $3, $4
+}
+'
diff --git a/parse/parse_memory_process b/parse/parse_memory_process
new file mode 100755 (executable)
index 0000000..74089f1
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+awk '
+BEGIN  {
+       count = 0
+       init = 1
+       printf "VSZ\tRSS\tPERCENT\n"
+}
+
+/VSZ[ \t]+RSS[ \t]+%MEM/       {
+       count = 0
+       init = 0
+}
+
+{
+       count++
+       if (count == 2 && !init)
+               printf "%s\t%s\t%s\n", $6, $7, $8
+}
+'
diff --git a/parse/parse_memory_system b/parse/parse_memory_system
new file mode 100755 (executable)
index 0000000..860a59b
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+awk '
+BEGIN  {
+       count = 0
+       init = 1
+       printf "memory\n"
+}
+
+/^Mem:/        {
+       count = 0
+       init = 0
+}
+
+{
+       count++
+       if (count == 2 && !init)
+               printf "%s\n", $3
+}
+'
diff --git a/parse/parse_packets_in b/parse/parse_packets_in
new file mode 100755 (executable)
index 0000000..8d5b59c
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+awk '
+BEGIN  {
+       count = 0
+       init = 1
+       printf "bytes_received\n"
+}
+
+/^Chain udp_out/               {
+       count = 0
+       init = 0
+}
+
+{
+       count++
+       if (count == 4 && !init)
+               printf "%s\n", $1
+}
+'
diff --git a/parse/parse_packets_out b/parse/parse_packets_out
new file mode 100755 (executable)
index 0000000..e547d94
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+awk '
+BEGIN  {
+       count = 0
+       init = 1
+       printf "bytes_sent\n"
+}
+
+/^Chain udp_out/               {
+       count = 0
+       init = 0
+}
+
+{
+       count++
+       if (count == 5 && !init)
+               printf "%s\n", $1
+}
+'
diff --git a/parse/parse_udp_in b/parse/parse_udp_in
new file mode 100755 (executable)
index 0000000..1423559
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+awk '
+BEGIN  {
+       count = 0
+       init = 1
+       printf "pkts\tbytes\n"
+}
+
+/^Chain udp_in/                {
+       count = 0
+       init = 0
+}
+
+{
+       count++
+
+       pkts = $1 + 0
+       bytes = $2 + 0
+
+       if (index($1, "K"))
+               pkts = pkts * 1024
+       else
+               if (index($1, "M"))
+                       pkts = pkts * 1024 * 1024;
+               else
+                       if (index($1, "G"))
+                               pkts = pkts * 1024 * 1024 * 1204
+
+       if (index($2, "K"))
+               bytes = bytes * 1024
+       else
+               if (index($2, "M"))
+                       bytes = bytes * 1024 * 1024;
+               else
+                       if (index($2, "G"))
+                               bytes = bytes * 1024 * 1024 * 1204
+
+       if (count == 3 && !init)
+               printf "%s\t%s\n", pkts, bytes
+}
+'
diff --git a/parse/parse_udp_out b/parse/parse_udp_out
new file mode 100755 (executable)
index 0000000..2ebb99e
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+awk '
+BEGIN  {
+       count = 0
+       init = 1
+       printf "pkts\tbytes\n"
+}
+
+/^Chain udp_out/       {
+       count = 0
+       init = 0
+}
+
+{
+       count++
+
+       pkts = $1 + 0
+       bytes = $2 + 0
+
+       if (index($1, "K"))
+               pkts = pkts * 1024
+       else
+               if (index($1, "M"))
+                       pkts = pkts * 1024 * 1024;
+               else
+                       if (index($1, "G"))
+                               pkts = pkts * 1024 * 1024 * 1204
+
+       if (index($2, "K"))
+               bytes = bytes * 1024
+       else
+               if (index($2, "M"))
+                       bytes = bytes * 1024 * 1024;
+               else
+                       if (index($2, "G"))
+                               bytes = bytes * 1024 * 1024 * 1204
+
+       if (count == 3 && !init)
+               printf "%s\t%s\n", pkts, bytes
+}
+'
diff --git a/parse/r_parse_all b/parse/r_parse_all
new file mode 100755 (executable)
index 0000000..8757af2
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+if test $# -ne 1; then
+       echo "Usage: $0 base-log-file" 1>&2
+       exit 1
+fi
+
+base_log_file=$1
+
+Rscript r_parse_udp.R out/ui_$base_log_file out/ui_$(basename $base_log_file .log).pdf
+Rscript r_parse_udp.R out/uo_$base_log_file out/uo_$(basename $base_log_file .log).pdf
+Rscript r_parse_cp.R out/cp_$base_log_file out/cp_$(basename $base_log_file .log).pdf
+Rscript r_parse_mp.R out/mp_$base_log_file out/mp_$(basename $base_log_file .log).pdf
diff --git a/parse/r_parse_cp.R b/parse/r_parse_cp.R
new file mode 100644 (file)
index 0000000..f22678e
--- /dev/null
@@ -0,0 +1,14 @@
+args <- commandArgs(trailingOnly=TRUE)
+
+source_file <- args[1]
+output_file <- args[2]
+
+cpu_table <- read.table(source_file, header=T)
+
+cpu_perc <- cpu_table$CPU
+
+cpu_perc
+
+pdf(file=output_file)
+plot(cpu_perc, type="o", col="red", xlab="Time (s)", ylab="CPU Usage (%)");
+dev.off()
diff --git a/parse/r_parse_mp.R b/parse/r_parse_mp.R
new file mode 100644 (file)
index 0000000..5d0c8f4
--- /dev/null
@@ -0,0 +1,16 @@
+args <- commandArgs(trailingOnly=TRUE)
+
+source_file <- args[1]
+output_file <- args[2]
+
+mem_table <- read.table(source_file, header=T)
+
+rss <- mem_table$RSS / 1024
+new_rss <- rss
+new_rss[length(new_rss)+1] = 0
+
+rss
+
+pdf(file=output_file)
+plot(new_rss, type="o", col="red", xlab="Time (s)", ylab="RSS (MB)");
+dev.off()
diff --git a/parse/r_parse_udp.R b/parse/r_parse_udp.R
new file mode 100644 (file)
index 0000000..234316d
--- /dev/null
@@ -0,0 +1,17 @@
+args <- commandArgs(trailingOnly=TRUE)
+
+source_file <- args[1]
+output_file <- args[2]
+
+udp_table <- read.table(source_file, header=T)
+
+bytes_array <- udp_table$bytes
+offset_bytes_array <- bytes_array[2:length(bytes_array)]
+
+speed <- (offset_bytes_array - bytes_array[1:length(bytes_array)-1]) / 1024
+
+speed
+
+pdf(file=output_file)
+plot(speed, type="o", col="red", xlab="Time (s)", ylab="Speed (KB/s)");
+dev.off()