Created
April 27, 2018 19:21
-
-
Save nzbart/60970fbdfd1f00f7fb21254d665408bb to your computer and use it in GitHub Desktop.
Parse a CSV file exported from Uptime Robot to get a summary of outages over the past year.
This file contains 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
if (!require("pacman")) install.packages("pacman") | |
pacman::p_load(tidyverse, lubridate, pander) | |
inputFileName <- file.choose() | |
rawData <- read_csv(inputFileName, locale = locale(tz = Sys.timezone()), col_types = cols( | |
Event = col_character(), | |
`Date-Time` = col_datetime(format = ""), | |
Reason = col_factor(levels = NULL), | |
Duration = col_character(), | |
`Duration (in mins.)` = col_integer() | |
)) %>% | |
rename( | |
When = `Date-Time` | |
) | |
outagesOverPastYear <- rawData %>% | |
mutate(PreviousWhen = lead(`When`)) %>% | |
filter(Event == "Up") %>% | |
select(PreviousWhen, When) %>% | |
mutate(DurationMinutes = round(as.numeric(When - PreviousWhen, 'mins'), digits = 0)) %>% | |
filter(PreviousWhen > (Sys.time() %m+% years(-1))) %>% | |
rename( | |
OutageStarted = PreviousWhen, | |
OutageFinished = When | |
) | |
outagesOverPastYear %>% | |
pander(style="simple", justify = c("left", "left", "right")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment