Skip to content

Instantly share code, notes, and snippets.

@nzbart
Created April 27, 2018 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nzbart/60970fbdfd1f00f7fb21254d665408bb to your computer and use it in GitHub Desktop.
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.
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