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).

Friday, March 23, 2007

BlackBerry Enterprise Server SNMP agent extension

I was working on a trouble with doing some SNMP monitoring of a BlackBerry Entrprise Server 4.x.  I noticed I could not do any typical commands like get or walk on a particular server.  I read and re-read the vendor documentation, and still could not get BES SNMP to work, while it was working fine on another BES server we had.

Turned out that the server that didn't work had a BlackBerryServerSNMPAgent.dll version of 4.x, while the DLL that did work on another server was 2.x.  I copied the 2.x DLL over to the new server, restarted SNMP, and all is well.

So either the MIB variables are different, or there's something wrong with the 4.x DLL.  Perhaps the 4.x DLL has more 'monitoring points' or other added features, but what I found in the 2.x version met all my requirements.

(I intend on tying this into PowerShell for some advanced monitoring of BES.  It appears the only way to do monitoring of the client license usage might be via SNMP.)

(Also just blogging this to post this somewhere on the web.)

Monday, March 12, 2007

New NetCmdlets beta

I've previously blogged about NetCmdlets before.  They have just released beta 3 of their PowerShell extensions.

Definitely something worth trying out for rich networking-based cmdlets extensions.

Saturday, March 10, 2007

Cool application: PowerGUI (www.powergui.org)

There's a new project out there still in a 'closed' beta.  It is closed, but you can go to www.powergui.org and request an account.

From the FAQ: "PowerGUI is an extensible graphical administrative console for managing systems based on Windows PowerShell. These include Windows OS (XP, 2003, Vista), Exchange 2007, Operations Manager 2007 and other new systems from Microsoft. The tool allows to use the rich capabilities of Windows PowerShell in a familiar and intuitive GUI console."

This is a pretty good idea on using a graphical method to represent objects from cmdlets.

You can find a Exchange 2007, and I think it is pretty powerfull as far as viewing and actually being able to make modifications.

I might blog about this a bit more this week if I find the time.

Wednesday, March 7, 2007

Comments feed in Community Server

With some help from Lance, I'm posting an entry on how to get access to an RSS feed of comments from the great online forum product Community Server.  Apparently, their newer version (currently in beta) makes this available via a viewable RSS feed link.

Very simple script/example below.  It will print out the blog post titles, then the next line will be the RSS feed address to the comments.

PowerShell script:

$wc = new-Object System.Net.WebClient
[xml]$nl = $wc.DownloadString($url)

[end script]

Thursday, March 1, 2007

Another PowerGadgets example

I've blogged a few times before about the 2007 Microsoft Scripting Games.  There was 4 categories this year, and I originally thought I was going to map all the data like I previously did.  Instead, I though I'd do something different: represent the number of participants per country per category in a line graph using PowerGadgets.

Here's the finished product: all countries (with more than 5 total entrants).


psaentries: PowerShell advanced, psbentries: PowerShell beginner, vbaentries: VBScript advanced,  and vbbentries: VBScript beginner.  total is just the sum of the former 4 values.

Here's an example of the 'mouse-over' features.  What I did here, was put my mouse over  psaentries in the legend box: PowerShell advanced entries.

Here's another advanced feature where I add a "data grid", so I can view all the data in a table format just below the graph:data grid option.

And finally, one more advanced feature where I do a mouse-over of a particular data point, and I get: a popup tooltip.

To keep the graph "less busy", I've only added countries who had a total number of participants of 5 or more.

All the entries for each category are here: VBScript beginner, VBScript advanced, PowerShell beginner, and PowerShell advanced.

Inspired by /\/\o\/\/, here's the script I used:





foreach ($category in $categories){
$wc = new-Object System.Net.WebClient
$nl = $wc.DownloadString("$url")
$r = [regex]'l">(.*?)</p'
$m = $r.Matches($nl)
$l = $m |% {$_.groups[1].value}
$list = @()
foreach ($i in 13..($l.count -1) ) {
$Record = new-Object -typename System.Object
$Record | add-Member -memberType noteProperty -name Name -Value $m[$i].groups[1].value
[void] $foreach.MoveNext()
$Record | add-Member -memberType noteProperty -name Country -Value $m[$foreach.current].groups[1].value
1..10 |% {[void] $foreach.MoveNext();$Record | add-Member -memberType noteProperty -name "E$_" -Value $m[$foreach.current].groups[1].value}
[void] $foreach.MoveNext();$Record | add-Member -memberType noteProperty -name "Total" -Value $m[$foreach.current].groups[1].value
$list += $record
$list|group Country|`
%{if($countries[$_.name] -eq $null){$countries[$_.name]="0,0,0,0,0"}
set-variable country_val$z $cur_count




foreach ($arr_country in $arr_countries){
$record=new-object -typename system.object
$record|add-member -membertype noteproperty -name Country -value $arr_country
$record|add-member -membertype noteproperty -name PSAEntries -value $cur_country0
$record|add-member -membertype noteproperty -name PSBEntries -value $cur_country1
$record|add-member -membertype noteproperty -name VBAEntries -value $cur_country2
$record|add-member -membertype noteproperty -name VBBEntries -value $cur_country3
$record|add-member -membertype noteproperty -name Total -value $cur_country4

$listing|?{$_.Total -ge 5}|`
out-chart -palette highcontrast -label country -values psaentries,psbentries,vbaentries,vbbentries,total -AllSeries_Gallery Lines -AllSeries_PointLabels_Visible false

[end code]

(I'm still trying to figure out blogspot code formatting...  Leave a comment if you'd like me to send you the script.)