Détection d’installations du serveur MySQL (Linux)

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

Détecte les installations du serveur MySQL (pour Linux). Cette détection analyse l'ordinateur avec un script pour identifier les installations du serveur MySQL.

Knowledge Base article:

Résumé

Cette règle de détection détecte les installations de serveurs MySQL sur les ordinateurs Linux. Une instance de serveur MySQL n'est pas analysée tant qu'un fournisseur CIM MySQL n'est pas installé et tant que les informations d'identification du serveur MySQL ne sont pas fournies. Ce fournisseur peut être installé à partir de la console Operations Manager avec la tâche « Installer/Mettre à jour le fournisseur CIM du serveur MySQL ». Les informations d'identification pour le serveur MySQL peuvent être définies à l'aide de la tâche « Définir les informations d'identification MySQL par défaut ».

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)}'`

# 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>