Created
January 26, 2016 10:03
-
-
Save nodakai/5f455877e6e831de8461 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(stringi) | |
| library(data.table) | |
| library(ggplot2) | |
| library(scales) | |
| Sys.setlocale(category="LC_TIME", "en_US.UTF-8") # strptime | |
| STRPTIME <- "%a %b %d %H:%M:%S EST %Y" | |
| ARGS <- commandArgs(trail = TRUE) | |
| readKernel <- function(line) { | |
| timestamp.s <- substr(line, 1, 28) # "Tue Jan 12 15:25:08 EST 2016" | |
| timestamp <- strptime(timestamp.s, STRPTIME, tz="America/New_York") # EST | |
| drops <- as.numeric(stri_extract_first_regex(line, "\\d+(?= packet receive errors)")) # number preceding a text | |
| data.frame(Time=timestamp, PktDropAtRcvr=drops) | |
| } | |
| dropA.df <- rbindlist( Map(readKernel, readLines(ARGS[1])) ) | |
| dropB.df <- rbindlist( Map(readKernel, readLines(ARGS[2])) ) | |
| # nrow(drop.df) | |
| # ncol(drop.df) | |
| # dropA.df[1:3, ] | |
| g <- ggplot() | |
| svg("r01.svg", width=20, height=8) | |
| # png("r01.png", width=2000, height=800) | |
| g + | |
| geom_point(data=dropA.df, aes(Time, PktDropAtRcvr), color="red") + | |
| geom_point(data=dropB.df, aes(Time, PktDropAtRcvr), color="blue") + | |
| scale_x_datetime(labels=date_format("%b%d %H:%M", tz="America/New_York"), breaks=date_breaks("3 hour"), minor_breaks=date_breaks("30 min")) | |
| dev.off() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment