Устанавливаем и тестируем OMI, DSC, Powershell на Linux.

Установочные пакеты OMI
Open Management Infrastructure
можно взять здесь: https://github.com/Microsoft/omi/releases
Установка omi из пакетов

Определяем версию opensssl и в зависимости от версии будем устанавливать пакет omi.

openssl version

Вывод:

root@icinga-failover:/opt/omi/bin# openssl version
OpenSSL 1.0.1f 6 Jan 2014

Устанавливаем соответствующий версии OpenSSL, пакет omi:

wget https://github.com/Microsoft/omi/releases/download/v1.4.0-4/omi-1.4.0-4.ssl_100.ulinux.x64.deb

dpkg -i ./omi-1.4.0-4.ssl_100.ulinux.x64.deb
Установка omi из репозитория
wget https://packages.microsoft.com/config/ubuntu/14.04/packages-microsoft-prod.deb
dpkg -i packages-microsoft-prod.deb
apt-get update

apt-get install omi

Редактируем файл конфигурации /etc/opt/omi/conf/omiserver.conf, где нужно указать порты для прослушивания в параметрах httpport и httpsport.

omiserver.conf
```
root@ubuntu-omi-test:/etc/opt/omi/conf# cat omiserver.conf
# omiserver configuration file

##
## httpport -- listening port for the binary protocol (default is 5985)
##
httpport=5985

##
## httpsport -- listening port for the binary protocol (default is 5986)
##
httpsport=5986

##
## idletimeout -- idle providers unload timeout in seconds (defualt is 90)
##
#idletimeout=TIMEOUT

##
## trace -- enable tracing to standard output (default is 'false')
##
#trace=(true|false)

##
## NtlmCredsFile -- credentials file for NTLM authentication
##
## To enable NTLM authentication via negotiation (SPNEGO), specify the
## location of the credentials file. This file is in the form:
##
##   <domain>:<username>:<password>
##
## For further information, please see: https://github.com/Microsoft/omi/blob/master/Unix/doc/setup-ntlm-omi.md
##
#NtlmCredsFile=/etc/opt/omi/.creds/ntlm

##
## <NICKNAME> -- set the value of nickname.
##
#prefix=PATH
#libdir=PATH
#bindir=PATH
#localstatedir=PATH
#sysconfdir=PATH
#providerdir=PATH
#certsdir=PATH
#datadir=PATH
rundir=/var/opt/omi/run
#logdir=PATH
#schemadir=PATH
#schemafile=PATH
pidfile=/var/opt/omi/run/omiserver.pid
logfile=/var/opt/omi/log/omiserver.log
registerdir=/etc/opt/omi/conf/omiregister
pemfile=/etc/opt/omi/ssl/omi.pem
keyfile=/etc/opt/omi/ssl/omikey.pem
#agentprogram=PATH
#serverprogram=PATH
#includedir=PATH
configfile=/etc/opt/omi/conf/omiserver.conf
#NoSSLv2=true
#NoSSLv3=false

## non-root feature parameters
#nonroot=true

```

Перезапускаем сервис:

/opt/omi/bin/service_control restart

Проверяем, с удаленного Windows компьютера:

PS C:\scripts> $Credentials = get-credential
PS C:\scripts> $CimOptions = New-CimSessionOption -SkipCACheck -SkipCNCheck -UseSsl -SkipRevocationCheck
PS C:\scripts> $CimSession = New-CimSession -Credential $Credentials -ComputerName 192.168.0.160 -port 5986 -Authentication Basic -SessionOption $CimOptions
PS C:\scripts> Get-CimInstance -CimSession $CimSession -namespace root/omi -ClassName omi_identify


InstanceID             : 2FDB5542-5896-45D5-9BE9-DC04430AAABE
SystemName             : ubuntu-omi-test.pshome.local
ProductName            : OMI
ProductVendor          : Microsoft
ProductVersionMajor    : 1
ProductVersionMinor    : 4
ProductVersionRevision : 0
ProductVersionString   : 1.4.0-4
Platform               : LINUX_X86_64_GNU
OperatingSystem        : LINUX
Architecture           : X86_64
Compiler               : GNU
ConfigPrefix           : GNU
ConfigLibDir           : /opt/omi/lib
ConfigBinDir           : /opt/omi/bin
ConfigIncludeDir       : /opt/omi/include
ConfigDataDir          : /opt/omi/share
ConfigLocalStateDir    : /var/opt/omi
ConfigSysConfDir       : /etc/opt/omi/conf
ConfigProviderDir      : /etc/opt/omi/conf
ConfigLogFile          : /var/opt/omi/log/omiserver.log
ConfigPIDFile          : /var/opt/omi/run/omiserver.pid
ConfigRegisterDir      : /etc/opt/omi/conf/omiregister
ConfigSchemaDir        : /opt/omi/share/omischema
ConfigNameSpaces       : {root-omi}
PSComputerName         : 192.168.0.160
Установка SCXcore-kits

Установка omi не добавляет какие либо классы или пространства имен кроме класса OMI_Identify в прастранстве имен root/omi. Минимальный набор можно добавить установив SCXCore. SCXCore добавляет следующие классы:

  • SCX_Agent
  • SCX_Application_Server
  • SCX_DiskDrive
  • SCX_DiskDriveStatisticalInformation
  • SCX_EthernetPortStatistics
  • SCX_FileSystem
  • SCX_FileSystemStatisticalInformation
  • SCX_IPProtocolEndpoint
  • SCX_LANEndpoint
  • SCX_LogFile
  • SCX_MemoryStatisticalInformation
  • SCX_OperatingSystem
  • SCX_ProcessorStatisticalInformation
  • SCX_RTProcessorStatisticalInformation
  • SCX_UnixProcess
  • SCX_UnixProcess TopResourceConsumers
  • SCX_UnixProcessStatisticalInformation

SCXcore, запущенный как агент Microsoft Operations Manager UNIX / Linux, теперь используется в целом ряде продуктов, включая Microsoft Operations Manager. Microsoft Azure и Microsoft Operations Management Suite. SCXcore предоставляет провайдер CIMOM на основе OMI для возврата журнала и статистической информации для системы UNIX или Linux. Поставщик SCXcore работает под управлением AIX 6.1 и более поздних версий, HP / UX 11.31 и более поздних версий, Solaris 5.10 и более поздних версий, а также большинство версий Linux еще в RedHat 5.0, SuSE 10.1 и Debian 5.0.

В составе установочного скрипта scx-1.6.3-326.universal.x64.sh лежит пакет omi, но старой версии, поэтому лучше извлечь пакеты (запустив скрипт с параметром --extract) и установить только SCX.

wget https://github.com/Microsoft/SCXcore-kits/blob/master/release/scx-1.6.3-326.universal.x64.sh?raw=true -O scx-1.6.3-326.universal.x64.sh

chmod 755 ./scx-1.6.3-326.universal.x64.sh
./scx-1.6.3-326.universal.x64.sh --extract
cd scxbundle.2106/100
dpkg -i ./scx-1.6.3-326.universal.x64.deb

После установки появятся дополнительные пространства имен:

PS C:\scripts> Get-CimInstance -CimSession $CimSession -namespace root/omi -ClassName omi_identify


InstanceID             : 2FDB5542-5896-45D5-9BE9-DC04430AAABE
SystemName             : ubuntu-omi-test.pshome.local
ProductName            : OMI
ProductVendor          : Microsoft
ProductVersionMajor    : 1
ProductVersionMinor    : 4
ProductVersionRevision : 0
ProductVersionString   : 1.4.0-4
Platform               : LINUX_X86_64_GNU
OperatingSystem        : LINUX
Architecture           : X86_64
Compiler               : GNU
ConfigPrefix           : GNU
ConfigLibDir           : /opt/omi/lib
ConfigBinDir           : /opt/omi/bin
ConfigIncludeDir       : /opt/omi/include
ConfigDataDir          : /opt/omi/share
ConfigLocalStateDir    : /var/opt/omi
ConfigSysConfDir       : /etc/opt/omi/conf
ConfigProviderDir      : /etc/opt/omi/conf
ConfigLogFile          : /var/opt/omi/log/omiserver.log
ConfigPIDFile          : /var/opt/omi/run/omiserver.pid
ConfigRegisterDir      : /etc/opt/omi/conf/omiregister
ConfigSchemaDir        : /opt/omi/share/omischema
ConfigNameSpaces       : {root-scx, root-omi, root-Microsoft-DesiredStateConfiguration, root-Microsoft-Windows-DesiredS
                         tateConfiguration}
PSComputerName         : 192.168.0.160

Вывод SCX_OperatingSystem:

PS C:\scripts> Get-CimInstance -CimSession $CimSession -namespace root/scx -ClassName SCX_OperatingSystem


