Login with Facebook

Friday, April 1, 2011

OMW: List log files to be monitored

 

In an answer to HP support forum about how to list files with certain extention to be used on OMW

We have a sample directory contain may different logs, we need to monitor only files start with cisco

image

Use dir /b /s will list the files only with their full path

image

to optimality integrate this with OMW

Create a log file monitor and under file to be executed type <`cmd.exe /c dir d:\cisco\log\cisco*.log /b /S`>

This will enabled the logfile policy to read all the files and will parse them for the policy rules

This was in respond to Logfile Monitoring with File name changes after server reeboot

OMW: Alert when files are older than 30 minutes Part 1

1- Create the needed script

This script is listing the files that are located in certain directory

cscript /nologo checkolderfiles.vbs abc c:\scripts list

I have added two features for the script

One is to display list the files which are not modified within the time specified

file1.txt
file2.txt
listfiles.vbs


Second is to use opcmon to with a count of files that are not modified before 30 minutes


cscript /nologo checkolderfiles.vbs abc c:\scripts alert

2-prepare the file for distribution


Create a folder name it filesmonitoring under <ovdatadir>\shared\Instrumentation\Categories


image


3-Create Measurement Threshold Monitoring Policy


Create Measurement Threshold Policy name it “monitoroldfiles”


Use Source Type as Program


type in the command area


cscript /nologo checkoldfiles.vbs abc c:\scripts alert

this to run the script to check for the files located in c:\scripts and will generate alert with opcmon policyname=<number of files>


Create a matching rule to send alert if the value is greater than 0 to match the value sent by opcmon  and generate the alert


Add automatic command to this alert to list down which policies are not changed within the time assigned.


The command should be


cscript /nologo checkoldfiles.vbs abc c:\scripts list

4-Deploy the the instrumentation for filemonitoring to the nodes where this policy will be used.


the full script is below and name it checkoldfiles.vbs


nodeName = "."
If Wscript.Arguments.Count <; 3 Then
wscript.echo "Usage cscript checkoldfiles.vbs ""PolicyName"" ""<Files direcotory>"" ""<Alert |List >"" "
wscript.echo "Ex: to send the count to the OM"
wscript.echo "cscript listfiles.vbs abc c:\scripts alert"
wscript.echo "Ex: to list the files"
wscript.echo "cscript listfiles.vbs abc c:\scripts list"
Else
policyname = WScript.Arguments.Item(0)
path= WScript.Arguments.Item(1)
action=WScript.Arguments.Item(2)

myPath = Split(path,":")
drive= myPath(0)
if right(myPath(1),1) <;> "\" then
directory = replace(myPath(1),"\","\\") &; "\\"
else
directory = replace(myPath(1),"\","\\")
end if
Set dateTime = CreateObject("WbemScripting.SWbemDateTime")
dateTime.SetVarDate( DateAdd("n",-5,now()))
Set objWMIService = GetObject("winmgmts:" _
&; "{impersonationLevel=impersonate}!\\" & nodeName & "\root\cimv2")
query = "Select * From CIM_DataFile Where Drive = '"&; drive &":' and Path = '"& directory &"' and LastModified < '" & dateTime.Value &"'"
Set colFiles = _
objWMIService.ExecQuery(query)
if action= "list" then
listfiles()
elseif action="alert" then
alert()
end if
end if
Function listfiles()
For Each objFile in colFiles
strNewFile = objFile.FileName &; "." & objFile.Extension
Wscript.Echo strNewFile
next
End function
function alert()
Set objShell = WScript.CreateObject("WScript.Shell")
command = "cmd /c ""%ovinstalldir%\bin\opcmon.exe"" " &; policyname & "=" & colFiles.Count
Wscript.Echo command
Set oExec = objShell.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


 


Continue on part 2

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

HP Network Node Manager i 9.0 deep dive

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