Login with Facebook

Thursday, March 24, 2011

OMW: Modify the Heartbeat settings for Managed Node

Recently I decided to post my replies in HP Support Forum here in my blog to enrich the internet with the direct answer to the question I may also attach some screenshots..

The question was about changing Hearbeat settings for OMW Nodes..

The settings are actually located under system tab in the node properties page

I will use WMI to handle this case

So node information is located in the instances of WMI Class named ov_managednode this class contain all the node related attributes plus more methods to execute different functions

This WMI class is located under WMI namespace “root\HewlettPackard\OpenView\data”

dealing with WMI in VB scripting is quite straightforward, although the scripts may look different

The code below is simple to connect to WMI on the local machine and direct the code to the namespace mentioned above

Set objLocator = CreateObject("WbemScripting.SWbemLocator") 
Set objNode = objLocator.ConnectServer("", "root\HewlettPackard\OpenView\data", "", "")
objNode.Security_.impersonationlevel = 3


The next section is to find the node where we want to modify in list of Instance of the ov_managedNode class so as long as we may use the full node name there is attribute contain this data called primarynodename so we will use a WQL to locate node(s) matches our select criteria and we will execute the query by objNode.ExecQuery() function

msgQuery = "Select * from ov_managednode where primarynodename = """ & nodeName & """" 
objNodeList = objNode.ExecQuery(msgQuery)

but in the query about you may notice nodeName which is a variable  where you my add it as argument while executing the script where we defined the nodeName as the 1st argument identified as Item(0)

argsObj = WScript.Arguments 
nodeName = argsObj.Item(0)


And finally to change the value of any attribute  you need to locate the attribute name and its possible values and use .put to write your changes.

So in the example below the attribute is HeartBeatMode  and the values are from 0 to 4 where each number mean certain item in the drop list in the heartbeat settings like the below.

“0 = HeartBeatDisabled "
"1 = AgentPollingOnly "
"2 = ICMPPollingOnly "
"3 = HeartBeatEnabled "
"4 = UseSystemDefault "
Also I decided to give the user the ability to tyoe the number in the command line as a second argument that’s why I defined --- heartbeat = WScript.Arguments.Item(1) --- 

wmiNode.HeartBeatMode = heartbeat
----the full script----

Dim argsObj
Set argsObj=WScript.Arguments

If argsObj.Count<2 Then
WScript.echo "Usage: cscript.exe disableheartbeat.vbs <nodename> <heartbeat>"
WScript.echo "<heartbeat> value as below"
WScript.echo "0 = HeartBeatDisabled "
WScript.echo "1 = AgentPollingOnly "
WScript.echo "2 = ICMPPollingOnly "
WScript.echo "3 = HeartBeatEnabled "
WScript.echo "4 = UseSystemDefault "

WScript.Quit (1)
End If

nodeName = WScript.Arguments.Item(0)
heartbeat = WScript.Arguments.Item(1)
Dim objLocator
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Dim objNode
Set objNode = objLocator.ConnectServer("", "root\HewlettPackard\OpenView\data", "", "")
objNode.Security_.impersonationlevel = 3
'//get the node from WMI
Dim msgQuery
msgQuery = "Select * from ov_managednode where primarynodename = """ & nodeName & """"
Dim objNodeList
Set objNodeList = objNode.ExecQuery(msgQuery)

'//get the GUID of the managed node object
Dim nodeGuid
Dim wmiNode
For Each wmiNode In objNodeList
nodeGuid = wmiNode.Name
wmiNode.HeartBeatMode = heartbeat

After saving the script in .vbs file you may name it disableheartbeat.vbs

Type the following command on your OMW server where you saved the .vbs file
cscript.exe disableheartbeat.vbs <nodename> <heartbeatnumber>

heartbeatnumber as below
0 = HeartBeatDisabled
1 = AgentPollingOnly
2 = ICMPPollingOnly
3 = HeartBeatEnabled
4 = UseSystemDefault

This was a quick overview on the script details, so please accept any typos, grammar mistakes , or unclear information and feel free to use the facebook comments plugin to have a better communication…
Waiting for your feedback.

No comments:

Post a Comment