CPU, MEM, DISK weekly usage

This topic contains 4 replies, has 4 voices, and was last updated by  Don Jones 1 year, 2 months ago.

  • Author
  • #65926

    Venkata Kalyan

    Wrote a script which will give me CPU, MEM, DISK usage. But, I am not able to get weekly report of this. Can someone help me, what I am missing here:

    $ServerListFile = "C:\Users\venkatak\Desktop\Test\ServerList.txt"
    $ServerList = Get-Content $ServerListFile -ErrorAction SilentlyContinue
    $Result = @()
    ForEach($computername in $ServerList)

    $AVGProc = Get-WmiObject -computername $computername win32_processor |
    Measure-Object -property LoadPercentage -Average | Select Average
    $OS = gwmi -Class win32_operatingsystem -computername $computername |
    Select-Object @{Name = "MemoryUsage"; Expression = {“{0:N2}” -f ((($_.TotalVisibleMemorySize – $_.FreePhysicalMemory)*100)/ $_.TotalVisibleMemorySize) }}
    $vol = Get-WmiObject -Class win32_Volume -ComputerName $computername -Filter "DriveLetter = 'C:'" |
    Select-object @{Name = "C PercentFree"; Expression = {“{0:N2}” -f (($_.FreeSpace / $_.Capacity)*100) } }

    $result += [PSCustomObject] @{
    ServerName = "$computername"
    CPULoad = "$($AVGProc.Average)%"
    MemLoad = "$($OS.MemoryUsage)%"
    CDrive = "$($vol.'C PercentFree')%"

    $Outputreport = " Server Health Report

    Server Health Report

    Server Name
    Avrg.CPU Utilization
    Memory Utilization
    C Drive Utilizatoin"

    Foreach($Entry in $Result)

    if(($Entry.CpuLoad) -or ($Entry.memload) -ge "80")
    $Outputreport += ""
    $Outputreport += ""
    $Outputreport += "$($Entry.Servername)$($Entry.CPULoad)$($Entry.MemLoad)$($Entry.Cdrive)"
    $Outputreport += ""

    $Outputreport | out-file C:\Users\venkatak\Desktop\Test\Test.htm


  • #65929

    Daniel Krebs

    Please, can you elaborate what you mean with "not able to get weekly report of this".


  • #65934

    Venkata Kalyan

    When I run the script, it is giving me the current usage. But I am looking for a week history (cpu, mem, disk usage).


  • #65937

    Richard Siddaway

    The values returned by those CIM classes are point in time values. if you want historical trends you'll have to capture the data a number of times per week to have anything meaningful. In many ways you'd be better off looking at the performance counters and capturing their output

  • #65938

    Don Jones

    Have a look at our eBooks menu. There's a free one on building trend and historical reports that addresses this question exactly and even has some examples along these lines.

You must be logged in to reply to this topic.