mathjax

Thursday, January 13, 2011

Plot a FIFO in R

Recently discovered a really simple way to plot a fifo in rstats. Here's a simple example of plotting the output of your ifstat program. From one terminal do:


mkfifo ifstat_fifo
ifstat -n > ifstat_fifo


Then, in another terminal, open an R shell and do the following:


# Plot the most recent 100 seconds of inbound network traffic
> while(T){
d <- read.table(fifo("ifstat_fifo",open="read"))
x <- rbind(x,d)
x <-tail(x,100)
plot(x$V1,type='l')
Sys.sleep(1)
}


You may have to run it a couple times while the fifo fills with data. And here's what that looks like:

4 comments: