Thursday 3 April 2014

SCOM Script Monitor Numeric Expressions Default To String

Here's a straighforward explanation of something I found took me a long time to figure out. I found lots of posts but none that explain this straight up...(also I'm sure I knew this 5 years ago when I was doing heaps of SCOM stuff but had since forgotten!)

If you make a SCOM scripted state monitor using say a vbscript and you want to check the result of a numeric value (say an integer), by default it does a string comparison not a numeric one.

Regardless of the variant type your script produces (note variant types listed here: http://www.culham.net/2012/scom/property-bags-and-variant-types ) the authoring gui's create a STRING type compare. This is because there is no datatype field on the SCOM editing screen (unlike say CA Spectrum event configuration where every value has to be typed explicitly).

For example say I return this with my MOM.ScriptAPI AddValue("diffThresholdMinusRun",iServiceCountThreshold-good)

this results in something like:
<DataItem type="System.PropertyBagData" time="2014-04-04T12:09:26.8984174+13:00" sourceHealthServiceId="2B60ADC4-15C5-0FE3-7FF8-1"></Property><Property Name="diffThresholdMinusRun" VariantType="2">-1</Property>...

Now I create a unhealthy expression in SCOM for >0 critical and <=0 OK. Unfortunately the comparisions default to STRING so don't work properly. Any negative value is evalutated as unhealth (becuase - is > 0 in string compare) For example

       <ErrorExpression>
            <SimpleExpression>
              <ValueExpression>
                <XPathQuery Type="String">Property[@Name='diffThresholdMinusRun']</XPathQuery>
              </ValueExpression>
              <Operator>Greater</Operator>
              <ValueExpression>
                <Value Type="String">0</Value>
              </ValueExpression>
            </SimpleExpression>
          </ErrorExpression>

The only way to fix this is to edit the management pack xml (in the 'edit' screen in authoring console or in xml editor) so that it has a valid numeric type (say Integer).

 <ErrorExpression>
    <SimpleExpression>
      <ValueExpression>
        <XPathQuery Type="Integer">Property[@Name='diffThresholdMinusRun']</XPathQuery>
      </ValueExpression>
      <Operator>Greater</Operator>
      <ValueExpression>
        <Value Type="Integer">0</Value>
      </ValueExpression>
    </SimpleExpression>
  </ErrorExpression>

Wednesday 19 March 2014

SCOM Query to Show All Tasks Defined By Management Pack and Target Class

We've been looking at making better use of the built in tasks in SCOM recently. One of the biggest issues is that there are lots of tasks there but users don't realise they even exist because unless the select an object of the correct target class the pre-defined tasks are effectively invisible.

A common example is users select a windows computer object (which has one set of tasks) when if they selected a windows server operating system class object (in say the windows server MP view) htey will get a totally different set of possible tasks.

So I wrote this SQL query to dump out a list of all the tasks defined in your SCOM operations database (not the datawarehouse DB!).

Armed with this list you can easily find out what tasks exist and what target class you need to select to be able to execute them. Then using 'discovered inventory' you can specifically target a class of object to get the tasks you want (even if you don't know a canned view that targets objects of that type.)

SELECT     dbo.TaskView.Id, dbo.TaskView.Name, dbo.TaskView.DisplayName, dbo.TaskView.Description, dbo.TaskView.Category,
                      dbo.ManagedType.TypeName AS TargetClassName, dbo.TaskView.Enabled, dbo.TaskView.Timeout, dbo.TaskView.TimeAdded,
                      dbo.ManagementPack.MPName, dbo.ManagementPack.MPFriendlyName AS MPFirendlyName
FROM         dbo.TaskView LEFT OUTER JOIN
                      dbo.ManagementPack ON dbo.TaskView.ManagementPackId = dbo.ManagementPack.ManagementPackId LEFT OUTER JOIN
                      dbo.ManagedType ON dbo.TaskView.TargetMonitoringClassId = dbo.ManagedType.ManagedTypeId
ORDER BY dbo.TaskView.DisplayName

Thursday 13 March 2014

SCOM run as profile SSID in hex

it took me along time to find this post about how to convert a hex SSID value in a scom event to something where I could figure out what user was causing the problem.

reposting here so I can find it again next time!

http://social.technet.microsoft.com/Forums/systemcenter/en-US/0b9bd679-a712-435e-9a27-8b3041cddac8/how-to-find-the-runasaccount-from-the-ssid?forum=operationsmanagergeneral


Tuesday 14 January 2014

Spooky Number Times Table Game Released on Android Play Store

I launched my first android app this month that I created with Corona SDK. Its a educational times table game called Spooky Numbers Times Tables and can be found on the android store.

Spooky Numbers On Google Play

The game is free and a great way for kids of all ages to build their times table skills.

It also has a level editor so kids can make their own level to play in the game!