Tuesday, March 27, 2007

Using PowerShell with HP OpenView Operations Windows agents

I've been wanting to try using PowerShell to do advanced system monitoring, but only got around to it this week.

One of the first things to do was to test how PowerShell could interface with the HP OVO Windows agent.

I found out recently that version 7.20 or newer of the Windows based agents had a automation library included, aka COM interface (I hope I'm using the terms properly).

I first tried to load the automation library straight from PowerShell, but that failed:

PSH> $ovo=new-object -com ovoautomation.opcmsg
PSH> $ovo|gm
   TypeName: System.__ComObject#{bb03cab1-2606-4388-bbbc-2b5af2321464}
Name         MemberType Definition
----         ---------- ----------
Send         Method     void Send ()
Application  Property    {get} {set}
MessageGroup Property    {get} {set}
MessageId    Property   string MessageId () {get}
MessageText  Property    {get} {set}
NodeName     Property    {get} {set}
Object       Property    {get} {set}
OptVar       Property    {get} {set}
ServiceName  Property    {get} {set}
Severity     Property    {get} {set}

PSH> $ovo.messagetext="testing"
Exception setting "MessageText": "Type mismatch. (Exception from HRESULT:
0x80020005 (DISP_E_TYPEMISMATCH))"
At line:1 char:6
+ $ovo.m <<<< essagetext="testing"

[end display of PSH code]

You'll note that 'Definition' section doesn't look very complete if compared to the IE COM object.  I don't know if that makes a difference.

OK, so that doesn't work...

I went to the HP ITRC forums and asked whether anyone had tried using the OVO agents with PowerShell.  Drew Dimmick replied that he was getting the same error, but also pointed out a link to www.ovinternals.com (free account required to download), where there was a managed code assembly available that exposes the OVO agent API.  I retrieved the OVAgent.zip file and tried it out...  It worked perfectly:

PSH>$ovo=new-object ovinternals.ovagent.submitmessage

[end of display of PSH code]

I only tried the messaging inteface, but it also appears you have an API for CODA performance logging, as well as an API for the monitoring agent (opcmona).