AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 728557
Accepted
Juris Krumins
Juris Krumins
Asked: 2015-10-14 01:05:20 +0800 CST2015-10-14 01:05:20 +0800 CST 2015-10-14 01:05:20 +0800 CST

从作为 ServerManager.DeploymentProvider.dll 一部分的 WMI 提供程序“deploymentprovider”观察到高 CPU 使用率

  • 772

我正在使用 powerShell Desired State Configuration 在服务器机器上测试/设置 Windows 功能。我拥有的是 78 个 WindowsFeature 资源,如果需要,可以检查和安装。我观察到的是在 LCM(本地配置管理器)执行和检查配置时 CPU 使用率很高。我进行了一些调查,发现 WMI 提供程序“deploymentprovider”是负责 WindowsFeature 资源的 ServerManager.DeploymentProvider.dll 的一部分。所以问题是,有没有人经历过这个问题并以某种方式解决了它?

提前致谢。

dsc
  • 2 2 个回答
  • 280 Views

2 个回答

  • Voted
  1. Juris Krumins
    2015-10-17T04:41:05+08:002015-10-17T04:41:05+08:00
        Configuration cWindowsFeatures {
            param
            (
                [parameter(Mandatory=$true)]
                $WindowsFeatures
    
            )
            Import-DscResource -ModuleName PSDesiredStateConfiguration
            $i=0
            foreach($WindowsFeature in $WindowsFeatures.keys)
            {
                $ResourceName="WindowsFeature$($i)"
                WindowsFeature "$ResourceName"
                {
                    Name = "$WindowsFeature"
                    Ensure = $WindowsFeatures["$WindowsFeature"][0]
                    IncludeAllSubFeature = $WindowsFeatures["$WindowsFeature"][1]
                }
                $i++
            }
    }
    
    
    function Get-TargetResource 
    {
        [CmdletBinding()]
        [OutputType([System.Collections.Hashtable])]
        param 
        (      
            [parameter(Mandatory = $true)]
            [ValidateNotNullOrEmpty()]
            [string]
            $Id,
            [parameter(Mandatory = $true)]
            [ValidateNotNullOrEmpty()]
            [string[]]
            $WindowsFeature
        )
    
        $retValue=@{}
        $InstalledFeatures=(Get-WindowsFeature -Name $WindowsFeature | Where-Object {$_.InstallState -eq "Installed"}).Name
        $retValue.WindowsFeature=$InstalledFeatures
        return $retValue
    }
    
    
    function Set-TargetResource 
    {
        [CmdletBinding()]
        param 
        (      
            [parameter(Mandatory = $true)]
            [ValidateNotNullOrEmpty()]
            [string]
            $Id,
            [parameter(Mandatory = $true)]
            [ValidateNotNullOrEmpty()]
            [string[]]
            $WindowsFeature
        )
    
        Install-WindowsFeature -Name $WindowsFeature
    
    }
    
    # The Test-TargetResource cmdlet is used to validate if the role or feature is in a state as expected in the instance document.
    function Test-TargetResource 
    {
        [CmdletBinding()]
        [OutputType([System.Boolean])]
        param 
        (      
            [parameter(Mandatory = $true)]
            [ValidateNotNullOrEmpty()]
            [string]
            $Id,
            [parameter(Mandatory = $true)]
            [ValidateNotNullOrEmpty()]
            [string[]]
            $WindowsFeature
        )
    
        $return=$false
        $InstalledFeatures=(Get-TargetResource -Id $Id -WindowsFeature $WindowsFeature).WindowsFeature
        if($InstalledFeatures.Count -eq $WindowsFeature.Count)
        {
            Write-Verbose -Message "Seems like all features are already installed"
            $return=$true
        }
        else
        {
            Write-Verbose -Message "Some features are still missing. It'll be necessary to installed them."
        }
        return $return
    
    }
    
    
    Export-ModuleMember -function Get-TargetResource, Set-TargetResource, Test-TargetResource
    
    
    
    
    Configuration app0 { 
        param (
                [parameter(Mandatory=$true)]
                [string]$MachineName
               )
    
        Import-DscResource -ModuleNAme cCompositeConfigurationResources
        Import-DscResource -ModuleName cPSDesiredStateConfiguration
    
        Node $AllNodes.Where{$_.Nodename -eq "$MachineName"}.Nodename {
            #region WindowsFeatures
            cWindowsFeatures cWindowsFeatures0
            {
                WindowsFeatures=$Node.WindowsFeatures
            }
            #endregion WindowsFeatures
        }
    }
    
    
    Configuration app1 { 
        param (
                [parameter(Mandatory=$true)]
                [string]$MachineName
               )
    
        Import-DscResource -ModuleName cPSDesiredStateConfiguration
    
        Node $AllNodes.Where{$_.Nodename -eq "$MachineName"}.Nodename {
            #region WindowsFeatures
            cWindowsFeature cWindowsFeature0
            {
                ID = "cWindowsFeature0"
                WindowsFeature=$Node.WindowsFeatures.Keys
            }
            #endregion WindowsFeatures
        }
    }
    
    app0 -ConfigurationData $ConfigurationData -OutputPath C:\DSC0 -MachineName app1
    app1 -ConfigurationData $ConfigurationData -OutputPath C:\DSC1 -MachineName app1
    
    Start-DSCConfiguration -Path c:\dsc0 -Wait -Force
    Start-Sleep 1
    Start-DSCConfiguration  -Wait -Force -UseExisting
    (Get-DSCConfigurationStatus).DurationInSeconds
    Start-DSCConfiguration -Path c:\dsc1 -Wait -Force
    Start-Sleep 1
    Start-DSCConfiguration  -Wait -Force -UseExisting
    (Get-DSCConfigurationStatus).DurationInSeconds
    
    
    
        Directory: C:\DSC0
    
    
    Mode                LastWriteTime         Length Name                                                                                                                                                                          
    ----                -------------         ------ ----                                                                                                                                                                          
    -a----       10/16/2015   2:23 PM          76182 app1.mof                                                                                                                                                                      
    
    
        Directory: C:\DSC1
    
    
    Mode                LastWriteTime         Length Name                                                                                                                                                                          
    ----                -------------         ------ ----                                                                                                                                                                          
    -a----       10/16/2015   2:23 PM           5152 app1.mof                                                                                                                                                                      
    14
    0
    

    这是我的代码和最终测试结果。find 示例需要大约 80 倍的时间来测试资源。因此,将资源数量保持在最低水平并处理代码中的所有内容是值得的。

    • 1
  2. Best Answer
    briantist
    2015-10-15T07:08:25+08:002015-10-15T07:08:25+08:00

    78个WindowsFeature资源很多。您可以尝试通过使用Script资源并自己编写代码(或创建自定义资源)来合并检查。花费的大部分 CPU 时间可能是开销,所以如果你一次检查所有 78 个,它应该会快得多。

    • 0

相关问题

  • 当服务器与 DSC 配置不同步时,有没有办法产生差异?

  • 可以从当前系统构建创建 PowerShell DSC 配置文件吗?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve