OS Performance monitoring (PowerShell)
Another useful powershell code snippet, monitoring the OS performance...
Code Snippet:
$computer = "."
$perf = get-wmiobject -class "Win32_PerfFormattedData_PerfOS_System" -computer $computer
$uptime=$perf.SystemUpTime/3600
write-host "Performance Stats: "
write-host "Processes", $perf.Processes
write-host "Threads", $perf.Threads
write-host "System Up Time `(hours`)", $uptime.tostring("00.0")
write-host "Alignment Fixups/sec", $perf.AlignmentFixupsPersec.tostring("###,##0.0")
write-host "Context Switches/sec", $perf.ContextSwitchesPersec.tostring("###,##0.0")
write-host "Exception Dispatches/sec", $perf.ExceptionDispatchesPersec.tostring("###,##0.0")
write-host "File Control Bytes/sec", $perf.FileControlBytesPersec.tostring("###,##0.0")
write-host "File Control Operations/sec", $perf.FileControlOperationsPersec.tostring("###,##0.0")
write-host "File Data OperationsPersec", $perf.FileDataOperationsPersec.tostring("###,##0.0")
write-host "File Read Bytes/sec", $perf.FileReadBytesPersec.tostring("###,##0.0")
write-host "File Read Operations/sec", $perf.FileReadOperationsPersec.tostring("###,##0.0")
write-host "File Write Bytes/sec", $perf.FileWriteBytesPersec.tostring("###,##0.0")
write-host "File Write Operations/sec", $perf.FileWriteOperationsPersec.tostring("###,##0.0")
write-host "Floating Emulations/rsec", $perf.FloatingEmulationsPersec.tostring("###,##0.0")
write-host "Percent Registry Quota Used", $($perf.PercentRegistryQuotaInUse/100).tostring("P")
write-host "Processor Queue Length", $perf.ProcessorQueueLength
write-host "System Calls Persec", $perf.SystemCallsPersec
write-host ""
Sample Output:
Performance Stats:
Processes 66
Threads 573
System Up Time (hours) 24.8
Alignment Fixups/sec 0.0
Context Switches/sec 9,857.0
Exception Dispatches/sec 0.0
File Control Bytes/sec 0.0
File Control Operations/sec 0.0
File Data OperationsPersec 1,232.0
File Read Bytes/sec 3,943,044.0
File Read Operations/sec 1,232.0
File Write Bytes/sec 0.0
File Write Operations/sec 0.0
Floating Emulations/rsec 0.0
Percent Registry Quota Used 9.00 %
Processor Queue Length 0
System Calls Persec 51752
If at first you fail, call it version 1.0
No comments:
Post a Comment