コンテンツ
Cactiはネットワークやサーバーの状態をグラフ化するソフトウェアです。このソフトをWindowsで動かします。
S.M.A.R.T.とは、Self-Monitoring, Analysis and Reporting Technologyのことです。HDDの故障予測に役立つSMARTをWMIで取得します。
フリーエリア
アクセス数
Wiki内検索
最近更新したページ
最新コメント
FrontPage by ≪潟若
FrontPage by ≪潟若 2014
FrontPage by ASDWE
WindowsでCacti by 井上 馨

SMART情報を取得するWMIスクリプト

MSStorageDriver_FailurePredictDataオブジェクトのVendorSpecificメソッド、MSStorageDriver_FailurePredictThresholdsオブジェクトのVendorSpecificメソッドで取得します。

最終的にCactiのData Queryで使用できるような出力方法になっています。
SMART_index.vbs()

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

Set args = WScript.Arguments
strComputer = args.item(0)
strUser = args.item(1)
strPassword = args.item(2)

command=""
field=""
index=1
selected = -1
Dim array(2)

Set args = Wscript.Arguments
If args.length > 0 Then
command = args(3)
If args(3) = "query" Then
field = args(4)
End If
If args(3) = "get" Then
field = args(4)
selected = args(5)
End If
End If

Dim value(256)
Dim threshold(256)
Dim worst(256)

If strComputer = "localhost" Then
'localhost
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\WMI")
Else
'remote host
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objSWbemLocator.ConnectServer(strComputer, "root\WMI", strUser, strPassword)
End If

Set colItems = objWMIService.ExecQuery("SELECT * FROM MSStorageDriver_FailurePredictData","WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItems in colItems
For i = 2 To UBound(objItems.VendorSpecific) Step 12
value(objItems.VendorSpecific(i)) = objItems.VendorSpecific(i+3)
worst(objItems.VendorSpecific(i)) = objItems.VendorSpecific(i+4)
If objItems.VendorSpecific(i) = 194 Then 'tempreture
value(objItems.VendorSpecific(i)) = objItems.VendorSpecific(i+5)
End If
Next
Next

Set colItems = objWMIService.ExecQuery("SELECT * FROM MSStorageDriver_FailurePredictThresholds","WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItems in colItems
For i = 2 To UBound(objItems.VendorSpecific) Step 12
threshold(objItems.VendorSpecific(i)) = objItems.VendorSpecific(i+1)
If objItems.VendorSpecific(i) = 194 Then 'tempreture
threshold(objItems.VendorSpecific(i)) = objItems.VendorSpecific(i+5)
End If
Next
Next

For i = 1 To UBound(value)
array(0) = index
Select Case field
Case "index" array(1) = index
Case "id" array(1) = i
Case "Caption"
Select Case i
Case "1" array(1) = "Raw Read Error Rate"
Case "2" array(1) = "Throughput Performance"
Case "3" array(1) = "Spin Up Time"
Case "4" array(1) = "Start/Stop Count"
Case "5" array(1) = "Reallocated Sectors Count"
Case "6" array(1) = "Read Channel Margin"
Case "7" array(1) = "Seek Error Rate"
Case "8" array(1) = "Seek Time Performance"
Case "9" array(1) = "Power-On Hours"
Case "10" array(1) = "Spin Retry Count"
Case "11" array(1) = "Calibration Retry Count"
Case "12" array(1) = "Power Cycle Count"
Case "13" array(1) = "Soft Read Error Rate"
Case "190" array(1) = "Temperature(Celsius)"
Case "191" array(1) = "G-Sense Error Rate"
Case "192" array(1) = "Power-Off Retract Count"
Case "193" array(1) = "Load Cycle Count"
Case "194" array(1) = "Temperature(Celsius)"
Case "195" array(1) = "Hardware ECC recovered"
Case "196" array(1) = "Reallocated Event Count"
Case "197" array(1) = "Current Pending Sector Count"
Case "198" array(1) = "Off-Line Scan Uncorrectable Sector Count"
Case "199" array(1) = "UltraDMA CRC Error Count"
Case "200" array(1) = "Write Error Rate (Multi Zone Error Rate)"
Case "201" array(1) = "Soft Read Error Rate"
Case "202" array(1) = "TA Increase Count"
Case "203" array(1) = "Run Out Cancel"
Case "204" array(1) = "Soft ECC Correction"
Case "205" array(1) = "Thermal Asperity Rate"
Case "206" array(1) = "Flying Height"
Case "207" array(1) = "Spin High Current"
Case "208" array(1) = "Spin Buzz"
Case "209" array(1) = "Offline Seek Performance"
Case "210" array(1) = "Vibration During Write"
Case "211" array(1) = "Vibration During Read"
Case "212" array(1) = "Shock During Write"
Case "220" array(1) = "Disk Shift"
Case "221" array(1) = "G-Sense Error Rate"
Case "222" array(1) = "Loaded Hours"
Case "223" array(1) = "Load/Unload Retry Count"
Case "224" array(1) = "Load Friction"
Case "226" array(1) = "Load-in Time"
Case "227" array(1) = "Torque Amplification Count"
Case "228" array(1) = "Power-Off Retract Count"
Case "230" array(1) = "GMR Head Amplitude"
Case "240" array(1) = "Head Flying Hours"
Case "250" array(1) = "Read Error Retry Rate"
Case Else array(1) = "Unknown"
End Select
Case "value" array(1) = value(i)
Case "threshold" array(1) = threshold(i)
Case "worst" array(1) = worst(i)
Case Else array(1) = ""
End Select

If value(i) <> "" and threshold(i) <> "" Then
Select Case command
Case "index" Wscript.StdOut.Writeline array(0)
Case "query" Wscript.StdOut.Writeline array(0) & "!" & array(1)
Case "get" If selected = FormatNumber(index, 0, -1, 0, 0) Then Wscript.StdOut.Write array(1)
End If
End Select
index = index + 1
End If
Next



表記上の問題で画面上のテキストをそのままコピー&ペーストしづらいと思いますので、ファイルを用意しました。
ただし、使用しているシステムの都合上、画像かPDFしかアップロードできないため、プログラムをPDFファイルでおいてあります。
PDFのテキスト部分をテキストエディタなどにコピーしてからお使いください。
2007年12月13日(木) 16:04:28 Modified by slt33333

添付ファイル一覧(全1件)
6c9c5d84.pdf (29.31KB)
Uploaded by slt33333 2007年12月13日(木) 15:59:09



スマートフォン版で見る