question

HS-2676 avatar image
0 Votes"
HS-2676 asked VladmirZelenov-2659 answered

SCOM Monitor with write-action

Hello

we hav an old MP with a monitor for special url-check.

The Monitor is running a script and returns a property bag with uri,state and request-time.

Now I want to change the monitor that data are written as performance values.
I want to run a powershell-script after condition-detection with property-bag-values as input parameters.


How can I do this?

 #UnitMonitorType ID="MyID"#
  ...
    
     #DataSource ID="Scheduler" TypeID="System!System.SimpleScheduler"#
       #IntervalSeconds#$Config/IntervalSeconds$#/IntervalSeconds#
       #SyncTime#$Config/SyncTime$#/SyncTime#
     #/DataSource#
     #ProbeAction ID="Script" TypeID="Windows!Microsoft.Windows.PowerShellPropertyBagProbe"#
       #ScriptName#MyScript.ps1#/ScriptName#
       #ScriptBody#$IncludeFileContent/Resources/Scripts/MyScript.ps1$#/ScriptBody#
       #Parameters#
       ...
     #/ProbeAction#
     #ConditionDetection ID="RequestFilter" TypeID="System!System.ExpressionFilter"#
       #Expression#
         #SimpleExpression#
           #ValueExpression#
             #XPathQuery Type="String"#Property[@Name='URI']#/XPathQuery#
           #/ValueExpression#
           #Operator#Equal#/Operator#
           #ValueExpression#
             #Value Type="String"#$Target/Property[Type="My.Class"]/URI$#/Value#
           #/ValueExpression#
         #/SimpleExpression#
       #/Expression#
     #/ConditionDetection# 
     ...

sorry, but I can't put in "<" and ">"

rg

Hansis



msc-operations-manager
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

CyrAz avatar image
0 Votes"
CyrAz answered CyrAz edited

Your first post is not very clear, it looks like you have two distinct requirements :
- Add a write action to the monitor workflow so it will collect performance metrics in the DB/DW : not possible. However, what would work is creating a custom datasource module type with your script, then use it as the datasource in the monitor type as well as in a performance rule (with an additionnal performance data mapper at the end of the workflow to convert the property bag to performance data type).
- Run a powershell script after the monitor changes state, using data in the property bag. This is possible with a PowerShell Recovery Task and using the following syntax for the variables : $Data/StateChange/DataItem/Context/DataItem/Property[@Name=’PropertyName’]$ . More about this here : http://archive.wmug.co.uk/wmug/b/aquilaweb/posts/passing-data-items-to-recovery-actions



· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Actually I guess you could do the perf conversion+write perf metrics to db/dw in the recovery task since they can contain a ConditionDetection and WriteAction (only a single one so you would have to choose between DB and DW or write a custom WriteActionModule), but that would be a very bad design, totally unusual and out of best practice. I still strongly advise you to create a dedicated perf rule.

0 Votes 0 ·
VladmirZelenov-2659 avatar image
0 Votes"
VladmirZelenov-2659 answered

Monitors can't have write actions but you can add recovery task to achieve your issue.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

HS-2676 avatar image
0 Votes"
HS-2676 answered

Hello!
Thank you for answer.

So I know that it not possible to add a write-action in monitor-workflow.

I have made a datasource with the script and the monitor and the rule are using this datasoure.

the possibilty with recovery task is a good idea. I will take a look on it.

rg
hansi

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.