1 slices <- function (x, components=FALSE)
15 slices_2 <- function (x, components=FALSE)
17 # Define an ideal, then scale each measurement relative to the ideal.
18 # If it matches it will be more or less than 1
19 # does this scale (up or down) linearly, and why not?
21 # 4, 2.4x2, 1000; 4, 3.2x1, 320; 1, 2.4x1, 160
28 d<-x$disksize/ideal_d;
29 c<-x$cpuspeed/ideal_c;
30 r<-x$numcores/ideal_r;
42 slices_3 <- function (x, components=FALSE)
44 # Define an ideal, then scale each measurement relative to the ideal.
45 # If it matches it will be more or less than 1
46 # does this scale (up or down) linearly, and why not?
48 # 4, 2.4x2, 1000; 4, 3.2x1, 320; 1, 2.4x1, 160
53 ideal_bw <- 100000; #Kbps
56 d<-x$disksize/ideal_d;
57 c<-x$cpuspeed/ideal_c;
58 r<-x$numcores/ideal_r;
59 b<-log(x$bwlimit)/log(ideal_bw);
71 slices_4 <- function (x, components=FALSE)
73 # Define an ideal, then scale each measurement relative to the ideal.
74 # If it matches it will be more or less than 1
75 # does this scale (up or down) linearly, and why not?
77 # 4, 2.4x2, 1000; 4, 3.2x1, 320; 1, 2.4x1, 160
82 ideal_bw <- 100000; #Kbps
86 d<-x$disksize/ideal_d;
87 c<-x$cpuspeed/ideal_c;
88 r<-x$numcores/ideal_r;
89 b<-log(x$bwlimit)/log(ideal_bw);
90 p<-x$pcustatus/ideal_pcu;
102 index_of_bin <- function (h, value)
106 for (i in sequence(length(h$breaks)))
110 if ( value < h$breaks[1] )
118 if ( i == length(h$breaks) )
127 if ( value > h$breaks[i] && value <= h$breaks[i+1] )
134 warning("index == 0, no bin assigned for value: ", value);
140 start_image <- function (name, width=480, height=480)
142 png(name, width=width, height=height);
145 end_image <- function ()
151 plot_rt_hist <- function (t, imagename=0)
153 d2 <- (t$lastreply - t$start)
154 std_dev <- sd(log(d2))
156 print(sprintf("mean: %s, stddev: %s\n", m, std_dev));
158 if ( imagename != 0 ) { start_image(imagename) }
161 xlab="Hours between ticket creation and final reply",
162 main="Time to Final Reply for RT Tickets", axes=FALSE)
164 a<-exp(h$breaks)/(60*60) # convert units from log(secs) to hours
165 axis(1,labels=signif(a,2), at=h$breaks)
168 x<-seq(min(h$breaks),max(h$breaks),length=500)
169 y<-dnorm(x,mean=m, sd=std_dev)
171 # scale y to the size of h's 'counts' vector rather than the density function
172 lines(x,y*max(h$counts)/max(y))
173 if ( imagename != 0 ) { end_image() }
176 year_hist <- function (t, year, from, to, max, type="week", title="Histogram for Tickets in")
178 dates <-seq(as.Date(from), as.Date(to), type)
179 months <- format(dates, "%b-%d")
180 hbreaks<-unclass(as.POSIXct(dates))
181 h<-hist(t$start, breaks=hbreaks, plot=FALSE)
182 main<-sprintf(paste(title, "%s: MEAN %s\n"), year, mean(h$counts))
187 plot(h, ylim=c(0,max), main=main, axes=FALSE)
188 axis(1, labels=months, at=hbreaks)
190 abline(mean(h$counts), 0, col='grey')
195 year_hist_unique <- function (t, year, from, to, max, type="week", title="Histogram for Tickets in")
197 dates <-seq(as.Date(from), as.Date(to), type)
198 months <- format(dates, "%b-%d")
199 hbreaks<-unclass(as.POSIXct(dates))
205 t_sub <- t[which(t$start > d & t$start <= d_end),]
206 rows <- rbind(rows, c('start'=d, 'reboots'=length(unique(t_sub$hostname))) )
208 rows <- data.frame(rows)
211 max = max(rows$reboots)
213 main<-sprintf(paste(title, "%s: MEAN %s\n"), year, mean(rows$reboots))
215 barplot(rows$reboots, ylim=c(0,max), main=main, axes=FALSE, space=0)
216 #plot(h, ylim=c(0,max), main=main, axes=FALSE)
217 axis(1, labels=months, at=seq(1,length(hbreaks)))
219 abline(mean(rows$reboots), 0, col='grey')
225 year_hist_unique_recent <- function (t, year, from, to, max, blocks=c(1,3,7,14,30), type="week", title="Histogram for Tickets in")
227 dates <-seq(as.Date(from), as.Date(to), type)
228 months <- format(dates, "%b-%d")
229 hbreaks<-unclass(as.POSIXct(dates))
236 # initialize row for this iteration
238 row[as.character(0)] <- 0
239 for ( block in blocks ) {
240 row[as.character(block)] <- 0
243 # find the range : d plus a day
245 # find unique hosts in this day range
246 t_sub <- t[which(t$start > d & t$start <= d_end),]
247 unique_hosts <- unique(t_sub$hostname)
248 if (length(unique_hosts) == 0 ) {
249 rows <- rbind(rows, c('start'=d, row))
253 #print(sprintf("unique_hosts: %s\n", unique_hosts));
254 print(sprintf("unique_hosts: %s\n", length(unique_hosts)));
256 for ( host in as.character(unique_hosts) )
259 for ( block in blocks )
261 #print(sprintf("date: %s, block: -%s, %s\n", d, block, host));
262 #print(sprintf("row: %s\n", row));
263 # find the range : 'block' days ago to 'd'
264 d_back <- d - 60*60*24 * block
265 t_back_sub <- t[which(t$start > d_back & t$start <= d),]
266 u <- unique(t_back_sub$hostname)
267 if ( length(u[u==host]) >= 1)
269 # add to block_count and go to next host.
271 i <- as.character(block)
279 row['0'] <- row['0'] + 1
282 rows <- rbind(rows, c('start'=d, row))
285 rows <- data.frame(rows)
290 #main<-sprintf(paste(title, "%s: MEAN %s\n"), year, mean(rows$reboots))
292 #barplot(rows$reboots, ylim=c(0,max), main=main, axes=FALSE, space=0)
293 ##plot(h, ylim=c(0,max), main=main, axes=FALSE)
294 #axis(1, labels=months, at=seq(1,length(hbreaks)))
296 #abline(mean(rows$reboots), 0, col='grey')
302 source("myImagePlot.R")
303 reboot_image <- function (t, year, from, to, max=0, type="week", title="")
305 dates <-seq(as.Date(from), as.Date(to), type)
306 months <- format(dates, "%b-%d")
307 hbreaks<-unclass(as.POSIXct(dates))
310 image <- matrix(data=0, nrow=max(as.numeric(t$hostname)), ncol=length(hbreaks))
311 #image <- matrix(data=0, nrow=length(unique(t$hostname)), ncol=length(hbreaks))
313 #for ( d in hbreaks )
314 for ( i in seq(1, length(hbreaks)) )
316 # find the range : d plus a day
319 # find unique hosts in this day range
320 t_sub <- t[which(t$start > d & t$start <= d_end),]
321 unique_hosts <- unique(t_sub$hostname)
322 if (length(unique_hosts) == 0 ) { next }
324 for ( host in unique_hosts )
330 myImagePlot(image, xLabels=months, yLabels=c(""), title=title)
333 #for ( block in blocks )
335 #print(sprintf("date: %s, block: -%s, %s\n", d, block, host));
336 #print(sprintf("row: %s\n", row));
337 # find the range : 'block' days ago to 'd'
338 # d_back <- d - 60*60*24 * block
339 # t_back_sub <- t[which(t$start > d_back & t$start <= d),]
340 # u <- unique(t_back_sub$hostname)
341 # if ( length(u[u==host]) >= 1)
343 # # add to block_count and go to next host.
345 # i <- as.character(block)
346 # row[i] <- row[i] + 1
353 # row['0'] <- row['0'] + 1
356 #rows <- rbind(rows, c('start'=d, row))
358 #rows <- data.frame(rows)
361 # max = max(rows['0'])
363 #main<-sprintf(paste(title, "%s: MEAN %s\n"), year, mean(rows$reboots))
365 #barplot(rows$reboots, ylim=c(0,max), main=main, axes=FALSE, space=0)
366 ##plot(h, ylim=c(0,max), main=main, axes=FALSE)
367 #axis(1, labels=months, at=seq(1,length(hbreaks)))
369 #abline(mean(rows$reboots), 0, col='grey')
375 add_year <- function (t)
377 t$year <- c(0) # assign new column with zero value initially
378 for ( i in 1:length(t$start) )
380 d <- as.POSIXlt(t$start[i], origin="1970-01-01")
381 year <- d$year + 1900 # as.numeric(format(d, "%Y"))
387 add_timestamp <- function (t)
389 t$start <- c(0) # assign new column with zero value initially
390 for ( i in 1:length(t$date) )
392 tstamp <-unclass(as.POSIXct(t$date[i], origin="1970-01-01"))[1]
398 abline_at_date <- function (date, col='black', lty=1, format="%Y-%m-%d")
400 ts <-unclass(as.POSIXct(date, format=format, origin="1970-01-01"))[1]
401 abline(v=ts, col=col, lty=lty)