Search Blog
spacer
You must be logged in and have permission to create or edit a blog.
 

How to create a Two-State PowerShell Script Monitor using the Authoring Console (Part 2)

Oct 29

Written by:
Thursday, October 29, 2009 3:48:44 PM  RssIcon

This is a step-by-step guide in multiple parts:

Part 1 will cover the Probe Actions Module Types: Part 1 is available here on SCC or here on code4ward 
Part 2 will be about creating a Data Source
Part 3 will cover creating a Monitor Type
Part 4 will cover the Unit Monitor itself

As always be careful with the samples provided here. Always use a test environment first to try those examples!

Will only work with OpsMgr 2007 R2 !

Part 2: Data Source

What do we need a data source for?

The data source we create will be needed in out monitor type (which will be explained in Part 3 of this series). So far we only defined a module which is returning a property bag with our state information and a wrapped up module we use for a (diagnostic-)task later on. In the latter case, the trigger for our module will be the operator launching the task. For our monitor we need a scheduler to trigger our probe – so for this we will create a simple data source.

Creating the Data Source

image

Change to the Data Sources node and right-click to create a New->Composite Data Source…

The ID will be: code4ward.Sample.PowerShellMonitor.DataSource.CheckFileContent
Name will be: Check File Content Data Source

image Now change to the Member Modules tab and click on Add…

Look for the System.Scheduler, select it and give it an ID like: Scheduler
Remember, the ID we choose here needs only to be unique within the Member Modules scope, it doesn’t need to be unique for the whole MP. Therefore you can also choose the ID Scheduler for another data source in this MP.

Hit OK.
image We will configure this module that all the configuration will be passed on from its consumer. You can use the fly-out button and select Promote… to fill in the appropriate $Config values.
image Now let’s add another module, our Check File Content Probe we created in the first part. We ID it Probe
image The configuration of our Check File Content probe is also straight forward. All parameters (except the last one) will be populated by its consumer. The last parameter will be set to false. We know that the module in this data source will never be used with the additional information we provide when we execute it as task.
image Before we move on to the next tab, we need to define the order our modules are executed:
The Scheduler is our first module, which is basically triggering the workflow. So, in the Next Module column we set Probe as our next module to be executed.
the Probe module will provide the Module Output
image In the Configuration Schema tab we need to verify (again) that all the data types are set accordingly. The authoring console tends to always use String as type, so we need to correct them to set Interval to Integer and Debug to Boolean.

Also keep in mind that optional parameters will not be shown here by default. In case you have modules with optional parameters you need to add them explicitly. It is also important the the order of the parameters are correct!

In our case we do not have and use any optional parameters, so nothing to do for us here. But if we would have defined an optional boolean parameter named “Bob” in our CheckFileContent probe after the ErrorText and we want to use it, we must add this parameter manually to this list right after the ErrorText parameter and set it to boolean. The arrows next to the list allows to reorder the list.
image In the Overridable Parameters tab we add all our parameters to the list.

As mentioned in Part 1, if you want to seal you MP and want others to use this data source in their own MP you need to mark this data source Public in the Options tab.

That’s it for part 2. The next step will be creating the monitor type.

cheers,
Stefan Koell
http://www.code4ward.net

Tags:
Categories:
Location: Blogs Parent Separator Stefan Koell

2 comment(s) so far...


Gravatar

Re: How to create a Two-State PowerShell Script Monitor using the Authoring Console (Part 2)

These are very interesting post and blog,thanks.
www.pdfqueen.com

By Nyasia on   Thursday, January 14, 2010 10:44:29 AM
Gravatar

Re: How to create a Two-State PowerShell Script Monitor using the Authoring Console (Part 2)

Hi all

Try to create a monitor to calculate available memory in percentage. With powershell I read from wmi TotalPhysicalMemory and AvailableMemory and calculate the percentage. So far so good, but how can I bring this in a monitor?

I just found examples by abbmp3.com/ music search engine with create eventlog entries but nothing with powershell and wmi. Can anybody help me?

I'm beginner in powershell and SCOM.

Thanks for any suggestions.

By Oxy on   Wednesday, August 04, 2010 2:18:34 PM

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
CAPTCHA image
Enter the code shown above in the box below
Add Comment   Cancel 
spacer
dummy