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:
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
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 messageC:\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
No comments:
Post a Comment