clearer names for actions, and infer actions better
[monitor.git] / statistics / node_status_jun09feb10.r
1 source("functions.r");
2
3 # data collected from M3 fb db 
4 # system("./harvest_nodestatus.py  > node-status-jun09-feb10.csv")
5 ns <- read.csv('node-status-jun09-feb10.csv', sep=',', header=TRUE)
6
7 available_nodes <- function (ns, from, to, type, fmt="%b")
8 {
9     # find 'type' range of days
10     dates <-seq(as.Date(from), as.Date(to), type)
11     months <- format(dates, fmt)
12     hbreaks<-unclass(as.POSIXct(dates))
13
14     xx<-NULL;
15     yy<-NULL;
16
17     for ( i in seq(1,length(hbreaks)-1) )
18     {
19         # get range from ns
20         ns_sub <- ns[which(ns$date > hbreaks[i] & ns$date <= hbreaks[i+1] & ns$status == 'BOOT'),]
21         nodes <- length(ns_sub$date)
22
23         xx<- c(xx, hbreaks[i])
24         yy<- c(yy, nodes)
25
26     }
27     m<- months[1:length(months)-1]
28     return (rbind(xx,yy,m))
29 }
30
31 an <- available_nodes(ns, "2009-06-10", "2010-02-28", 'day')
32
33 x_start<-unclass(as.POSIXct("2009-06-10", origin="1970-01-01"))[1]
34 x_end  <-unclass(as.POSIXct("2010-02-28", origin="1970-01-01"))[1]
35
36 par(mfrow=c(1,1))
37 par(mai=c(.9,.8,.5,.4))
38 #start_image("daily-node-count.png")
39 sx<-an[1,][which(as.numeric(an[2,]) > 100)]
40 sy<-an[2,][which(as.numeric(an[2,]) > 100)]
41 plot(sx, sy,
42     type='l', col='blue', ylim=c(0,1000), xlim=c(x_start, x_end),
43     xlab="Date", ylab="Node Count", axes=F)
44 axis(2, las=1)
45 axis(1, labels=months, at=hbreaks)
46
47