Having just discovered how to get SCOM data from Microsoft Sho - a dynamic language analysis environment - I thought I’d try from F#. Pretty much the same but you need to think about what to do with the graphing, and you need to handle the Nullable<float> values coming back from SCOM.
I used fschart to do the plotting and a sequence filter and boxing/unboxing to handle the Nullable data.
The histogram function wouldn’t be hard to make but while stumbling across fschart I also stumbled across this.
So my contribution was do this:
#r "c:\Program Files\System Center Operations Manager 2007\SDK Binaries\Microsoft.EnterpriseManagement.OperationsManager.dll"
let mg = Microsoft.EnterpriseManagement.ManagementGroup("someManagementServer")
let mpdc = MonitoringPerformanceDataCriteria("ObjectName = 'ASP.NET' and CounterName like 'Request Execution%' and MonitoringObjectPath like 'someMonitoringObjectPathFilter%'")
let mpds = mg.GetMonitoringPerformanceData(mpdc)
let (perfData:seq<DateTime * float>) =
|> Seq.map (fun(mpdv) -> (mpdv.TimeAdded, mpdv.SampleValue))
|> Seq.filter ( fun(d,v) -> v.HasValue)
|> Seq.map ( fun(d,v) -> (d,box v) )
|> Seq.map ( fun(d,v) -> (d, unbox v) )
hist 0.0 200. 50 (perfData |> Seq.map (fun (d,v) -> v) )
The result looks like this.
So the question is… what was the more efficient approach? Well when I did the sho/python code I actually had some c# code open in the background to help me through the classes - without that it would have been really hard. The F# approach made me scratch my head a few times wondering how to deal with charting and nullables but all the way through (much like the c#) I had the advantage of the richer type information to help me figure out what to do.