Created
July 7, 2011 21:21
-
-
Save reyjrar/1070570 to your computer and use it in GitHub Desktop.
Probability Density of DNS Query/Response times
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
# Connect to Database | |
pgDrv <- dbDriver("PostgreSQL") | |
dbh <- dbConnect(pgDrv, host="", dbname="dnsmonitor", user="dnsmon", password="") | |
# Retrieve Statistics from DB | |
stats <- dbGetQuery(dbh, "select * from packet_timing") | |
# Close the Database Connection and free variables | |
dbDisconnect(dbh) | |
rm(dbh) | |
rm(pgDrv) | |
stats$zscore = (stats$difference - mean(stats$difference))/sd(stats$difference) | |
trimmed <- stats[ which(abs(stats$zscore) <= 3 & stats$difference > 0 ),] | |
outliers <- stats[which(abs(stats$zscore) > 3),] | |
# All data | |
hist(stats$difference,breaks=100,prob=TRUE, main="DNS Response Times", xlab="seconds") | |
d <- density(stats$difference) | |
lines(d, col="blue") | |
# Outliers | |
hist(outliers$difference,breaks=100,prob=TRUE, main="DNS Response Times for Outliers", xlab="seconds") | |
d <- density(outliers$difference) | |
lines(d, col="red") | |
# Normals | |
hist(trimmed$difference,breaks=200,prob=TRUE, main="DNS Response Times (z <= 3)", xlab="seconds") | |
d <- density(trimmed$difference) | |
lines(d, col="green") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample output is here: http://skit.ch/b1iw