## 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_fifoifstat -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:

#### 1 comment:

1. Thanks for this post. However, I don't know what x is in your example. Also, I couldn't get the read.table(...) function to work but was able to use readLines(...). I'm new to R, so do you mind expanding on this post?

Thanks!