' ' 初期設定値 ' Const WASSTDERRLOG_ROW = 13 ' WAS stderr ファイル名を入力するセルの行番号 Const WASSTDERRLOG_COLUMN = 3 ' WAS stderr ファイル名を入力するセルの桁番号 Const TARGETDATE_ROW = 19 ' 解析する対象日付のセルの行番号 Const TARGETDATE_COLUMN = 3 ' 解析する対象日付のセルの桁番号 Dim Table As Variant Private Sub CommandButton1_Click() ' ' 監視実行 ' Call stderrデータ読込 End Sub Private Sub CommandButton2_Click() Call クリア End Sub Private Sub stderrデータ読込() ' ' 初期設定 ' Dim intIndex As Integer ' 配列の列(jvmstat の各項目に対応) Dim intRow As Integer ' 配列の行(jvmstat の行に対応) Dim intFileNo As Integer ' ファイル番号 Dim strText As String ' ファイルから1行読み込んだ内容 Dim noSpace As String ' 連続した空白を1つの空白に置換した内容となる Dim StderrFile As String ' stderr ログファイル名 Dim strArray() As String ' 空白区切りで配列にしたもの ' ' マクロ動作をユーザーに意識させない ' Application.ScreenUpdating = False If IsObject(Table) = False Then Set Table = CreateObject("Scripting.Dictionary") End If Errorno = 1 With Workbooks(ThisWorkbook.Name) ' ' 「使用方法」シートより stderr 結果のファイル名を取り出す ' StderrFile = .Path & "\\" & .Sheets("使用方法").Cells(WASSTDERRLOG_ROW, WASSTDERRLOG_COLUMN) ' ' 「使用方法」シートより stderr 結果のファイル名を取り出す ' TargetDate = Format(.Sheets("使用方法").Cells(TARGETDATE_ROW, TARGETDATE_COLUMN), "mmmddyyyy") ' ' 「データ」シートの B3 セルから stderr の内容をロードする。 ' intFileNo = FreeFile Open StderrFile For Input Access Read As intFileNo Do Until EOF(intFileNo) ' ' 1行ずつ取り出し ' strText = "" Do strSj = InputB(1, #intFileNo) strUni = StrConv(strSj, vbUnicode) If EOF(intFileNo) Or strUni = vbLf Then Exit Do End If strText = strText & strUni Loop ' ' 連続した空白をカット ' noSpace = "" For i = 1 To Len(strText) If Mid$(strText, i, 2) <> " " Then noSpace = noSpace & Mid$(strText, i, 1) End If Next ' ' 空白区切りで配列に展開 ' strArray = Split(Trim(noSpace), " ") ' ' ヘッダ部分は読み飛ばし、そうでない部分はセルに格納 ' ' AIX WAS 3.0 ' GC: Thu Oct 13 03:40:42 2005 ' ' ' Windows WAS 4.0 ' ' ' AIX WAS 5.1 ' ' head = Mid$(noSpace, 1, 3) If head = " Chr$(9) Then ErrorName = strArray(0) If Not Table.Exists(ErrorName) Then Table(ErrorName) = Errorno .Sheets("Data1").Cells(1, Errorno + 7) = ErrorName .Sheets("Data1").Cells(1, Errorno + 7).Interior.ColorIndex = 15 Errorno = Errorno + 1 End If .Sheets("Data1").Cells(intRow + 2, Table(ErrorName) + 7) = Str(100 + Table(ErrorName) * 2) + "%" End If End If Loop ' ' ファイルのクローズ ' Close intFileNo ' ' Data2 の作成 ' For i = 0 To intRow gctime = .Sheets("Data1").Cells(i + 2, 1) t = Int(24 * 60 * gctime) afms = .Sheets("Data1").Cells(i + 2, 6) .Sheets("Data2").Cells(t + 2, 2) = .Sheets("Data2").Cells(t + 2, 2) + afms .Sheets("Data2").Cells(t + 2, 3) = .Sheets("Data2").Cells(t + 2, 3) + 1 Next ' ' グラフ の作成 ' RowMax = Mid$(Str$(intRow + 2), 2) Graph1 = "A1:A" + RowMax + ",B1:B" + RowMax + ",C1:C" + RowMax + ",D1:D" + RowMax Graph2 = "A1:A" + RowMax + ",E1:E" + RowMax + ",F1:F" + RowMax Graph3 = "A1:A" + RowMax + ",G1:G" + RowMax Alpha = Chr$(Asc("G") + Errorno - 1) Graph3 = Graph3 + "," + Alpha + "1:" + Alpha + RowMax .Sheets("Data1").Columns("A:" + Alpha).EntireColumn.AutoFit .Charts("GC-Heap").SetSourceData Source:=.Sheets("Data1").Range(Graph1), PlotBy:=xlColumns .Charts("GC-Time").SetSourceData Source:=.Sheets("Data1").Range(Graph2), PlotBy:=xlColumns .Charts("Free").SetSourceData Source:=.Sheets("Data1").Range(Graph3), PlotBy:=xlColumns RowMax = Mid$(Str$(.Sheets("Data2").UsedRange.Rows.Count), 2) Graph4 = "A1:A" + RowMax + ",B1:B" + RowMax Graph5 = "A1:A" + RowMax + ",C1:C" + RowMax .Charts("GC-Time2").SetSourceData Source:=.Sheets("Data2").Range(Graph4), PlotBy:=xlColumns .Charts("GC-回数").SetSourceData Source:=.Sheets("Data2").Range(Graph5), PlotBy:=xlColumns For no = 2 To .Sheets.Count .Sheets(no).Visible = xlSheetVisible Next no For no = 1 To .Charts.Count .Charts(no).Visible = xlSheetVisible Next no End With End Sub Private Sub クリア() With Workbooks(ThisWorkbook.Name) .Sheets("Data1").Range("A2:IV65536").Delete .Sheets("Data2").Range("A2:IV65536").Delete For no = 2 To .Sheets.Count .Sheets(no).Visible = xlSheetHidden Next no For no = 1 To .Charts.Count .Charts(no).Visible = xlSheetHidden Next no If IsObject(Table) = True Then Table.RemoveAll End If For t = 0 To 24 * 60 - 1 .Sheets("Data2").Cells(t + 2, 1) = t / 24 / 60 Next t For i = 1 To Errorno - 1 .Sheets("Data1").Cells(1, Errorno + 7) = "" Next End With End Sub