Skip to content

Instantly share code, notes, and snippets.

@deckerego
Created December 6, 2013 14:17
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 deckerego/7824840 to your computer and use it in GitHub Desktop.
Save deckerego/7824840 to your computer and use it in GitHub Desktop.
Reading RabbitMQ Message Statistics
queueStatsToDataframe <- function(uri, username, password) {
uri <- paste(uri, "api/queues", sep="/")
credentials = paste(username, password, sep=":")
doc <- getURL(uri, userpwd=credentials, httpauth=1L)
src <- fromJSON(doc)
items.df <- data.frame()
if(length(src) > 0) {
for(i in 1:length(src)) {
if(length(src[[i]]$messages_details) == 3) {
record.df <- data.frame(src[[i]]$name, src[[i]]$messages_details, stringsAsFactors=FALSE)
names(record.df) <- c("Name", "Rate", "Interval", "LastEvent")
items.df <- rbind(items.df, record.df)
}
}
}
return(items.df)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment