locked
Pass Monitor Name as Argument RRS feed

  • Question

  • I am wanting to pass the ID of the unitmonitor into the arguments of a twostate vbscript. 

    <unitmonitor id="mpname.class.whatever" ....... >

         <arguments>$something/config/monitorname$</arguments>

    Is anyone aware if there is a way to accomplish this?  Thank you!

     

    Daven

    Tuesday, February 15, 2011 3:45 PM

Answers

  • No, there is no substitution string for this per se. If you want to use something like $Target$ or $MPElement$ you'll get what you want, I think.  It is a value that can later be used via SDK call - but generally this will fail in a script inside of a monitor because the SDK is not available on an agent managed host that is not a root management server.
    Microsoft Corporation
    • Marked as answer by Daven Combs Wednesday, February 16, 2011 4:40 PM
    Tuesday, February 15, 2011 8:51 PM

All replies

  • what is preventing you from passing this in?  Any string can be passed in this way.

    But at the end of the day what are you trying to do with that information?  If it is to use the SDK or powershell, you may hit some blockers ... these are not available to workflows in general (rms/management server being  the exception)


    Microsoft Corporation
    Tuesday, February 15, 2011 5:51 PM
  • Lack of knowledge - trying to google it but can't find it anywhere.  I can't find the syntax for that particular field.

    <UnitMonitor ID="This.Is.My.MonitorID" Accessability="Internal" Enabled="True" Target="Your.Class.Here" ParentMonitorID="Parent.Here" Remotable="true" Priority="Normal" TypeID="Windows!Microsoft.Windows.TimedScript.ThreeStateMonitorType" ConfirmDelivery="false">       
     <OperationalStates>         
      <OperationalState ID="Success" MonitorTypeStateID="Success" HealthState="Success" />
            <OperationalState ID="Warning" MonitorTypeStateID="Warning" HealthState="Warning" />
            <OperationalState ID="Error" MonitorTypeStateID="Error" HealthState="Error" />
        </OperationalStates>
        <Configuration>
            <IntervalSeconds>300</IntervalSeconds>
            <SyncTime>00:00</SyncTime>
            <ScriptName>ScriptName.vbs</ScriptName>
            <Arguments>$Something/ThisUnitMonitorID$</Arguments>
      <ScriptBody><![CDATA[

    UnitMonitorName = WScript.Arguments(0)

    'At this point, a WScript.Echo would should return "This.Is.My.MonitorID" so it can be referenced in some VBscript stuff I'm trying to do directly with SCOM.

      ]]></ScriptBody>
      <SecureInput />
            <TimeoutSeconds>60</TimeoutSeconds>
            <ErrorExpression>
                <SimpleExpression>
                  <ValueExpression>
                    <XPathQuery Type="String">Property[@Name='Status']</XPathQuery>
                  </ValueExpression>
                  <Operator>Equal</Operator>
                  <ValueExpression>
                    <Value Type="String">CRITICAL</Value>
                  </ValueExpression>
                </SimpleExpression>
            </ErrorExpression>
            <WarningExpression>
                <SimpleExpression>
                  <ValueExpression>
                    <XPathQuery Type="String">Property[@Name='Status']</XPathQuery>
                  </ValueExpression>
                  <Operator>Equal</Operator>
                  <ValueExpression>
                    <Value Type="String">WARNING</Value>
                  </ValueExpression>
                </SimpleExpression>
            </WarningExpression>
            <SuccessExpression>
                <SimpleExpression>
                  <ValueExpression>
                    <XPathQuery Type="String">Property[@Name='Status']</XPathQuery>
                  </ValueExpression>
                  <Operator>Equal</Operator>
                  <ValueExpression>
                    <Value Type="String">OK</Value>
                  </ValueExpression>
                </SimpleExpression>
            </SuccessExpression>
        </Configuration>
    </UnitMonitor>

    Tuesday, February 15, 2011 6:49 PM
  • No, there is no substitution string for this per se. If you want to use something like $Target$ or $MPElement$ you'll get what you want, I think.  It is a value that can later be used via SDK call - but generally this will fail in a script inside of a monitor because the SDK is not available on an agent managed host that is not a root management server.
    Microsoft Corporation
    • Marked as answer by Daven Combs Wednesday, February 16, 2011 4:40 PM
    Tuesday, February 15, 2011 8:51 PM
  • $MPElement$ is what I was looking for.  Thank you!

    Wednesday, February 16, 2011 4:41 PM
  • As an added amount of information as to what I'm trying to do, it is this:

    SCOM Does not show you the *Current* value in the alert description of a Unit Monitor.  This was a brutal suprise to us when we switched from Nagios+Cacti to SCOM.  We have a custom MP I created that uses unitmonitors (over 150) to gather some values/columns from our databases using queries via VBScript and alerts about our Application based off those queries.  When some "event" would happen within our app that would cause one of those alerts to trigger, it could trigger on 10 - 15 of our databases at the same time.  We need the by-dabase alerts, it's not an alert storm to us, it's a troubleshooting tool.  We needed to prioritize in realtime and needed descriptive, relevant, data in the alert description (that is updated with the results that were gathered the last time the unitmonitor was ran).  Since the Alert is Static and never changing (unless it goes from Warning to Critical - state changes definately not good enough for this), SCOM instantly had a very signifigan downfall for us as Nagios was able to do this for us.

    So I now run the query against our database (as before), but I also hit the OperationsManager Database from within the Unitmonitor's VBScript and look at AlertView and check if an alert already exists.  If it doesn't, nothing extra happens - it just puts the alerting descriptive data into the alert description.  If it does already exist and the resolutionstate is < 255, the MonitoringObjectName matched and the $MPElement$ matches, then it will check if the AlertParams is the same as the current data (including tags of course "<AlertParameters><AlertParameter1>" & data & "</AlertParameter1></AlertParamaters>".  If the AlertParams haven't changed, it does nothing.  If they have, it updates the AlertParams to the current data.

    Additionally, I wanted SCOM to send a new notification out to all subscribers so they know the state has gotten worse since the last check.  I figured out on my own that updating the "LastModifiedExceptRepeatCount" with GETUTCDATE() will cause a new alert to go out with the current data.  I went ahead and designed the Alertview to include that field so I could hit the same view as when I update the Alert Parameters so I'll have to deal with if Microsoft every overwrites that View again but I'll deal with that as necessary.

    So what you helped me with was this: I needed to pass to the VBScript the Monitor's ID, the $Target/Property[Type="OurCustomClass"]/Name$ so that I could compare it against AlertView in addition to the MonitoringObjectName in order to verify there was or wasn't already an existing alert.  If there was, then I used the same variables to update the two fields.  I didn't want to have to manualy put in the Monitor's ID on every Unit Monitor as a variable.  Your recommendation lead me to the "MonitoringRuleId" column in the AlertView which goes hand-in-hand with the UnitMonitor's ID.  Now I just have to put $MPElement$ instead of the Unit Monitor's ID in each 150+ unit monitor we have.

    Wednesday, February 16, 2011 5:17 PM