MySQL Server Yüklemesi Bulma (Linux)

Microsoft.MySQLServer.Installation.ScriptDiscovery.Unix (Discovery)

MySQL Server'ın örneklerini bulur (Linux için). Bu bulma işlemi, MySQL Server yüklemelerini belirlemek üzere bilgisayarı bir betikle araştırır

Knowledge Base article:

Özet

Bu bulma kuralı, Linux sunucularındaki MySQL Server yüklemelerini bulur. Bir MySQL Server örneği, MySQL CIM Sağlayıcı yüklenene ve MySQL Server kimlik bilgileri sağlanana kadar izlenmez. Bu sağlayıcı, İşlemler Konsolu'ndan "MySQL Server CIM Sağlayıcı Yükleme/Yükseltme" görevi kullanılarak yüklenebilir. MySQL Server'ın kimlik bilgileri "Varsayılan MySQL Server Kimlik Bilgilerini Ayarla" görevi kullanılarak ayarlanabilir.

Element properties:

TargetMicrosoft.Linux.Computer
EnabledTrue
RemotableFalse

Object Discovery Details:

Discovered Classes and their attribuets:

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource Microsoft.Oss.TimedShellScript.PropertyBag.Discovery.DataSource Default

Source Code:

<Discovery ID="Microsoft.MySQLServer.Installation.ScriptDiscovery.Unix" Target="Linux!Microsoft.Linux.Computer" Enabled="true" ConfirmDelivery="false" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="Microsoft.MySQLServer.Installation.Unix"/>
</DiscoveryTypes>
<DataSource ID="DS" TypeID="Oss!Microsoft.Oss.TimedShellScript.PropertyBag.Discovery.DataSource">
<Interval>14400</Interval>
<TargetSystem>$Target/Property[Type="Unix!Microsoft.Unix.Computer"]/NetworkName$</TargetSystem>
<ShellScript>

#!/bin/bash

version=""
version=`mysqld --version |awk '{print $(NF-5)}'`
if [ "$version" = 'on' ]
then
version=`mysqld --version |awk '{print $(NF-8)}'`
elif [ "$version" = 'for' ]
then
version=`mysqld --version |awk '{print $(NF-6)}'`
fi
# rpm/deb package data directory location
if [ -e /var/lib/mysql/ ]
then
datdir="/var/lib/mysql/"
printf "datdir=$datdir,version=$version"

# generic package data directory location
elif [ -e /usr/local/mysql/data/]
then
datadir="/usr/local/mysql/data/"
printf "datdir=$datdir,version=$version"

# tar source data directory location
elif [ -e /usr/local/var/mysql/ ]
then
datadir="/usr/local/var/mysql/"
printf "datdir=$datdir,version=$version"
fi

</ShellScript>
<ScriptArguments/>
<Timeout>60</Timeout>
<UserName>$RunAs[Name="Unix!Microsoft.Unix.ActionAccount"]/UserName$</UserName>
<Password>$RunAs[Name="Unix!Microsoft.Unix.ActionAccount"]/Password$</Password>
<PSScriptName>ParseOutput.ps1</PSScriptName>
<PSScriptBody>
param([string]$StdOut,[string]$StdErr,[string]$ReturnCode)

if($StdOut -like "*datdir*"){
$api = New-Object -ComObject 'MOM.ScriptAPI'
$bag = $api.CreatePropertyBag()

$arProps=$stdOut.Split(",")
foreach ($prop in $arProps) {
$PropName=$prop.Split("=")[0]
$PropValue=$prop.Split("=")[1].Replace("`n","")
$bag.AddValue("$PropName","$PropValue")
}
$bag
}
</PSScriptBody>
<FilterExpression>
<RegExExpression>
<ValueExpression>
<XPathQuery>Property[@Name='datdir']</XPathQuery>
</ValueExpression>
<Operator>MatchesRegularExpression</Operator>
<Pattern>\/.+\/.+\/.+</Pattern>
</RegExExpression>
</FilterExpression>
<ClassId>$MPElement[Name="Microsoft.MySQLServer.Installation.Unix"]$</ClassId>
<InstanceSettings>
<Settings>
<Setting>
<Name>$MPElement[Name='Microsoft.MySQLServer.Installation']/DataDirectory$</Name>
<Value>$Data/Property[@Name='datdir']$</Value>
</Setting>
<Setting>
<Name>$MPElement[Name='Microsoft.MySQLServer.Installation']/Version$</Name>
<Value>$Data/Property[@Name='version']$</Value>
</Setting>
<Setting>
<Name>$MPElement[Name='Unix!Microsoft.Unix.Computer']/PrincipalName$</Name>
<Value>$Target/Property[Type="Unix!Microsoft.Unix.Computer"]/PrincipalName$</Value>
</Setting>
</Settings>
</InstanceSettings>
</DataSource>
</Discovery>