' ' 「使用方法」タブの入力項目 ' Const VMSTATINTERVAL_ROW = 10 ' vmstatコマンドの間隔セルの行番号 Const VMSTATINTERVAL_COLUMN = 5 ' vmstatコマンドの間隔セルの列番号 Const INTERVAL_ROW = 34 ' 監視間隔を入力するセルの行番号 Const INTERVAL_COLUMN = 3 ' 監視間隔を入力するセルの列番号 Const VMSTATLOGPATH_ROW = 18 ' vmstatログパス名を入力するセルの行番号 Const VMSTATLOGPATH_COLUMN = 9 ' vmstatログパス名を入力するセルの列番号 Const VMSTATLOGFILE_ROW = 19 ' vmstatログファイル名を入力するセルの行番号 Const VMSTATLOGFILE_COLUMN = 9 ' vmstatログファイル名を入力するセルの列番号 Const STARTTIME_ROW = 14 ' 開始時刻セルの行番号 Const STARTTIME_COLUMN = 2 ' 開始時刻セルの列番号 Const DEFAULT_INTERVAL_MIN = 1 ' 監視間隔のデフォルト(分) ' ' OS 別の vmstat のエントリ数 ' Const AIX = 17 Const HP = 18 Const LINUX = 16 Const SOLARIS = 22 Dim VmstatInterval As Integer ' vmstat のグラフの再描画間隔(分) Private Sub CommandButton1_Click() Call vmstatデータ読込 With Workbooks(ThisWorkbook.Name).Sheets("使用方法") .Select .CommandButton1.Enabled = False .CommandButton2.Enabled = True .CommandButton3.Enabled = False .CommandButton4.Enabled = True .ToggleButton1.Enabled = False End With End Sub Private Sub CommandButton2_Click() Call クリア With Workbooks(ThisWorkbook.Name).Sheets("使用方法") .Select .CommandButton1.Enabled = True .CommandButton2.Enabled = False .CommandButton3.Enabled = False .CommandButton4.Enabled = False .ToggleButton1.Enabled = True End With End Sub Private Sub CommandButton3_Click() Call グラフ描画 With Workbooks(ThisWorkbook.Name).Sheets("使用方法") .Select .CommandButton1.Enabled = False .CommandButton2.Enabled = True .CommandButton3.Enabled = False .CommandButton4.Enabled = True .ToggleButton1.Enabled = False End With End Sub Private Sub CommandButton4_Click() Call グラフ消去 With Workbooks(ThisWorkbook.Name).Sheets("使用方法") .Select .CommandButton1.Enabled = False .CommandButton2.Enabled = False .CommandButton3.Enabled = True .CommandButton4.Enabled = False .ToggleButton1.Enabled = False End With End Sub Private Sub ToggleButton1_Click() With Workbooks(ThisWorkbook.Name).Sheets("使用方法") If .ToggleButton1.Value = True Then .ToggleButton1.Caption = "監視停止" .CommandButton1.Enabled = False .CommandButton2.Enabled = False .CommandButton3.Enabled = False .CommandButton4.Enabled = False .ToggleButton1.Enabled = True Call 監視開始 Else .ToggleButton1.Caption = "監視開始" .CommandButton1.Enabled = False .CommandButton2.Enabled = True .CommandButton3.Enabled = False .CommandButton4.Enabled = True .ToggleButton1.Enabled = True End If End With End Sub Sub 監視開始() Dim Interval_min As Integer ' 監視間隔(数値) Dim TimeString As String ' 監視間隔(XX:XX 形式) Dim PreSheet As String ' ' マクロ動作をユーザーに意識させない ' Application.ScreenUpdating = False ' ' Active シートの記憶 ' PreSheet = ActiveSheet.Name With Workbooks(ThisWorkbook.Name).Sheets("使用方法") ' ' 監視間隔値の取得 ' Interval_min = .Cells(INTERVAL_ROW, INTERVAL_COLUMN) If Interval_min <= 0 Or 60 <= Interval_min Then Interval_min = DEFAULT_INTERVAL_MIN End If TimeString = "00:" & Right$("00" & Mid$(Str(Interval_min), 2, Len(Str(Interval_min)) - 1), 2) & ":00" StartTime = Now() + TimeValue(TimeString) If .ToggleButton1.Value = True Then ' ' 次の監視をスケジュール ' Application.OnTime StartTime, "Sheet1.監視開始" ' ' 監視実行 ' Call vmstatデータ読込 End If End With ' ' Active シートの復帰 ' Workbooks(ThisWorkbook.Name).Sheets(PreSheet).Select End Sub Private Sub vmstatデータ読込() Dim intFileNo As Integer ' ファイル番号 Dim noSpace As String ' 読み込みバッファの連続する空白を省いたもの Dim strArray() As String ' 空白区切りで配列にしたもの Dim ArrayCount As Integer ' 読み取った配列の要素の最大数 Dim intIndex As Integer ' 配列の列(vmstat の各項目に対応) Dim strText As String ' ファイルから1行読み込んだ内容 Dim VmstatPath As String ' vmstat のログ格納パス Dim VmstatFile As String ' vmstat のログファイル名 Dim VmstatInterval As Double ' vmstat の測定間隔 Dim VmstatStartTime As Double ' vmstat の測定開始時刻 Static intRow As Integer ' 行数 intRow = 3 ' 行数初期設定 ' ' マクロ動作をユーザーに意識させない ' Application.ScreenUpdating = False ' ' 「使用方法」シートからの初期値の取り出し ' With Workbooks(ThisWorkbook.Name).Sheets("使用方法") ' ' vmstat 結果のファイル名 ' VmstatPath = .Cells(VMSTATLOGPATH_ROW, VMSTATLOGPATH_COLUMN) If VmstatPath = "" Then VmstatPath = Workbooks(ThisWorkbook.Name).Path End If VmstatFile = VmstatPath & "\" & .Cells(VMSTATLOGFILE_ROW, VMSTATLOGFILE_COLUMN) ' ' 測定間隔を取り出す ' VmstatInterval = .Cells(VMSTATINTERVAL_ROW, VMSTATINTERVAL_COLUMN) / 86400 ' ' 測定開始時刻を取り出す ' VmstatStartTime = .Cells(STARTTIME_ROW, STARTTIME_COLUMN) End With ' ' Data シートへの取り込み ' With Workbooks(ThisWorkbook.Name).Sheets("Data") ' ' 「データ」シートの B3 セルから vmstat の内容をロードする。 ' intFileNo = FreeFile Open VmstatFile 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 ' ' 末尾に改行がある場合は削除 ' a = Right$(noSpace, 1) If Right$(noSpace, 1) = vbCr Then noSpace = Left$(noSpace, Len(noSpace) - 1) End If ' ' 空白区切りで配列に展開 ' strArray = Split(Trim(noSpace), " ") ArrayCount = UBound(strArray) ' ' ヘッダ部分は読み飛ばし、そうでない部分はセルに格納 ' If ArrayCount < 15 Then ' ヘッダまたはデータ以外 ElseIf InStr("0123456789", Left$(strArray(0), 1)) <= 0 Then ' データ以外 Else If .Cells(intRow, 1) <> "" Then ' 既に入力済み Else If intRow > 3 Then .Cells(intRow, 1) = .Cells(intRow - 1, 1) + VmstatInterval Else intRow = 3 .Cells(intRow, 1) = VmstatStartTime End If For intIndex = 0 To ArrayCount .Cells(intRow, intIndex + 2) = strArray(intIndex) Next intIndex End If intRow = intRow + 1 End If Loop ' ' ファイルのクローズ ' Close intFileNo ' ' チャートの作成 ' Call グラフ描画 ' ' シートのカラム幅を整形 ' .Cells.EntireColumn.AutoFit .Columns("A:A").NumberFormatLocal = "yyyy/m/d h:mm:ss" .Rows("1:2").HorizontalAlignment = xlCenter End With End Sub ' ' グラフ描画 ' Private Sub グラフ描画() Call グラフ消去 With Workbooks(ThisWorkbook.Name).Sheets("Data") .Cells(1, 2) = " " intRow = .UsedRange.Rows.Count Entry = .UsedRange.Columns.Count - 1 ' 時刻があるので -1 End With If Entry = AIX Then OptionButton_AIX1.Value = True Call AIX_グラフ描画(Mid$(Str$(intRow), 2)) ElseIf Entry = HP Then OptionButton_HP1.Value = True Call HP_グラフ描画(Mid$(Str$(intRow), 2)) ElseIf Entry = LINUX Then Call Linux_グラフ描画(Mid$(Str$(intRow), 2)) ElseIf Entry = SOLARIS Then OptionButton_Solaris1.Value = True Call Solaris_グラフ描画(Mid$(Str$(intRow), 2)) End If End Sub ' ' AIX のグラフ描画 ' ' kthr メモリー ページ フォールト cpu ' ----- ----------- ------------------------ ------------ ----------- ' r b avm fre re pi po fr sr cy in sy cs us sy id wa ' Private Sub AIX_グラフ描画(MaxRow As String) With Workbooks(ThisWorkbook.Name).Sheets("Data") .Select .Range("B1:C1").Merge .Range("D1:E1").Merge .Range("F1:K1").Merge .Range("L1:N1").Merge .Range("O1:R1").Merge .Cells(1, 2) = "kthr" .Cells(1, 4) = "memory" .Cells(1, 6) = "page" .Cells(1, 12) = "fault" .Cells(1, 15) = "cpu" .Cells(2, 2) = "r" .Cells(2, 3) = "b" .Cells(2, 4) = "avm" .Cells(2, 5) = "fre" .Cells(2, 6) = "re" .Cells(2, 7) = "pi" .Cells(2, 8) = "po" .Cells(2, 9) = "fr" .Cells(2, 10) = "sr" .Cells(2, 11) = "cy" .Cells(2, 12) = "in" .Cells(2, 13) = "sy" .Cells(2, 14) = "cs" .Cells(2, 15) = "us" .Cells(2, 16) = "sy" .Cells(2, 17) = "id" .Cells(2, 18) = "wa" End With With Workbooks(ThisWorkbook.Name) ' ' CPU ' Charts.Add After:=.Sheets("使用方法") With ActiveChart .ChartType = xlAreaStacked100 .SetSourceData Source:=Workbooks(ThisWorkbook.Name).Sheets("Data").Range("A1:A" & MaxRow & ",O1:R" & MaxRow), PlotBy:=xlColumns .Name = "CPU" .Location Where:=xlLocationAsNewSheet .Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale .Axes(xlCategory, xlPrimary).TickLabels.Orientation = 45 .HasTitle = True .HasLegend = True .Legend.Top = 9 .Legend.Left = 504 .Legend.Width = 202 .Legend.Height = 31 .PlotArea.Width = 700 .ChartTitle.Characters.Text = "CPU使用率" .SeriesCollection(3).PlotOrder = 4 .Legend.LegendEntries(1).LegendKey.Interior.ColorIndex = 27 .Legend.LegendEntries(2).LegendKey.Interior.ColorIndex = 3 .Legend.LegendEntries(3).LegendKey.Interior.ColorIndex = 30 .Legend.LegendEntries(4).LegendKey.Interior.ColorIndex = 28 End With ' ' Fault ' Charts.Add After:=.Sheets("使用方法") With ActiveChart .ChartType = xlLineMarkers .SetSourceData Source:=Workbooks(ThisWorkbook.Name).Sheets("Data").Range("A1:A" & MaxRow & ",L1:N" & MaxRow), PlotBy:=xlColumns .Name = "Fault" .Location Where:=xlLocationAsNewSheet .Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale .Axes(xlCategory, xlPrimary).TickLabels.Orientation = 45 .HasTitle = True .HasLegend = True .Legend.Top = 13 .Legend.Left = 504 .Legend.Width = 202 .Legend.Height = 26 .PlotArea.Width = 700 .Axes(xlValue).HasTitle = True .Axes(xlValue).AxisTitle.Characters.Text = "回数" .Axes(xlValue).AxisTitle.Orientation = xlHorizontal .Axes(xlValue).AxisTitle.Left = 38 .Axes(xlValue).AxisTitle.Top = 13 .ChartTitle.Characters.Text = "ページフォルト" End With ' ' Page ' Charts.Add After:=.Sheets("使用方法") With ActiveChart .ChartType = xlLineMarkers .SetSourceData Source:=Workbooks(ThisWorkbook.Name).Sheets("Data").Range("A1:A" & MaxRow & ",F1:K" & MaxRow), PlotBy:=xlColumns .Name = "Page" .Location Where:=xlLocationAsNewSheet .Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale .Axes(xlCategory, xlPrimary).TickLabels.Orientation = 45 .HasTitle = True .HasLegend = True .Legend.Top = 1 .Legend.Left = 550 .Legend.Width = 155 .Legend.Height = 45 .PlotArea.Width = 700 .Axes(xlValue).HasTitle = True .Axes(xlValue).AxisTitle.Characters.Text = "1KBページ数" .Axes(xlValue).AxisTitle.Orientation = xlHorizontal .Axes(xlValue).AxisTitle.Left = 38 .Axes(xlValue).AxisTitle.Top = 13 .ChartTitle.Characters.Text = "スワップ発生" End With ' ' Memory ' Charts.Add After:=.Sheets("使用方法") With ActiveChart .ChartType = xlLineMarkers .SetSourceData Source:=Workbooks(ThisWorkbook.Name).Sheets("Data").Range("A1:A" & MaxRow & ",D1:E" & MaxRow), PlotBy:=xlColumns .Name = "Mem" .Location Where:=xlLocationAsNewSheet .Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale .Axes(xlCategory, xlPrimary).TickLabels.Orientation = 45 .HasTitle = True .HasLegend = True .Legend.Left = 620 .Legend.Top = 10 .PlotArea.Width = 700 .Axes(xlValue).HasTitle = True .Axes(xlValue).AxisTitle.Characters.Text = "Page (4KB)" .Axes(xlValue).AxisTitle.Orientation = xlHorizontal .Axes(xlValue).AxisTitle.Left = 38 .Axes(xlValue).AxisTitle.Top = 13 .ChartTitle.Characters.Text = "メモリ使用率" End With End With End Sub ' ' HP のグラフ描画 ' ' procs memory page faults cpu ' r b w avm free re at pi po fr de sr in sy cs us sy id ' Private Sub HP_グラフ描画(MaxRow As String) With Workbooks(ThisWorkbook.Name).Sheets("Data") .Select .Range("B1:D1").Merge .Range("E1:F1").Merge .Range("G1:M1").Merge .Range("N1:P1").Merge .Range("Q1:S1").Merge .Cells(1, 2) = "kthr" .Cells(1, 5) = "memory" .Cells(1, 7) = "page" .Cells(1, 14) = "fault" .Cells(1, 17) = "cpu" .Cells(2, 2) = "r" .Cells(2, 3) = "b" .Cells(2, 4) = "w" .Cells(2, 5) = "avm" .Cells(2, 6) = "fre" .Cells(2, 7) = "re" .Cells(2, 8) = "at" .Cells(2, 9) = "pi" .Cells(2, 10) = "po" .Cells(2, 11) = "fr" .Cells(2, 12) = "de" .Cells(2, 13) = "sr" .Cells(2, 14) = "in" .Cells(2, 15) = "sy" .Cells(2, 16) = "cs" .Cells(2, 17) = "us" .Cells(2, 18) = "sy" .Cells(2, 19) = "id" End With With Workbooks(ThisWorkbook.Name) ' ' CPU ' Charts.Add After:=.Sheets("使用方法") With ActiveChart .ChartType = xlAreaStacked100 .SetSourceData Source:=Workbooks(ThisWorkbook.Name).Sheets("Data").Range("A1:A" & MaxRow & ",Q1:S" & MaxRow), PlotBy:=xlColumns .Name = "CPU" .Location Where:=xlLocationAsNewSheet .Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale .Axes(xlCategory, xlPrimary).TickLabels.Orientation = 45 .HasTitle = True .HasLegend = True .Legend.Top = 9 .Legend.Left = 504 .Legend.Width = 202 .Legend.Height = 31 .PlotArea.Width = 700 .ChartTitle.Characters.Text = "CPU使用率" .Legend.LegendEntries(1).LegendKey.Interior.ColorIndex = 27 .Legend.LegendEntries(2).LegendKey.Interior.ColorIndex = 3 .Legend.LegendEntries(3).LegendKey.Interior.ColorIndex = 28 End With ' ' Fault ' Charts.Add After:=.Sheets("使用方法") With ActiveChart .ChartType = xlLineMarkers .SetSourceData Source:=Workbooks(ThisWorkbook.Name).Sheets("Data").Range("A1:A" & MaxRow & ",N1:P" & MaxRow), PlotBy:=xlColumns .Name = "Fault" .Location Where:=xlLocationAsNewSheet .Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale .Axes(xlCategory, xlPrimary).TickLabels.Orientation = 45 .HasTitle = True .HasLegend = True .Legend.Top = 13 .Legend.Left = 504 .Legend.Width = 202 .Legend.Height = 26 .PlotArea.Width = 700 .Axes(xlValue).HasTitle = True .Axes(xlValue).AxisTitle.Characters.Text = "回数" .Axes(xlValue).AxisTitle.Orientation = xlHorizontal .Axes(xlValue).AxisTitle.Left = 38 .Axes(xlValue).AxisTitle.Top = 13 .ChartTitle.Characters.Text = "ページフォルト" End With ' ' Page ' Charts.Add After:=.Sheets("使用方法") With ActiveChart .ChartType = xlLineMarkers .SetSourceData Source:=Workbooks(ThisWorkbook.Name).Sheets("Data").Range("A1:A" & MaxRow & ",G1:M" & MaxRow), PlotBy:=xlColumns .Name = "Page" .Location Where:=xlLocationAsNewSheet .Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale .Axes(xlCategory, xlPrimary).TickLabels.Orientation = 45 .HasTitle = True .HasLegend = True .Legend.Top = 4 .Legend.Left = 465 .Legend.Width = 243 .Legend.Height = 45 .PlotArea.Width = 700 .Axes(xlValue).HasTitle = True .Axes(xlValue).AxisTitle.Characters.Text = "1KBページ数" .Axes(xlValue).AxisTitle.Orientation = xlHorizontal .Axes(xlValue).AxisTitle.Left = 38 .Axes(xlValue).AxisTitle.Top = 13 .ChartTitle.Characters.Text = "スワップ発生" End With ' ' Memory ' Charts.Add After:=.Sheets("使用方法") With ActiveChart .ChartType = xlLineMarkers .SetSourceData Source:=Workbooks(ThisWorkbook.Name).Sheets("Data").Range("A1:A" & MaxRow & ",E1:F" & MaxRow), PlotBy:=xlColumns .Name = "Mem" .Location Where:=xlLocationAsNewSheet .Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale .Axes(xlCategory, xlPrimary).TickLabels.Orientation = 45 .HasTitle = True .HasLegend = True .Legend.Left = 620 .Legend.Top = 10 .PlotArea.Width = 700 .Axes(xlValue).HasTitle = True .Axes(xlValue).AxisTitle.Characters.Text = "Page (4KB)" .Axes(xlValue).AxisTitle.Orientation = xlHorizontal .Axes(xlValue).AxisTitle.Left = 38 .Axes(xlValue).AxisTitle.Top = 13 .ChartTitle.Characters.Text = "メモリ使用率" End With End With End Sub ' ' Linux のグラフ描画 ' ' procs memory swap io system cpu ' r b w swpd free buff cache si so bi bo in cs us sy id ' r b swpd free buff cache si so bi bo in cs us sy wa id ' r b swpd free buff cache si so bi bo in cs us sy id wa Private Sub Linux_グラフ描画(MaxRow As String) If OptionButton_Linux2.Value = True Then RangePROCS = "B1:C" RangeMEMORY = "D1:G" RangeSWAP = "H1:I" RangeIO = "J1:K" RangeSYSTEM = "L1:M" RangeCPU = "N1:Q" With Workbooks(ThisWorkbook.Name).Sheets("Data") .Select .Cells(1, 2) = "procs" .Cells(1, 4) = "memory" .Cells(1, 8) = "swap" .Cells(1, 10) = "io" .Cells(1, 12) = "system" .Cells(1, 14) = "cpu" .Cells(2, 2) = "r" .Cells(2, 3) = "b" .Cells(2, 4) = "swpd" .Cells(2, 5) = "free" .Cells(2, 6) = "buff" .Cells(2, 7) = "cache" .Cells(2, 8) = "si" .Cells(2, 9) = "so" .Cells(2, 10) = "bi" .Cells(2, 11) = "bo" .Cells(2, 12) = "in" .Cells(2, 13) = "cs" .Cells(2, 14) = "us" .Cells(2, 15) = "sy" .Cells(2, 16) = "wa" .Cells(2, 17) = "id" End With ElseIf OptionButton_Linux3.Value = True Then RangePROCS = "B1:C" RangeMEMORY = "D1:G" RangeSWAP = "H1:I" RangeIO = "J1:K" RangeSYSTEM = "L1:M" RangeCPU = "N1:Q" With Workbooks(ThisWorkbook.Name).Sheets("Data") .Select .Cells(1, 2) = "procs" .Cells(1, 4) = "memory" .Cells(1, 8) = "swap" .Cells(1, 10) = "io" .Cells(1, 12) = "system" .Cells(1, 14) = "cpu" .Cells(2, 2) = "r" .Cells(2, 3) = "b" .Cells(2, 4) = "swpd" .Cells(2, 5) = "free" .Cells(2, 6) = "buff" .Cells(2, 7) = "cache" .Cells(2, 8) = "si" .Cells(2, 9) = "so" .Cells(2, 10) = "bi" .Cells(2, 11) = "bo" .Cells(2, 12) = "in" .Cells(2, 13) = "cs" .Cells(2, 14) = "us" .Cells(2, 15) = "sy" .Cells(2, 16) = "id" .Cells(2, 17) = "wa" End With Else OptionButton_Linux1.Value = True RangePROCS = "B1:D" RangeMEMORY = "E1:H" RangeSWAP = "I1:J" RangeIO = "K1:L" RangeSYSTEM = "M1:N" RangeCPU = "O1:Q" With Workbooks(ThisWorkbook.Name).Sheets("Data") .Select .Cells(1, 2) = "procs" .Cells(1, 5) = "memory" .Cells(1, 9) = "swap" .Cells(1, 11) = "io" .Cells(1, 13) = "system" .Cells(1, 15) = "cpu" .Cells(2, 2) = "r" .Cells(2, 3) = "b" .Cells(2, 4) = "w" .Cells(2, 5) = "swpd" .Cells(2, 6) = "free" .Cells(2, 7) = "buff" .Cells(2, 8) = "cache" .Cells(2, 9) = "si" .Cells(2, 10) = "so" .Cells(2, 11) = "bi" .Cells(2, 12) = "bo" .Cells(2, 13) = "in" .Cells(2, 14) = "cs" .Cells(2, 15) = "us" .Cells(2, 16) = "sy" .Cells(2, 17) = "id" End With End If With Workbooks(ThisWorkbook.Name).Sheets("Data") .Range(RangePROCS & "1").Merge .Range(RangeMEMORY & "1").Merge .Range(RangeSWAP & "1").Merge .Range(RangeIO & "1").Merge .Range(RangeSYSTEM & "1").Merge .Range(RangeCPU & "1").Merge End With With Workbooks(ThisWorkbook.Name) ' ' CPU ' Charts.Add After:=.Sheets("使用方法") With ActiveChart .ChartType = xlAreaStacked100 .SetSourceData Source:=Workbooks(ThisWorkbook.Name).Sheets("Data").Range("A1:A" & MaxRow & "," & RangeCPU & MaxRow), PlotBy:=xlColumns .Name = "CPU" .Location Where:=xlLocationAsNewSheet .Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale .Axes(xlCategory, xlPrimary).TickLabels.Orientation = 45 .HasTitle = True .HasLegend = True .Legend.Top = 9 .Legend.Left = 504 .Legend.Width = 202 .Legend.Height = 31 .PlotArea.Width = 700 .ChartTitle.Characters.Text = "CPU使用率" .Legend.LegendEntries(1).LegendKey.Interior.ColorIndex = 27 .Legend.LegendEntries(2).LegendKey.Interior.ColorIndex = 3 .Legend.LegendEntries(3).LegendKey.Interior.ColorIndex = 28 End With ' ' System ' Charts.Add After:=.Sheets("使用方法") With ActiveChart .ChartType = xlLineMarkers .SetSourceData Source:=Workbooks(ThisWorkbook.Name).Sheets("Data").Range("A1:A" & MaxRow & "," & RangeSYSTEM & MaxRow), PlotBy:=xlColumns .Name = "System" .Location Where:=xlLocationAsNewSheet .Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale .Axes(xlCategory, xlPrimary).TickLabels.Orientation = 45 .HasTitle = True .HasLegend = True .Legend.Top = 13 .Legend.Left = 504 .Legend.Width = 202 .Legend.Height = 26 .PlotArea.Width = 700 .Axes(xlValue).HasTitle = True .Axes(xlValue).AxisTitle.Characters.Text = "回数/秒" .Axes(xlValue).AxisTitle.Orientation = xlHorizontal .Axes(xlValue).AxisTitle.Left = 38 .Axes(xlValue).AxisTitle.Top = 13 .ChartTitle.Characters.Text = "System" End With ' ' I/O ' Charts.Add After:=.Sheets("使用方法") With ActiveChart .ChartType = xlLineMarkers .SetSourceData Source:=Workbooks(ThisWorkbook.Name).Sheets("Data").Range("A1:A" & MaxRow & "," & RangeIO & MaxRow), PlotBy:=xlColumns .Name = "io" .Location Where:=xlLocationAsNewSheet .Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale .Axes(xlCategory, xlPrimary).TickLabels.Orientation = 45 .HasTitle = True .HasLegend = True .Legend.Top = 13 .Legend.Left = 504 .Legend.Width = 202 .Legend.Height = 26 .PlotArea.Width = 700 .Axes(xlValue).HasTitle = True .Axes(xlValue).AxisTitle.Characters.Text = "ブロック/秒" .Axes(xlValue).AxisTitle.Orientation = xlHorizontal .Axes(xlValue).AxisTitle.Left = 38 .Axes(xlValue).AxisTitle.Top = 13 .ChartTitle.Characters.Text = "ディスクI/O" End With ' ' Swap ' Charts.Add After:=.Sheets("使用方法") With ActiveChart .ChartType = xlLineMarkers .SetSourceData Source:=Workbooks(ThisWorkbook.Name).Sheets("Data").Range("A1:A" & MaxRow & "," & RangeSWAP & MaxRow), PlotBy:=xlColumns .Name = "Page" .Location Where:=xlLocationAsNewSheet .Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale .Axes(xlCategory, xlPrimary).TickLabels.Orientation = 45 .HasTitle = True .HasLegend = True .Legend.Top = 13 .Legend.Left = 504 .Legend.Width = 202 .Legend.Height = 26 .PlotArea.Width = 700 .Axes(xlValue).HasTitle = True .Axes(xlValue).AxisTitle.Characters.Text = "KB/sec" .Axes(xlValue).AxisTitle.Orientation = xlHorizontal .Axes(xlValue).AxisTitle.Left = 38 .Axes(xlValue).AxisTitle.Top = 13 .ChartTitle.Characters.Text = "スワップ発生" End With ' ' Memory ' Charts.Add After:=.Sheets("使用方法") With ActiveChart .ChartType = xlLineMarkers .SetSourceData Source:=Workbooks(ThisWorkbook.Name).Sheets("Data").Range("A1:A" & MaxRow & "," & RangeMEMORY & MaxRow), PlotBy:=xlColumns .Name = "Mem" .Location Where:=xlLocationAsNewSheet .Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale .Axes(xlCategory, xlPrimary).TickLabels.Orientation = 45 .HasTitle = True .HasLegend = True .Legend.Left = 511 .Legend.Top = 2 .Legend.Height = 41 .Legend.Width = 197 .PlotArea.Width = 700 .Axes(xlValue).HasTitle = True .Axes(xlValue).AxisTitle.Characters.Text = "KB" .Axes(xlValue).AxisTitle.Orientation = xlHorizontal .Axes(xlValue).AxisTitle.Left = 38 .Axes(xlValue).AxisTitle.Top = 13 .ChartTitle.Characters.Text = "メモリ使用率" End With End With End Sub ' ' Solaris のグラフ描画 ' ' procs memory page disk faults cpu ' r b w swap free re mf pi po fr de sr s0 s1 s1 -- in sy cs us sy id ' Private Sub Solaris_グラフ描画(MaxRow As String) With Workbooks(ThisWorkbook.Name).Sheets("Data") .Select .Range("B1:D1").Merge .Range("E1:F1").Merge .Range("G1:M1").Merge .Range("N1:Q1").Merge .Range("R1:T1").Merge .Range("U1:W1").Merge .Cells(1, 2) = "procs" .Cells(1, 5) = "memory" .Cells(1, 7) = "page" .Cells(1, 14) = "disk" .Cells(1, 18) = "faults" .Cells(1, 21) = "cpu" .Cells(2, 2) = "r" .Cells(2, 3) = "b" .Cells(2, 4) = "w" .Cells(2, 5) = "swap" .Cells(2, 6) = "free" .Cells(2, 7) = "re" .Cells(2, 8) = "mf" .Cells(2, 9) = "pi" .Cells(2, 10) = "po" .Cells(2, 11) = "fr" .Cells(2, 12) = "de" .Cells(2, 13) = "sr" .Cells(2, 14) = "s0" .Cells(2, 15) = "s1" .Cells(2, 16) = "s2" .Cells(2, 17) = "s3" .Cells(2, 18) = "in" .Cells(2, 19) = "sy" .Cells(2, 20) = "cs" .Cells(2, 21) = "us" .Cells(2, 22) = "sy" .Cells(2, 23) = "id" End With With Workbooks(ThisWorkbook.Name) ' ' CPU ' Charts.Add After:=.Sheets("使用方法") With ActiveChart .ChartType = xlAreaStacked100 .SetSourceData Source:=Workbooks(ThisWorkbook.Name).Sheets("Data").Range("A1:A" & MaxRow & ",U1:W" & MaxRow), PlotBy:=xlColumns .Name = "CPU" .Location Where:=xlLocationAsNewSheet .Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale .Axes(xlCategory, xlPrimary).TickLabels.Orientation = 45 .HasTitle = True .HasLegend = True .Legend.Top = 9 .Legend.Left = 504 .Legend.Width = 202 .Legend.Height = 31 .PlotArea.Width = 700 .ChartTitle.Characters.Text = "CPU使用率" .Legend.LegendEntries(1).LegendKey.Interior.ColorIndex = 27 .Legend.LegendEntries(2).LegendKey.Interior.ColorIndex = 3 .Legend.LegendEntries(3).LegendKey.Interior.ColorIndex = 28 End With ' ' Disk ' Charts.Add After:=.Sheets("使用方法") With ActiveChart .ChartType = xlLineMarkers .SetSourceData Source:=Workbooks(ThisWorkbook.Name).Sheets("Data").Range("A1:A" & MaxRow & ",N1:Q" & MaxRow), PlotBy:=xlColumns .Name = "Disk" .Location Where:=xlLocationAsNewSheet .Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale .Axes(xlCategory, xlPrimary).TickLabels.Orientation = 45 .HasTitle = True .HasLegend = True .Legend.Top = 13 .Legend.Left = 504 .Legend.Width = 202 .Legend.Height = 26 .PlotArea.Width = 700 .Axes(xlValue).HasTitle = True .Axes(xlValue).AxisTitle.Characters.Text = "処理数" .Axes(xlValue).AxisTitle.Orientation = xlHorizontal .Axes(xlValue).AxisTitle.Left = 38 .Axes(xlValue).AxisTitle.Top = 13 .ChartTitle.Characters.Text = "ディスク" End With ' ' Fault ' Charts.Add After:=.Sheets("使用方法") With ActiveChart .ChartType = xlLineMarkers .SetSourceData Source:=Workbooks(ThisWorkbook.Name).Sheets("Data").Range("A1:A" & MaxRow & ",R1:T" & MaxRow), PlotBy:=xlColumns .Name = "Fault" .Location Where:=xlLocationAsNewSheet .Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale .Axes(xlCategory, xlPrimary).TickLabels.Orientation = 45 .HasTitle = True .HasLegend = True .Legend.Top = 13 .Legend.Left = 504 .Legend.Width = 202 .Legend.Height = 26 .PlotArea.Width = 700 .Axes(xlValue).HasTitle = True .Axes(xlValue).AxisTitle.Characters.Text = "回数" .Axes(xlValue).AxisTitle.Orientation = xlHorizontal .Axes(xlValue).AxisTitle.Left = 38 .Axes(xlValue).AxisTitle.Top = 13 .ChartTitle.Characters.Text = "ページフォルト" End With ' ' Page2 ' Charts.Add After:=.Sheets("使用方法") With ActiveChart .ChartType = xlLineMarkers .SetSourceData Source:=Workbooks(ThisWorkbook.Name).Sheets("Data").Range("A1:A" & MaxRow & ",G1:H" & MaxRow & ",L1:M" & MaxRow), PlotBy:=xlColumns .Name = "Page" .Location Where:=xlLocationAsNewSheet .Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale .Axes(xlCategory, xlPrimary).TickLabels.Orientation = 45 .HasTitle = True .HasLegend = True .Legend.Top = 4 .Legend.Left = 465 .Legend.Width = 243 .Legend.Height = 45 .PlotArea.Width = 700 .Axes(xlValue).HasTitle = True .Axes(xlValue).AxisTitle.Characters.Text = "1KBページ数" .Axes(xlValue).AxisTitle.Orientation = xlHorizontal .Axes(xlValue).AxisTitle.Left = 38 .Axes(xlValue).AxisTitle.Top = 13 .ChartTitle.Characters.Text = "スワップ発生" End With ' ' Page1 ' Charts.Add After:=.Sheets("使用方法") With ActiveChart .ChartType = xlLineMarkers .SetSourceData Source:=Workbooks(ThisWorkbook.Name).Sheets("Data").Range("A1:A" & MaxRow & ",I1:K" & MaxRow), PlotBy:=xlColumns .Name = "Page(KB)" .Location Where:=xlLocationAsNewSheet .Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale .Axes(xlCategory, xlPrimary).TickLabels.Orientation = 45 .HasTitle = True .HasLegend = True .Legend.Top = 4 .Legend.Left = 465 .Legend.Width = 243 .Legend.Height = 45 .PlotArea.Width = 700 .Axes(xlValue).HasTitle = True .Axes(xlValue).AxisTitle.Characters.Text = "KByte" .Axes(xlValue).AxisTitle.Orientation = xlHorizontal .Axes(xlValue).AxisTitle.Left = 38 .Axes(xlValue).AxisTitle.Top = 13 .ChartTitle.Characters.Text = "スワップ発生" End With ' ' Memory ' Charts.Add After:=.Sheets("使用方法") With ActiveChart .ChartType = xlLineMarkers .SetSourceData Source:=Workbooks(ThisWorkbook.Name).Sheets("Data").Range("A1:A" & MaxRow & ",E1:F" & MaxRow), PlotBy:=xlColumns .Name = "Mem" .Location Where:=xlLocationAsNewSheet .Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale .Axes(xlCategory, xlPrimary).TickLabels.Orientation = 45 .HasTitle = True .HasLegend = True .Legend.Left = 620 .Legend.Top = 10 .PlotArea.Width = 700 .Axes(xlValue).HasTitle = True .Axes(xlValue).AxisTitle.Characters.Text = "空きメモリ(KB)" .Axes(xlValue).AxisTitle.Orientation = xlHorizontal .Axes(xlValue).AxisTitle.Left = 38 .Axes(xlValue).AxisTitle.Top = 13 .ChartTitle.Characters.Text = "メモリ使用率" End With End With End Sub Private Sub クリア() Call グラフ消去 ' チャートの削除 Workbooks(ThisWorkbook.Name).Sheets("Data").Cells.Clear ' シートデータの削除 End Sub Private Sub グラフ消去() Application.ScreenUpdating = False ' マクロ動作の隠蔽 Application.DisplayAlerts = False ' Delete 時に出るエラーを抑制 For no = Workbooks(ThisWorkbook.Name).Charts.Count To 1 Step -1 Workbooks(ThisWorkbook.Name).Charts(no).Delete ' グラフをすべて削除 Next no Application.DisplayAlerts = True ' エラー抑制を解除 End Sub