CPU, MEM, DISK weekly usage

Tagged: 

This topic contains 4 replies, has 4 voices, and was last updated by Profile photo of Don Jones Don Jones 2 months, 2 weeks ago.

  • Author
    Posts
  • #65926
    Profile photo of Venkata Kalyan
    Venkata Kalyan
    Participant

    Hi,
    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 += ""
    }
    else
    {
    $Outputreport += ""
    }
    $Outputreport += "$($Entry.Servername)$($Entry.CPULoad)$($Entry.MemLoad)$($Entry.Cdrive)"
    }
    $Outputreport += ""
    }

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

    -Kalyan

  • #65929
    Profile photo of Daniel Krebs
    Daniel Krebs
    Moderator

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

    Thanks,
    Daniel

  • #65934
    Profile photo of Venkata Kalyan
    Venkata Kalyan
    Participant

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

    -Kalyan

  • #65937
    Profile photo of Richard Siddaway
    Richard Siddaway
    Moderator

    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
    Profile photo of Don Jones
    Don Jones
    Keymaster

    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.