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", fmt="%b-%d")
178 dates <-seq(as.Date(from), as.Date(to), type)
179 months <- format(dates, fmt)
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))
188 plot(h, ylim=c(0,max), main=main, axes=FALSE)
189 axis(1, labels=months, at=hbreaks)
191 abline(mean(h$counts), 0, col='grey')
197 year_hist_unique <- function (t, year, from, to, max, type="week", title="Histogram for Tickets in")
199 dates <-seq(as.Date(from), as.Date(to), type)
200 months <- format(dates, "%b-%d")
201 hbreaks<-unclass(as.POSIXct(dates))
207 t_sub <- t[which(t$start > d & t$start <= d_end),]
208 rows <- rbind(rows, c('start'=d, 'reboots'=length(unique(t_sub$hostname))) )
210 rows <- data.frame(rows)
213 max = max(rows$reboots)
215 main<-sprintf(paste(title, "%s: MEAN %s\n"), year, mean(rows$reboots))
217 barplot(rows$reboots, ylim=c(0,max), main=main, axes=FALSE, space=0)
218 #plot(h, ylim=c(0,max), main=main, axes=FALSE)
219 axis(1, labels=months, at=seq(1,length(hbreaks)))
221 abline(mean(rows$reboots), 0, col='grey')
227 year_hist_unique_recent <- function (t, year, from, to, max, blocks=c(1,3,7,14,30), type="week", title="Histogram for Tickets in")
229 dates <-seq(as.Date(from), as.Date(to), type)
230 months <- format(dates, "%b-%d")
231 hbreaks<-unclass(as.POSIXct(dates))
238 # initialize row for this iteration
240 row[as.character(0)] <- 0
241 for ( block in blocks ) {
242 row[as.character(block)] <- 0
245 # find the range : d plus a day
247 # find unique hosts in this day range
248 t_sub <- t[which(t$start > d & t$start <= d_end),]
249 unique_hosts <- unique(t_sub$hostname)
250 if (length(unique_hosts) == 0 ) {
251 rows <- rbind(rows, c('start'=d, row))
255 #print(sprintf("unique_hosts: %s\n", unique_hosts));
256 print(sprintf("unique_hosts: %s\n", length(unique_hosts)));
258 for ( host in as.character(unique_hosts) )
261 for ( block in blocks )
263 #print(sprintf("date: %s, block: -%s, %s\n", d, block, host));
264 #print(sprintf("row: %s\n", row));
265 # find the range : 'block' days ago to 'd'
266 d_back <- d - 60*60*24 * block
267 t_back_sub <- t[which(t$start > d_back & t$start <= d),]
268 u <- unique(t_back_sub$hostname)
269 if ( length(u[u==host]) >= 1)
271 # add to block_count and go to next host.
273 i <- as.character(block)
281 row['0'] <- row['0'] + 1
284 rows <- rbind(rows, c('start'=d, row))
287 rows <- data.frame(rows)
292 #main<-sprintf(paste(title, "%s: MEAN %s\n"), year, mean(rows$reboots))
294 #barplot(rows$reboots, ylim=c(0,max), main=main, axes=FALSE, space=0)
295 ##plot(h, ylim=c(0,max), main=main, axes=FALSE)
296 #axis(1, labels=months, at=seq(1,length(hbreaks)))
298 #abline(mean(rows$reboots), 0, col='grey')
304 source("myImagePlot.R")
305 reboot_image <- function (t, year, from, to, max=0, type="week", title="")
307 dates <-seq(as.Date(from), as.Date(to), type)
308 months <- format(dates, "%b-%d")
309 hbreaks<-unclass(as.POSIXct(dates))
312 image <- matrix(data=0, nrow=max(as.numeric(t$hostname)), ncol=length(hbreaks))
313 #image <- matrix(data=0, nrow=length(unique(t$hostname)), ncol=length(hbreaks))
315 #for ( d in hbreaks )
316 for ( i in seq(1, length(hbreaks)) )
318 # find the range : d plus a day
321 # find unique hosts in this day range
322 t_sub <- t[which(t$start > d & t$start <= d_end),]
323 unique_hosts <- unique(t_sub$hostname)
324 if (length(unique_hosts) == 0 ) { next }
326 for ( host in unique_hosts )
332 myImagePlot(image, xLabels=months, yLabels=c(""), title=title)
335 #for ( block in blocks )
337 #print(sprintf("date: %s, block: -%s, %s\n", d, block, host));
338 #print(sprintf("row: %s\n", row));
339 # find the range : 'block' days ago to 'd'
340 # d_back <- d - 60*60*24 * block
341 # t_back_sub <- t[which(t$start > d_back & t$start <= d),]
342 # u <- unique(t_back_sub$hostname)
343 # if ( length(u[u==host]) >= 1)
345 # # add to block_count and go to next host.
347 # i <- as.character(block)
348 # row[i] <- row[i] + 1
355 # row['0'] <- row['0'] + 1
358 #rows <- rbind(rows, c('start'=d, row))
360 #rows <- data.frame(rows)
363 # max = max(rows['0'])
365 #main<-sprintf(paste(title, "%s: MEAN %s\n"), year, mean(rows$reboots))
367 #barplot(rows$reboots, ylim=c(0,max), main=main, axes=FALSE, space=0)
368 ##plot(h, ylim=c(0,max), main=main, axes=FALSE)
369 #axis(1, labels=months, at=seq(1,length(hbreaks)))
371 #abline(mean(rows$reboots), 0, col='grey')
377 add_year <- function (t)
379 t$year <- c(0) # assign new column with zero value initially
380 for ( i in 1:length(t$start) )
382 d <- as.POSIXlt(t$start[i], origin="1970-01-01")
383 year <- d$year + 1900 # as.numeric(format(d, "%Y"))
389 add_timestamp <- function (t)
391 t$start <- c(0) # assign new column with zero value initially
392 for ( i in 1:length(t$date) )
394 tstamp <-unclass(as.POSIXct(t$date[i], origin="1970-01-01"))[1]
400 abline_at_date <- function (date, col='black', lty=1, format="%Y-%m-%d", height=0)
402 ts <-unclass(as.POSIXct(date, format=format, origin="1970-01-01"))[1]
405 abline(v=ts, col=col, lty=lty)
407 lines(c(ts,ts),c(0,height), col=col, lty=lty)
412 tstamp <- function (date, format="%Y-%m-%d")
414 ts <- unclass(as.POSIXct(date, format=format, origin="1970-01-01"))[1]