統計與計量‎ > ‎應用總覽‎ > ‎

記憶體使用分析

資料結構

統計分析圖表

ANOVA(MEM_NUM_PERM)
Tables of means
Grand mean
         
22.49532 

 factor(HOSTNAME) 
    F12APDB1 F12APDB2
        39.7     1.91
rep     18.0    15.00


ANOVA(MEM_NUM_CLIENT)
Tables of means
Grand mean
         
22.49532 

 factor(HOSTNAME) 
    F12APDB1 F12APDB2
        39.7     1.91
rep     18.0    15.00

GNU-R

library(DBI)
library(RMySQL)
library(car)

GetDB <- function (SQL) {
  mySQL.Connection <- dbConnect(MySQL(), host=mySQL.Host, user=mySQL.User, password=mySQL.Password, db=mySQL.Schema)

  ResultSet <- dbGetQuery(mySQL.Connection, SQL)
  dbDisconnect(mySQL.Connection)
  
  ResultSet
}

SaveScatterPlotGraphics <- function(pngFileName, formula, graphicsTitle, graphicsXTitle, graphicsYTitle) {
  png(file=pngFileName)
    scatterplot(formula, reg.line=lm, smooth=TRUE, spread=TRUE,
boxplots='xy', span=0.5, main=graphicsTitle, xlab=graphicsXTitle, ylab=graphicsYTitle) dev.off() } PrintANOVA <- function (formula, heading) { cat(paste("ANOVA(", heading, ")", sep="")) cat("\n") R.ANOVA.MEM_NUM_PERM = aov(formula) summary(R.ANOVA.MEM_NUM_PERM) print(model.tables(R.ANOVA.MEM_NUM_PERM, "means"), digits=3) cat("\n\n") } mySQL.Host <- "127.0.0.1" mySQL.User <- "nmon" mySQL.Password <- "nmon" mySQL.Schema <- "nmon" R.Chart.Folder <- "/var/nmon/Results/Graphics" R.Analysis.Folder <- "/var/nmon/Results/Analysis" mySQL.SQL <- paste("SELECT DISTINCT DATE(ZZZZ) AS TXN_DATE FROM ", mySQL.Schema, ".memuse ORDER BY ZZZZ LIMIT 30", sep="") mySQL.DATA <- GetDB(mySQL.SQL) Date.Start <- mySQL.DATA$TXN_DATE[1] Date.End <- mySQL.DATA$TXN_DATE[length(mySQL.DATA$TXN_DATE)] mySQL.SQL <- paste("SELECT HOSTNAME, TO_DAYS(DATE(ZZZZ)) AS TXN_DATE, AVG(PCTnumperm) AS MEM_NUM_PERM, AVG(PCTnumclient) AS MEM_NUM_CLIENT FROM ", mySQL.Schema, ".memuse WHERE DATE(ZZZZ) BETWEEN '", Date.Start, "' AND '", Date.End,
"' GROUP BY HOSTNAME, DATE(ZZZZ) ORDER BY HOSTNAME, DATE(ZZZZ)"
, sep="") mySQL.DATA <- GetDB(mySQL.SQL) TXN_DATE <- (mySQL.DATA$TXN_DATE) HOSTNAME <- (mySQL.DATA$HOSTNAME) MEM_NUM_PERM <- (mySQL.DATA$MEM_NUM_PERM) MEM_NUM_CLIENT <- (mySQL.DATA$MEM_NUM_CLIENT) mySQL.Chart <- paste(R.Chart.Folder, "/", "AVG_HOST_MEM_NUM_PERM.png", sep="") SaveScatterPlotGraphics(mySQL.Chart, MEM_NUM_PERM~TXN_DATE | HOSTNAME,
"CPU.USER~TXN.DATE by HOST (Last 30 Days)", "Day #", "MEM.NUM.PERM") mySQL.Chart <- paste(R.Chart.Folder, "/", "AVG_HOST_MEM_NUM_CLIENT.png", sep="") SaveScatterPlotGraphics(mySQL.Chart, MEM_NUM_CLIENT~TXN_DATE | HOSTNAME,
"CPU.WAIT~TXN.DATE by HOST (Last 30 Days)", "Day #", "MEM.NUM.CLIENT") sink(paste(R.Analysis.Folder, "/", "AVG_HOST_MEM.txt", sep="")) PrintANOVA(MEM_NUM_PERM~factor(HOSTNAME), "MEM_NUM_PERM") PrintANOVA(MEM_NUM_CLIENT~factor(HOSTNAME), "MEM_NUM_CLIENT") sink() rm(list=(ls()))
ċ
ReportDB-AVG_MEM.R
(2k)
李智,
2012年7月5日 上午5:42