By BoLOHUKE payday loans uk

Oct 042009
 

Operations Manager has always been a fairly powerful tool. Even in it’s MOM2000 and MOM2005 variations it has a lot to offer. Sadly, in all the organizations I’ve been to, it’s never been utilized to it’s fullest.

I want to help change that.

Do you have a ‘batch’ server at your organization? You should. A batch server is a general all purpose scripting machine. It’s one you use to automate a lot of tasks that you don’t want to have a dedicated machine for, but are more important then you’d want to trust to run on your regular workstation. It doesn’t need to be anything particularly powerful – my batch server is a small Dell pizza box with now outdated hardware: Pentium 4 3.4Ghz CPU, maxed out at 2GB of ram, with an 80GB hard drive. Up until recently it ran Windows 2000 – it now runs Server 2008 standard.

A lot of the stuff I’ll be writing about will have a batch server in mind. I run these scripts there, and use OpsMgr to interact with the data. You’d be amazed at how much more you can accomplish and automate things with a simple ‘throw away’ desktop.

To start out, let’s get OpsMgr to record some stock prices. This will be a powershell script, that I’ll be running on our batch server. Read on to see how I do it.

So for this example, we’re going to create a new Performance Monitor category, a new performance counter, and record some information to it. That information will be Microsoft’s current stock price.

I’m not going to release an entire script for this yet, since I’m still working on getting used to the System.Diagnostics.PerformanceCounter class in powershell, but you’ll see how I set it up here and I’ll post that code – it’s just not very portable. I plan to have another post on PowerShell and Performance Counters including some scripts to create your own on the fly and add values easily.

One caveat – this uses PowerShell 2.0. It’s RTM on several versions of Windows (I’m using Powershell V2 on Windows 7), but if you don’t have the current CTP you can download it here. If you would rather implement this in PowerShell V1, see this post on Poshcode with details on implementing the ‘New-WebServiceProxy’ CmdLet in V1.

There’s many ways we can get external information into Operations Manager. Just a few of them are:

  • SNMP Query
  • SNMP Trap
  • WMI Event
  • CSV Log File
  • Custom Script
  • Syslog

And there’s a few more I’m sure I’m missing.

So, why a custom performance counter? Good question. This is one of the reasons I believe strongly in having a GAPBS ((General All-Purpose Batch Server)) lying around, so we can do things like this. Once we’ve created a Performance Counter we can not only collect information through Operations Manager, but also through the native performance collector and the hundreds of other programs that can also access this information. It’s fairly win-win here!

Anyway, lets start! Many thanks go to Marco Shaw for helping me to get this all running in PowerShell.

With Marco’s help and this How To on MSDN here’s the process I went through.

  1. First we need to create the counter and the category for it. Open up a PowerShell prompt. If you’re using UAC, ensure you’re opening it as an administrator.
  2. Run the following code. This will create our Performance Monitor Category, as well as a Counter named “Stock Price” and add it to our new category.
  3. If you were to open Performance Monitor, you’d see something similar to this – except you won’t have any instances (yet).
  4. Now you can run the below script to go out and query for the current Microsoft stock price and poke it into PerfMon
  5. Now, to get it into Operations Manager, you’d do what we’ve always done – create a new rule, Collection Rules, Performance Based, Windows Performance
    If you wanted to verify it works or watch it ‘live’, just open up Performance Monitor and add them to your graph, you’ll see it change like this:

Wasn’t that a lot easier then you thought it would be? Now imagine the possibilities! In the image above I’m watching 2 stock prices, Microsoft and Google – you could add as many as you wanted to! Just running a script like that from your batch server, or the RMS, or a management server, or anywhere really and now we have information flowing into OpsMgr that normally wouldn’t be getting in there.
I will get to work on cleaning up that script and adding a few new functions to my snippets file, but this should get you started!

And stay tuned – next post will show you how to have OpsMgr email you when you’re pizza is on it’s way – using PowerShell and WMI!


Be Sociable, Share!

  4 Responses to “How to monitor everything”

  1. Hi,

    Works great with 2007 SP1. However, I can’t view the custom counters in the web console, only the operations console. Have you ran into that? Also do you know how to create a dashboard of the performance view with the custom counters? I wasn’t able to figure that out.

  2. Really? That’s interesting, I’ll be honest and tell you I never attempted to look at them via the web console.
    Did you try to view them that way as soon as you created them? It may take a day to propagate out to everything, but I’ll have to take a look into that – since it might need some hand XML work done, not sure yet.

  3. Hi,

    Yes it never showed up, just shows existing performance counters for some reason. If you have any pointers to where that could be adjusted I could dig into it.

  4. You know what, I had a thought on that, and I have to investigate it further – someday, when I don’t have 50 hours billed @ work by end of day Tuesday – but I think it’s a config in the MP, though we’d have to export it, edit the xml, then re-import it.

    I’m *pretty* sure thats it

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>