InstanceID                :
Caption                   : Ubuntu 14.04 (x86_64)
Description               : Ubuntu 14.04 (x86_64)
ElementName               :
InstallDate               :
Name                      : Linux Distribution
OperationalStatus         :
StatusDescriptions        :
Status                    :
HealthState               :
CommunicationStatus       :
DetailedStatus            :
OperatingStatus           :
PrimaryStatus             :
EnabledState              : 5
OtherEnabledState         :
RequestedState            : 12
EnabledDefault            : 2
TimeOfLastStateChange     :
AvailableRequestedStates  :
TransitioningToState      :
CSCreationClassName       : SCX_ComputerSystem
CSName                    : ubuntu-omi-test.pshome.local
CreationClassName         : SCX_OperatingSystem
OSType                    : 36
OtherTypeDescription      : 4.4.0-31-generic #50~14.04.1-Ubuntu SMP Wed Jul 13 01:07:32 UTC 2016 x86_64
Version                   : 14.04
LastBootUpTime            : 05.11.2017 1:54:36
LocalDateTime             : 05.11.2017 2:38:20
CurrentTimeZone           : 300
NumberOfLicensedUsers     : 0
NumberOfUsers             : 1
NumberOfProcesses         : 120
MaxNumberOfProcesses      : 7691
TotalSwapSpaceSize        : 1048572
TotalVirtualMemorySize    : 2056200
FreeVirtualMemory         : 1417628
FreePhysicalMemory        : 369684
TotalVisibleMemorySize    : 1007628
SizeStoredInPagingFiles   : 1048572
FreeSpaceInPagingFiles    : 1047944
MaxProcessMemorySize      : 0
Distributed               :
MaxProcessesPerUser       : 3845
OperatingSystemCapability : 64 bit
SystemUpTime              : 2633
PSComputerName            : 192.168.0.160
Установка DSC
wget https://github.com/Microsoft/PowerShell-DSC-for-Linux/releases/download/v1.1.1-294/dsc-1.1.1-294.ssl_100.x64.deb
dpkg -i ./dsc-1.1.1-294.ssl_100.x64.deb

Проверяем работоспособность DSC. Создадим простейшую конфигурацию (создается файл /tmp/example с текстом "hello world") и отправим ее на Linux сервер.

На Windows компьютере, где будем создавать конфигурацию необходимо установить модуль nx.

Configuration ExampleConfiguration{

    Import-DscResource -Module nx

    Node  "192.168.0.160"{
        nxFile ExampleFile {

            DestinationPath = "/tmp/example"
            Contents = "hello world `n"
            Ensure = "Present"
            Type = "File"
        }

    }
}
ExampleConfiguration -OutputPath:"C:\temp\omi-test"


$Node = "192.168.0.160"
$Credential = Get-Credential -UserName:"root" -Message:"Enter Password:"

#Options for a trusted SSL certificate
#$opt = New-CimSessionOption -UseSsl:$true
#Ignore SSL certificate validation
$opt = New-CimSessionOption -UseSsl:$true -SkipCACheck:$true -SkipCNCheck:$true -SkipRevocationCheck:$true

$CimSession = New-CimSession -Credential:$credential -ComputerName:$Node -Port:5986 -Authentication:basic -SessionOption:$opt -OperationTimeoutSec:90

Start-DscConfiguration -Path:"C:\temp\omi-test" -CimSession:$CimSession -Wait -Verbose



<#
$cred = Get-Credential
$o = New-PSSessionOption -SkipCACheck -SkipRevocationCheck -SkipCNCheck
Enter-PSSession -ComputerName 192.168.0.160 -Credential $cred -Authentication basic -UseSSL -SessionOption $o

#>
Установка Powershell на Ubuntu 14.04
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/14.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list

apt-get update
apt-get install libunwind8 libicu52
apt-get install -y powershell

pwsh

Пробуем:

root@ubuntu-omi-test:/root# pwsh
PowerShell v6.0.0-beta.9
Copyright (C) Microsoft Corporation. All rights reserved.

PS /root> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.0.0-beta.9
PSEdition                      Core
GitCommitId                    v6.0.0-beta.9
OS                             Linux 4.4.0-31-generic #50~14.04.1-Ubuntu SMP Wed Jul 13 01:07:32 UTC 2016
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Установка PSRP-Server
apt-get install omi-psrp-server

Ссылки

Попробовать написать свой провайдер: