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}

Monday, March 28, 2011

OMW: List files on folder that didn’t modified within 30 minutes Part 2

 

nodeName = "."
Set dateTime = CreateObject("WbemScripting.SWbemDateTime")
dateTime.SetVarDate( DateAdd("n",-30,now()))
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & nodeName & "\root\cimv2")
Set colFiles = _
objWMIService.ExecQuery("Select * From CIM_DataFile Where Drive = 'C:' and Path = '\\Scripts\\' ")
'Wscript.Echo colFiles.Count 'echo number of files
For Each objFile in colFiles
IF objFile.LastModified < dateTime.Value Then
strNewFile = objFile.FileName & "." & objFile.Extension & " File last modified : " & objFile.LastModified
Wscript.Echo strNewFile
END IF
next


This script is for displaying files that are last modified date is older than 30 minutes


Here is the script breakdown with explanation


I tried to get the current time using Now() function then I deducted the time by using DateAdd() and used a native value


I called the files using WMI class  CIM_DataFile and I defined the file location through Where clause to filter the files that are located in drive C: and located under folder named \Scripts


objWMIService.ExecQuery("Select * From CIM_DataFile Where Drive = 'C:' and Path = '\\Scripts\\' ")


The problem that the time stored in WMI object is different that the time value used in VB script function like now() like the below


VB Time is 03/28/2011 9:42:03 PM


WMI Time is 20110328214201.225172+240


I have used WbemScripting.SWbemDateTime class to convert the date to WMI date


Set dateTime = CreateObject("WbemScripting.SWbemDateTime")

Then I converted the value received using a function named SetVarDate()


dateTime.SetVarDate( DateAdd("n",-30,now()))


I tried to compare it within the WMI query and failed so I compare it using if statement


If objFile.LastModified < dateTime.Value then
Wscript.Echo strNewFile

Saturday, March 26, 2011

NNMi: How to find Management Incidents that considered Key Incidents

 

I have analyzed the NNMi database, and found the below

The Key incidents are defined by the Incident Nature which can be found on the NNMi table NNM_INCIDENTS and the Incident name is stored under column "Name" and the correlation nature is stored under column "NATURE"

So after more analysis I found the below  table for mapping the value in nature column and map it to the correlation nature names used in the Incident Management views

image

so for Key correlation ( Root Cause, Service Impact, Stream Correlation,None, Info and  Rate Stream Correlation)

Value  Name

0    Root Cause
1    Secondary Root Cause
2    Symptom
3    Service Impact
4    Stream Correlation
5    None
6    Info

7    Dedup Stream Correlation
8    Rate Stream Correlation

I was able to get Incident Names them by the below Oracle SQL statement

   1: SELECT  "NNMI"."NMS_INCIDENTS"."NAME" as "NAME",COUNT(*)
   2:     FROM "NNMI"."NMS_INCIDENTS" 
   3:     WHERE ( ( "NATURE" = '0' ) OR ( "NATURE" BETWEEN '3' 
   4:     AND '6' ) OR ( "NATURE" = '8' ) ) group by Name

The result was the list below, but this may be expanded if you have more incidents from the system.

Note: This may be  the answer of your question

NnmHealthOverallStatus
SNMPAgentNotResponding
NodeDown
RateCorrelation
InterfaceDown
NodeOrConnectionDown
NonSNMPNodeUnresponsive
LicenseExpired
ConnectionDown
AggregatorLinkDegraded
LicenseNodeCountExceeded
AddressNotResponding
AggregatorDown









This was answer to question in HP Forum “NNMi List of Key Incidents”


http://h30501.www3.hp.com/t5/Network-Management-Support-Forum/NNMi-List-of-Key-Incidents/td-p/24529

Friday, March 25, 2011

Check the status of OMW nodes part1

I have create the below script to run opcragt command and check for the failure values and display the matching lines to the screen and this can be later used to write it in a log file for policy monitoring.

 

   1: If Wscript.Arguments.Count < 1 Then
   2:     wscript.echo "Usage cscript checkstatus.vbs ""nodename"" "
   3:     wscript.echo "Ex:"
   4: Else
   5:     Set args = WScript.Arguments
   6:     nodename = WScript.Arguments.Item(0)
   7:     call checkNode()
   8: end if
   9:  
  10: Function checkNode()
  11: Command = """C:\Program Files\HP\HP BTO Software\bin\win64\opcragt.cmd"" -status " & nodename
  12: Set WshShell = CreateObject("WScript.Shell")
  13: Set oExec = WshShell.Exec(Command)
  14: Do While Not oExec.StdOut.AtEndOfStream
  15:     commandoutput = oExec.StdOut.ReadLine()
  16:     subAgentError = instr(commandoutput, "isn't running") 
  17:     connectionFailed = instr(commandoutput, "failed") 
  18:     subAgentAborted= instr(commandoutput, "Aborted") 
  19:     if subAgentError > 0 Or connectionFailed >0 or subAgentAborted > 0 then
  20:         Wscript.Echo nodename & " : " & commandoutput 
  21:     end if 
  22: Loop

for two errors only (added the 3rd on 26 March)


1- When we run opcragt on a node that is on of the sub agents are failed the following error is displayed:


image


In line 16 I’d used instr() to filter and capture the error message


subAgentError = instr(commandoutput, "isn't running")

 

2- When we run opcragt on a node that is not accessible the following error is displayed


image


So I used the instr()  in line 17 to locate to filter the line for the error message


connectionFailed = instr(commandoutput, "failed")


 


3- When we run opcragt (opcagt) on a node that has a aborted subagent the following error is displayed

In line 18 I’d used instr() to filter and capture the error message

C:\WINDOWS\system32>opcagt
opcacta OVO Action Agent AGENT,EA (2064) Running
opcmsga OVO Message Agent AGENT,EA (4104) Running
opcmsgi OVO Message Interceptor AGENT,EA (3148) Running
opctrapi OVO SNMP Trap Interceptor AGENT,EA Aborted

 

Then I displayed the with filtered data contains the node name:


dc-dxb-01 : (xpl-316) connect() to '10.200.92.1:383' failed.
omw-dxb-01 : Action Agent opcacta isn't running
omw-dxb-01 : opctrapi OVO SNMP Trap Interceptor AGENT,EA Aborted


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.


Monday, March 21, 2011

Using VMware vSphere Client to connect to VMware Server

In Jan 2009 I created an article on How to use the Virtual Infrastructure Client to connect to VMware Server 2.0

Today, I hade another challenge where I want to use the latest client tool which is VMware vSphere Client to connect to an VMware Server it will give you the error below

image

image

image

 

"The required client support files cannot be retrieved from the server"
"The login process will now exit"
"Details: The server could not interpret the client's request. (404 not found)"


Solution was found in this link http://www.linux.com/community/blogs/accessing-vmware-server-2-with-vsphere-client-the-unsupported-way.html and simply download a rar file Here's a link expand the contents in the “Virtual Infrastructure Client” folder in Program files folder and rerun the tool it will work perfectly.


Note: This is not supported by VMware.

OMW:Enable Automatic Instrumentation Deployment

 

In the same namespace where you enabled Policy Deployment allows you to control the Auto deployment of the instrumentation, this can be allowed thought

In the console tree, right-click Operations Manager
Configure –> Server

image
Select "Policy Management and Deployment"
Select "Enable Automatic Instrumentation Deployment" change the Value to True.

 

image

Whenever Deploy a policy, the system will check for a Property called Category assigned to the policy and it will try to find that category under %ovdatadir%\shared\Instrumentation\Categories  on the management server and deploy the related tools to that node.

Sample:

Database SPI policies has the category Database_Monitoring you can easily locate the attribute in the list view of the policies under the Policy Management Node in OMW Console or the Properties page of the policy

 

image

image

Once this policy is deploy the folder contents %ovdatadir%\shared\Instrumentation\Categories\Database_Discovery will be deployed to the node (you may have sub-folders if you want different files to be deployed based on the Operating System Types / Versions / OSbits)

image

This article is created in response to ITRC Question below

http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1473794

Wednesday, March 16, 2011

Script for creating nodes in OMW

Copy and paste the script below as createNodes.vbs
If Wscript.Arguments.Count < 1 Then
'Check that you spacified the nodes filename
wscript.echo "Usage cscript createNodes.vbs ""filename"" "
wscript.echo "Ex:"
wscript.echo "cscript createNodes.vbs ""c:\nodelist.txt"""
Else
Set args = WScript.Arguments
arg1 = WScript.Arguments.Item(0)

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 & " -ostype ""AIX"" -osversion ""5L 5.3"" -systemtype ""Power PC Family"" -osbits ""32"" -agent_bin_format ""PowerPC"" "
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec(Command)
Wscript.Echo "The output of the command: " & Command
Do While Not oExec.StdOut.AtEndOfStream
commandoutput = oExec.StdOut.ReadLine()
Wscript.Echo commandOutput
Loop
End Function


Create a text file for example nodes.txt


node1.mahmoudthoughts.com
node2.mahmoudthoughts.com
node3.mahmoudthoughts.com

 

To ensure the script will work in your OMW version, change the path for ovownodeutil.cmd  located on line 22


The sample script is for creating AIX nodes only


To create any nodes open the Node Properties for a node with the same version and get the values located in the system tab and modify line 22 as per the red marks.


image_thumb2


Run

cscript createNodes.vbs nodes.txt

Friday, March 4, 2011

Monitor Unix processes in HP OM

Monitor the processes by several ways.

1-Log File Monitor
Configure the policy with pre-processing enabled to execute your script that direct the output to a text file and based on pattern matching rules, fetch the number of the processes.

2-Threshold Monitoring Policy
Where you have to create Measurement Threshold monitoring to launch a script and send the number of process instances along with opcmona.

3-Use the OSSPI built-in monitoring script to reach your goal as stated in your original question.

1- Monitor process using log file policy

Create Log file monitor policy
Leave log file location as empty
Enabled pre-processing option and for the field of command to be executed put your script
ps -ef | grep processname | grep -v grep | wc -l > /tmp/processname
Type the /temp/processname on the file to be read field
Note: replace the "processname" with the process you are looking for.
Create rule to look for value 0 to send you alert and for <!0> to send you the process is working

2- Monitor process using Measurement Threshold policy


Create a Measurement Threshold policy and name it with the process name
Select program as source and type
"processmonitor.sh policyname processname"
Note: replace the policyname and process name to match the exact policy name and process name.

Create minimum rule if processes are less than 1 then alert to be generated to as process is down

 

Create the following script and distribute it to the nodes (best option to distribute it as instrumentation)

---------processmonitor.sh--------
opcmon=$OVINSTALLDIR/bin/opcmon
policy=$1
process=$2
count=$(ps -ef | grep $process | grep -v grep | wc -l)
$opcmon $policy=$count
----------------------------------

3- Monitor Process using OSSPI.

Ref: Unix OS SPI Admin Guide http://support.openview.hp.com/selfsolve/document/KM14827/binary/UNIXOS-SPI_a35_AdminRef_pdf Page 86

The answer to your original question:
In OSSPI process monitor there is two files used for this:
1st one is created automatically called procmon.cfg and is created by "OSSPI-AutoDiscovery" policy and it is called discovery application
You can modify this file to add more processes but I am not sure if it will be overwritten by the re-discovery
2nd file is called procmon_local.cfg this can be manually created and it will not be overwritten by re-discovery, that's why you see everybody using it.

The file syntax is typical to procmon.cfg; also check the admin guide for more details.
[Process]
/path/to/process *

Also you can add processes by tools available in the OSSPI Process Monitoring application group to edit the process monitor configuration file.


After you add your processes
You can create a copy of any OSSPI process monitor template like "OSSPI-cronproc" and give it a new name and ensure that the program name in this policy to replace policy name and process name to match your own "osspi_perl.sh osspi_procmon.pl OSSPI-cronproc cron" with "osspi_perl.sh osspi_procmon.pl PolicyName Processname"

Thursday, March 3, 2011

Check OM Oracle DB Status

 

To check the database:
#su - oracle
Verify that ORACLE_HOME and ORACLE_SID are set correctly.

Check status by command tnsping:
$
tnsping ov_net

Check status by SQL query:

$ORACLE_HOME/bin/sqlplus /nolog
SQL> connect / as sysdba
SQL>

   1: set lines110
   2: col strtd hea 'STARTED'
   3: col instance_name for a8 hea 'INSTANCE'
   4: col host_name for a15 hea 'HOSTNAME'
   5: col version for a10
   6: select instance_name, version, host_name, status
   7: , database_status, to_char(startup_time,'DD-MON-YYYY HH:MI:SS') strtd
   8: from v$instance;

SQL> exit

Start the database:


$ORACLE_HOME/bin/sqlplus /nolog
SQL> connect / as sysdba
SQL> STARTUP MOUNT
SQL> exit

Usually default database setting is as below:
ORACLE_SID is [openview]
Password of Oracle user 'system' is [manager]
Oracle Service name is [ov_net]


Screenshot-1

OMU - Linux-2011-03-03-03-02-37

http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1471367