beautypg.com

Other examples, Scripting references, Other examples scripting references – HP Integrity rx3600 Server User Manual

Page 19

background image

Example 7 Clearing the record log

strComputer = "."
strNamespace = "\root\hpq"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & strNamespace)

Set colCommonRecordLog = objWMIService.ExecQuery("Select * from
HPQ_CommonRecordLog")

Wscript.Echo “Clearing the record log…”

For Each objCommonRecordLog in colCommonRecordLog
objCommonRecordLog.ClearLog()
Next

Example 8 Receiving an alert indication

strComputer = "."
strNamespace = "\root\hpq"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & strNamespace)

Set objIndication = objWMIService.ExecNotificationQuery("SELECT * FROM
HP_AlertIndication")

Wscript.Echo "Waiting for alert indication..."

Set objReceivedIndication = objIndication.NextEvent

WScript.Echo "Provider Name = " & objReceivedIndication.ProviderName
WScript.Echo "Event ID = " & objReceivedIndication.EventID
WScript.Echo "Severity = " & objReceivedIndication.PerceivedSeverity
WScript.Echo "Description = " & objReceivedIndication.Description

Other examples

You can also write scripts to obtain data from the Insight Providers using Microsoft Windows
Management Instrumentation Command-line (WMIC) and Microsoft Windows PowerShell.

The following command is used to display computer system status information using WMIC in
noninteractive mode:

wmic /namespace:\\root\hpq path hp_wincomputersystem get caption,OperationalStatus,StatusDescriptions

The following Windows PowerShell script code can be used to list fans in the system:

$strComputer = "."
$strNamespace = "root\hpq"

$colFan = Get-WMIObject -class "hp_winfan" -namespace $strNamespace -
computername $strComputer

foreach ($objFan in $colFan) {
write-host $objFan.Name, $objFan.Description
}

Scripting references

For more information regarding WMI scripting, see the following WMI references on the MSDN
website:

Scripting Access to WMI (

http://msdn2.microsoft.com/en-us/library/aa393256.aspx

)

Visual Basic Scripting Edition (

http://msdn2.microsoft.com/en-us/library/t0aew7h6.aspx

)

Other examples

19