Tuesday, March 29, 2011

Script for creating NNMi Nodes in OMW

Create a New Node Group

Right Click the Server –> Configure –> Nodes

Create Node Group

After Creation check for the node group id defined under Unique ID by check the properties page

image

 

image

 

If Wscript.Arguments.Count < 7 Then
'Check that you spacified the nodes filename
wscript.echo "Usage cscript createNodes.vbs ""filename"" osType osVersion sysemType osBits agentBinFormat groupID"
wscript.echo "Ex for Adding SNMP hosts: "
wscript.echo "cscript creatennmnodes.vbs nnmnodes.txt SNMP V1 Other 32 n/a {9F30A9B2-0833-4341-A146-27E01DA4AADD}"

Else
Set args = WScript.Arguments
arg1 = WScript.Arguments.Item(0)
osType = WScript.Arguments.Item(1)
osVersion = WScript.Arguments.Item(2)
sysemType = WScript.Arguments.Item(3)
osBits = WScript.Arguments.Item(4)
agentBinFormat = WScript.Arguments.Item(5)
groupid = WScript.Arguments.Item(6)

Set CSVoFS = CreateObject("Scripting.FileSystemObject")
nodesFile = arg1
Set file = CSVoFS.GetFile(nodesFile)
Set line = file.OpenAsTextStream(1,TristateUseDefault)
Do While line.AtEndOfStream <> True
myLine = Split(line.ReadLine,",")
nodeName = "" & myLine(0) & ""
call createNode()
Loop

End if

Function createNode()
Command = """D:\Program Files\HP\HP BTO Software\bin\ovownodeutil.cmd"" -add_nodewithtype -node_name " & nodeName & " -caption "& nodeName & " -ostype " & osType & " -osversion "& osVersion & " -systemtype "& sysemType & " -osbits " & osBits & " -agent_bin_format " & agentBinFormat & " -group_id " & groupID
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec(Command)
'Do While Not oExec.StdOut.AtEndOfStream
'commandoutput = oExec.StdOut.ReadLine()
'Wscript.Echo commandOutput
Loop
End Function



Create a text file contain all you NNMi nodes name it nnmnodes.txt


Run the below command


cscript creatennmnodes.vbs nnmnodes.txt  SNMP  V1 Other 32 n/a  {9F30A9B2-0833-4341-A146-27E01DA4AADD}