diff --git a/geoip.R b/geoip.R index e69de29..891970c 100644 --- a/geoip.R +++ b/geoip.R @@ -0,0 +1,12 @@ +library(tidyverse) +library(ipapi) + +system("grep GraphTV /var/log/nginx/access.log | grep -vi bot | cut -d ' ' -f 1 | sort | uniq", intern = T) -> ips + +read_delim("/var/log/nginx/access.log", delim = " ", col_names = c("ip", "null", "user", "timestamp", "zone", "req", "status", "size", "referer", "agent")) %>% + select(-null, -user, -zone, -size) %>% + mutate(timestamp = timestamp %>% str_sub(2) %>% as.POSIXct(format = "%d/%b/%Y:%H:%M:%S")) %>% + mutate_at(vars(status), factor) -> access + +geolocate(ips) -> geoip +