Friday, May 6, 2011
Wednesday, April 20, 2011
OMW: Script to Change Agent from DCE to HTTPs Part2
Many administrators looking to automate the time consuming process, I had seen requests in HP support forums on how to change agent in bulk
I have created the below script which utilizes Policy Management and Deployment (PMAD) API which mainly starts by
set pmad = CreateObject("PMAD.OvPmdPolicyManager")
pmad.ConnectDB
We can compare the above lines by opening the Node Editor
Set node = PMAD.CreateNode(nodeGuid)The line above is locating or creating a node typically like Selecting the node you will modify the agent attributes.
createnode = node.ChangeAgent(liAgentCommType,wminode.AgentBinaryFormatId,256, "", "")
The lines above is like right click the node and select Change Agent which is executed by ChangeAgent() function which should be formatted like ChangeAgent(lAgtType,lBinaryFormat,ulOptions,sUser,sPwd)
lAgtType
- Defines the communication type of the HP Operations agent (DCE or HTTPS) that should run on the node.
lBinaryFormat
- Defines the binary format of the HP Operations agent that should run on the node.
ulOptions
- Defines the type of authentication that will be used for the operation
- PMAD_DEPL_NONE_OPT - This flag cannot be combined with any other flags. Use this flag when you do not want to pass any other flags.
- PMAD_DEPL_IGNORE_OWNER_OPT - If this flag is NOT SET, the operation fails if some policies are owned by another management server. If this flag if SET, the owner attribute of the policies is ignored.
- PMAD_DEPL_FORCE_OPT - If this flag is NOT SET, the operation fails whenever there are policies in the inventory on the server for which no data is available. However, if this flag is SET, policies with no data are ignored (that is, not deployed again).
- PMAD_DEPL_IMPERSONATE_OPT - If SET, the remote managed node is accessed with the security context of the impersonated user (the user that called this API).
- PMAD_DEPL_PMADUSER_OPT - If SET, the remote managed node is accessed with the security context of the HP-OVE-Deleg-User account (the one under which PMAD is running).
Which I chose PMAD_DEPL_IMPERSONATE_OPT which uses the current user this options has a hex value 0x100 and the ulOptions means unsigned long which means a non negative decimal value which means here 256
sUser
- Name of the account used to access the remote node. You can specify the account either as a user principal name (UPN such as UserName@DomainName) or in the down-level log-on name format (DomainName\UserName).
sPwd
- Password of the account used to access the remote node.
The Full script
Dim nodeName
Dim agent
Dim argsObj
Set argsObj=WScript.Arguments
If argsObj.Count=2 Then
nodeName = argsObj(0)
newAgentType = argsObj(1)
Else
WScript.echo "usage: cscript.exe ovchgagent.vbs <nodeName> <agenttype>"
WScript.Quit (1)
End If
Dim objLocator
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Dim objNode
Set objNode = objLocator.ConnectServer("", "root\HewlettPackard\OpenView\data", "", "")
objNode.Security_.impersonationlevel = 3
Dim msgquery
msgquery = "Select * from ov_managednode where primarynodename = """ & nodeName & """"
Dim objNodeList
Set objNodeList = objNode.ExecQuery(msgquery)
Dim nodeGuid
Dim wminode
For Each wminode In objNodeList
nodeGuid = wminode.Name
wscript.echo nodeguid
Next
Set wminode = Nothing
Set objNodeList = Nothing
Set objNode = Nothing
Set objLocator = Nothing
Dim pmad
set pmad = CreateObject("PMAD.OvPmdPolicyManager")
pmad.ConnectDB
If pmad.DBConnected And nodeGuid <> "" Then
Select Case newAgentType
Case "n/a":
liAgentCommType = 0
Case "DCE":
liAgentCommType = 1
Case "HTTPS":
liAgentCommType = 2
End Select
Dim node
Set node = PMAD.CreateNode(nodeGuid)
createnode = node.ChangeAgent(liAgentCommType,wminode.AgentBinaryFormatId,256, "", "")
Set node = Nothing
Else
wscript.echo "node not found or invalid, or cannot connect to database!"
End If
Set pmad = Nothing
Tuesday, April 19, 2011
OMW: Script to Change Agent from DCE to HTTPs Part1
HP Operations manager prior to version 8, managed node are monitored through Agent uses RPC/DCE communication, which had lots of issues as it is unsecured communication and communication configuration headache for the Agent and Server through firewall
In HP Operations Manager 8 and later a new Agent is introduced called HTTP agent which uses encrypted HTTPs certificate-based communication to secure the data and uses only single port for the communication between OM and Agents ( TCP 383 by default)
So organizations with DCE Agents should be change the agent to HTTPS based to leverage the new features. the process is quite simple as the Administrator should access the Node Editor and Change the agent
To change the agent type
Open Node Editor by Right click Server Node > Configure > Node
Select Node and right click select Change Agent
This process will performs deployment operation as the following steps:
- Removes all packages and policies that are currently installed on the node.
- Deletes the server inventory for packages for the specified node, but keeps the server inventory for policies.
- Changes the agent type, binary format, or both of the node in WMI.
- Deploys the new binary of the HP Operation agent to the node.
- Redeploys all policies that were previously installed on the node (they are still in the server inventory) to the node. The additional agent packages and the instrumentation that is required by these policies are automatically deployed first.
Wednesday, April 6, 2011
All Apple Firmware (iPod, iPhone and iPad Firmware Download)
http://www.techstuffs.net/p/all-apple-firmwares-ipod-iphone-and.html
Apple Firmwares:
Note 1: When you download the required firmware below, you can shift-click (on PC) or option-click (on Mac) the Restore or Update Buttons in iTunes.
Note 2: Your browser may change the ipsw-file into a zip-file. In that case, just rename it to end in .ipsw and iTunes will accept it.
Tuesday, April 5, 2011
Monday, April 4, 2011
OMW:Read Multi-lined log files
I had seen so many questions about joining multiline log as in OMW the Log Interceptor is parsing line by line, so if your data is scattered on different lines it can not be monitoring unless you imply a pre-processing script.
I have created the below script is to join multiple lines together but if match a certain keyword
If Wscript.Arguments.Count < 2 Then
wscript.echo "Usage cscript joinlines.vbs ""logfilepath"" ""machingtext"" "
wscript.echo "Ex:"
wscript.echo "cscript joinlines.vbs ""d:\logs\filename.log"" logfilename "
Else
Set args = WScript.Arguments
arg1 = WScript.Arguments.Item(0)
match = WScript.Arguments.Item(1)
Set fsObject = CreateObject("Scripting.FileSystemObject")
nodesFile = arg1
Set file = fsObject.GetFile(nodesFile)
Set line = file.OpenAsTextStream(1,TristateUseDefault)
dim arrFileLines()
Do Until line.AtEndOfStream
Redim Preserve arrFileLines(l)
arrFileLines(l) = line.ReadLine
l = l + 1
Loop
For l = Ubound(arrFileLines) to LBound(arrFileLines) Step -1
If Instr(arrFileLines(l), match) > 0 then
wscript.echo "maching line " & arrFileLines(l-1) &" " & arrFileLines(l)
end if
Next
End if
Save the contents to joinlines.vbs
It can be implemented in different ways:
You can create a log file policy to search for your error message in each line as the sample below
20110326 08:00:13 expdp_SHARED_DATASTAGE.sql started ok
20110326 08:14:13 expdp_SHARED_DATASTAGE.sql completed ok with this output:
The job "EXPDP_USER". "SYS_EXPORT_SCHEMA_06" failed at 08:15:00: ERROR
20110327 08:00:13 expdp_SHARED_DATASTAGE2.sql started ok
20110327 08:14:13 expdp_SHARED_DATASTAGE2.sql completed ok with this output:
The job "EXPDP_USER2". "SYS_EXPORT_SCHEMA_02" failed at 08:15:00: ERROR
20110328 08:00:13 expdp_SHARED_DATASTAGE3.sql started ok
20110328 08:14:13 expdp_SHARED_DATASTAGE3.sql completed ok with this output:
The job "EXPDP_USER2". "SYS_EXPORT_SCHEMA_03" failed at 08:15:00: ERROR
1- You may create your rule to search for the word error and to send message and we can use the script as automatic action to get the previous lines and to append it to the annotation
Sample screenshots
2-You can create the policy to pre-process the log and write the output to a text file to be read.
cscript /nologo log.vbs backup.log ERROR >c:\windows\temp\joinedlines.txt
Ref: http://forums13.itrc.hp.com/service/forums/questionanswer.do?threadId=1474985
Saturday, April 2, 2011
OMW: Log file monitor for multiple log files
To monitor multiple files using a OMW log file monitor policy, you have to configure the policy to list those files separated by spaces.
Normally in Unix-based systems if you used ls command with wildcards, the result will be the full files path and separated by spaces
In Windows, dir is not delivering the same result as
if you try dir /b /s it will show each file in separate line
if you used /w command it display the files without path, so I created the below script to list the files with /w and add the path to the output
If Wscript.Arguments.Count < 2 Then
wscript.echo "Usage cscript listlogs.vbs ""directry"" filename "
wscript.echo "Ex:"
wscript.echo "cscript listlogs.vbs ""d:\logs\"" logfilename "
Else
directory = WScript.Arguments.Item(0)
fileName= WScript.Arguments.Item(1)
Set objShell = WScript.CreateObject("WScript.Shell")
command = "cmd /c dir /l /w " & directory & "*" &filename & "*.log"
Set oExec = objShell.Exec(Command)
Do While Not oExec.StdOut.AtEndOfStream
commandoutput = oExec.StdOut.ReadLine()
If Instr(commandoutput, ".log") > 0 then
replaced = replace(commandOutput,filename, directory & filename)
wscript.echo replaced
End if
Loop
End if
The next step is to deploy this script to your Managed Nodes, we may create new Instrumentation by creating a new folder under %ovdatadir%\shared\Instrumentation\Categories , lets name it LogFileMonitor
Browse to the Policy Group or to Policy Management –> Policies grouped by type-> Agent Policies –> Logfile Entry
In the Log file path type <`c:\windows\system32\cscript.exe /nolog listlog.vbs c:\Cisco\log\ cisco`> but during the test it work with me as <`c:\windows\system32\cscript.exe /nologo "%ovdatadir%"\bin\instrumentation\listlogs.vbs c:\Cisco\log\ cisco`>
Save the policy, you may use Category option to automatically deploy the instrumentation with the policy (requires certain configuration)
Distribute the instrumentation,then deploy the policy to your managed nodes.
This was in response of HP Support forum question on ITRC Logfile Monitoring with File name changes after server reeboot