locked
Unix.Authoring.TimedShellScript.PropertyBag.Discovery.DataSource all failing since scom 2019 RRS feed

  • Question

  • I've made a few discoveries with the unix authoring extention pack in the past but now just last week we found out that all those discoveries don't work anymore since we've upgraded to scom 2019ur1.

    By adding some debugging i found out that even the first line

    #!/bin/bash

    is enough to create the error. The 'if' statement is also not understood. It seems the only working command is 'echo' if i only put 'echo something' between the <ShellScript> tag it works.

    Does anyone has seen the same?

    For test i created a totally bare mp that should just discover the unix/linux machines as an extended class instance, maybe anyone can test it or find what it wrong.

    <?xml version="1.0" encoding="utf-8"?>
    <ManagementPack SchemaVersion="2.0" ContentReadable="true" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <Manifest>
        <Identity>
          <ID>Test.Discovery</ID>
          <Version>1.0.0.2</Version>
        </Identity>
        <Name>Test.Discovery</Name>
        <References>
          <Reference Alias="SC">
            <ID>Microsoft.SystemCenter.Library</ID>
            <Version>7.0.8443.6</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
          </Reference>
          <Reference Alias="Unix">
            <ID>Microsoft.Unix.Library</ID>
            <Version>10.19.1082.0</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
          </Reference>
          <Reference Alias="Windows">
            <ID>Microsoft.Windows.Library</ID>
            <Version>7.5.8501.0</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
          </Reference>
          <Reference Alias="Health">
            <ID>System.Health.Library</ID>
            <Version>7.0.8438.6</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
          </Reference>
          <Reference Alias="System">
            <ID>System.Library</ID>
            <Version>7.5.8501.0</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
          </Reference>
          <Reference Alias="UnixAuth">
            <ID>Unix.Authoring.Library</ID>
            <Version>7.3.1.2</Version>
            <PublicKeyToken>a0ae1bc76c673799</PublicKeyToken>
          </Reference>
        </References>
      </Manifest>
      <TypeDefinitions>
        <EntityTypes>
          <ClassTypes>
            <ClassType Abstract="false" Accessibility="Public" Base="Unix!Microsoft.Unix.Computer" Extension="false" Hosted="false" ID="Unix.Linux.Extended" Singleton="false">
              <Property AutoIncrement="false" CaseSensitive="false" ID="TestProp.Unix.Linux.Computers" Key="false" MaxLength="256" MinLength="0" Required="false" Scale="0" Type="string"></Property>
            </ClassType>
          </ClassTypes>
        </EntityTypes>
      </TypeDefinitions>
      <Monitoring>
        <Discoveries>
          <Discovery ConfirmDelivery="false" Enabled="true" ID="Unix.Linux.Standby.Discovery" Priority="Normal" Remotable="true" Target="Unix!Microsoft.Unix.Computer">
            <Category>Discovery</Category>
            <DiscoveryTypes>
              <DiscoveryClass TypeID="Unix.Linux.Extended">
                <Property PropertyID="TestProp.Unix.Linux.Computers" TypeID="Unix.Linux.Extended"></Property>
              </DiscoveryClass>
            </DiscoveryTypes>
            <DataSource ID="DS" TypeID="UnixAuth!Unix.Authoring.TimedShellScript.PropertyBag.Discovery.DataSource">
              <Interval>300</Interval>
              <TargetSystem>$Target/Property[Type="Unix!Microsoft.Unix.Computer"]/NetworkName$</TargetSystem>
              <ShellScript>
    #!/bin/bash
    TESTFILE="/tmp/testfile.txt"
    
    if [ -f $TESTFILE ]
    then
     echo true
    else
     echo false
    fi
              </ShellScript>
              <ScriptArguments></ScriptArguments>
              <Timeout>60</Timeout>
              <UserName>$RunAs[Name="Unix!Microsoft.Unix.ActionAccount"]/UserName$</UserName>
              <Password>$RunAs[Name="Unix!Microsoft.Unix.ActionAccount"]/Password$</Password>
              <PSScriptName>ConvertOutput.ps1</PSScriptName>
              <PSScriptBody>
    param([string]$StdOut,[string]$StdErr,[string]$ReturnCode)
    
    if ($ReturnCode -eq "0") {
      $evtxt="stdout=$StdOut`nError=$StdErr`nReturnCode=$ReturnCode" 
      $api = New-Object -comObject 'MOM.ScriptAPI'
      $api.LogScriptEvent($ScriptName,9999,0,"Discover test DEBUG:`n$evtxt")
      $bag = $api.CreatePropertyBag()
      if ($StdOut -ne $null) {
       $bag.AddValue('SomeVar',$StdOut)
      }
      else {
       $bag.AddValue('SomeVar','false')
      }
      $bag
    }
    else {
       $api = New-Object -comObject 'MOM.ScriptAPI'
       $evtxt="stdout=$StdOut`nError=$StdErr`nReturnCode=$ReturnCode"
       $api.LogScriptEvent($ScriptName,9999,2,"Discover test failed:`n$evtxt")
    
       $bag = $api.CreatePropertyBag()
       $bag.AddValue('SomeVar','false')
       $bag
    }
              </PSScriptBody>
              <FilterExpression>
                <RegExExpression>
                  <ValueExpression>
                    <XPathQuery>Property[@Name='SomeVar']</XPathQuery>
                  </ValueExpression>
                  <Operator>MatchesRegularExpression</Operator>
                  <Pattern>true</Pattern>
                </RegExExpression>
              </FilterExpression>
              <ClassId>$MPElement[Name="Unix.Linux.Extended"]$</ClassId>
              <InstanceSettings>
                <Settings>
                  <Setting>
                    <Name>$MPElement[Name='Unix!Microsoft.Unix.Computer']/PrincipalName$</Name>
                    <Value>$Target/Property[Type="Unix!Microsoft.Unix.Computer"]/PrincipalName$</Value>
                  </Setting>
                  <Setting>
                    <Name>$MPElement[Name='Unix.Linux.Extended']/TestProp.Unix.Linux.Computers$</Name>
                    <Value>$Data/Property[@Name='SomeVar']$</Value>
                  </Setting>
                </Settings>
              </InstanceSettings>
            </DataSource>
          </Discovery>
        </Discoveries>
      </Monitoring>
      <Presentation>
      </Presentation>
      <LanguagePacks>
        <LanguagePack ID="ENU" IsDefault="true">
          <DisplayStrings>
            <DisplayString ElementID="Test.Discovery">
              <Name>Test Discovery</Name>
            </DisplayString>
            <DisplayString ElementID="Unix.Linux.Extended">
              <Name>UNIX/Linux Computer Extended2</Name>
              <Description></Description>
            </DisplayString>
            <DisplayString ElementID="Unix.Linux.Extended" SubElementID="TestProp.Unix.Linux.Computers">
              <Name>TestProp</Name>
              <Description></Description>
            </DisplayString>
          </DisplayStrings>
          <KnowledgeArticles></KnowledgeArticles>
        </LanguagePack>
      </LanguagePacks>
    </ManagementPack>


    Ronald

    Tuesday, July 21, 2020 7:45 AM

All replies