DIY简易CPU,内存脚本

 

Name         CPU(p) ----         ------

_Total          100

Idle            100

Skype            12

dwm               6

SnagitEditor      6

 

Name                 CPU(s) ----                 ------

Skype           7000.578125

Thunder          3189.84375

ThunderPlatform     1346.25

firefox          951.921875

explorer          646.46875

 

FreePhysicalMemory ------------------            

859072

 

~~~~~~~~~~~

No matter how much money you have invested in a new computer, sooner or later you will face performance problems.

These problems are usually related with the CPU or the memory. Computers are becoming so complex that you need all the help you can get to find the source of the problems.

The first thing I do when I notice that my computer is not acting as it should is run Task Manager. With this tool you can easily see the usage of Memory and CPU of every process on your computer. I always do the same: look for the processes that are using more CPU and see if there are enough physical memory available.

So, why not have a utility that do the same with just one click and that can be easily found in your Windows 7 Taskbar?

To do this we are going to use one component of Windows 7, PowerShell, that can be also used in other Windows versions.

 

PowerShell is an enhancement of VBScript, which is no more than a scripting language.

Even if you don’t understand what a scripting language is, you can just read this post and you will have your utility running for free in no time.

The information this utility is going to display is the following:

The first list is of every process that is using more than 0 percent of your CPU. This list is sorted by the CPU usage at the moment it’s run. In this case the _Total and the Idle process are not real processes; however, WmiPrvSE is a real process which is using 3% CPU.

The second list displays the 5 running processes that have used more CPU Time. This is measured in seconds. If the computer is running slowly since startup, this is the list you need to check.

The last list is the free physical memory. This cannot be seen as a definitive measure to know the reason for a poor performance but it can be a sign.

Create the Script

So, first we are going to create a folder that is going to have the script that displays the information. I have used c:\utils.

You are going to create a new file in that folder, CheckMemoryCpu.bat in c:\utils.

To do this, open notepad, press WinKey + R, type notepad, and press Enter.

Copy the following text to that file.

@echo off
Powershell -command "&{Get-WmiObject -Query 'Select * from Win32_PerfFormattedData_PerfProc_Process '| Select Name, @{Name='CPU(p)';Expression={$_.PercentProcessorTime}} |  where {$_.'CPU(p)' -gt 0 } |Sort 'CPU(p)' -descending | Format-Table -AutoSize;}" Powershell -command "&{Get-Process | Select Name, @{Name='CPU(s)';Expression={$_.CPU}} | sort 'CPU(s)' -Descending | Select -First 5| Format-Table -AutoSize;}" Powershell -noexit -command "&{Get-WmiObject -Query 'Select * from Win32_OperatingSystem' | Select FreePhysicalMemory | Format-Table -AutoSize;}"

It’s not the intention of the article to explain every part of this script.

Save it as c:\utils\CheckMemoryCPU.bat:

If you don’t use the hyphens it will create a text file, with the txt extension.

Relax, take a breath. You have done the more complicated part. Now we are going to pin the utility to the Windows 7 Taskbar.

Pin the Script to the Taskbar

We cannot pin the recent created file to the Taskbar directly, therefore we have to use a trick.

To do this we create a new shortcut.

Right click on a folder or over the Desktop and select New > Shortcut.

Type cmd /c  c:\utils\CheckMemoryCPU.bat and click Next.

Windows asks for a name, I have used CheckMemoryCPU but you can use other if you prefer. Click Finish.

To change the icon right click over the shortcut and click Properties.

Click Change Icon.

Windows has several files full of very detailed icons. One I like is located in c:\windows\system32\imageres.dll.

Once you find the file you can use the icon you prefer.

Now that you have your shortcut created you only have to move to the Taskbar.

And this is it. Just click it for a quick glance and what is slowing down your PC.

时间: 2024-09-30 21:27:49

DIY简易CPU,内存脚本的相关文章

使用Python实现对Linux服务器CPU内存网络的监控脚本

本文介绍一下使用 Python 脚本实现对 Linux 服务器 CPU 内存 网络的监控脚本的编写.Python 是由 Guido van Rossum 开发的.可免费获得的.非常高级的解释型语言.其语法简单易懂,而其面向对象的语义功能强大(但又灵活).Python 可以广泛使用并具有高度的可移植性.本文 Linux 服务器是 Ubuntu 12.10, Python 版本 是 2.7 .如果是 Python 3.0 版本的语法上有一定的出入.另外这里笔者所说的 Python 是 CPython

脚本-linux获取CPU内存占用信息

问题描述 linux获取CPU内存占用信息 想弄个脚本定时记录,linux 占用最高CPU 内存的进程. 生成友好阅读的日志,或者将查到的信息追加到日志文件中也行. 然后放到crontab里去执行. 但是有个前提,不使用ps命令. 网上找了一堆,可以使用这个方式,但是我不能使用PS命令,请问有什么办法吗: linux下获取占用 CPU 资源最多的10个进程,可以使用如下命令组合: ps aux|head -1;ps aux|grep -v PID|sort -rn -k +3|head linu

如何开发获取当前计算机cpu,内存,硬盘,进程,网络流量等使用率或传输情况

问题描述 如何开发获取当前计算机cpu,内存,硬盘,进程,网络流量等使用率或传输情况 如何开发获取当前计算机cpu,内存,硬盘,进程,网络流量等使用率或传输情况,参考什么书籍或知识点! 解决方案 http://download.csdn.net/detail/ww516617119/7178777 解决方案二: google wmi 性能计数器 <你用的语言> 结果就有了 解决方案三: 楼上这个连接有点厉害,我觉的吧得深入了解win32 sdk,学的快的话,还是调用别人的库 解决方案四: WM

统计和分析系统性能【IO CPU 内存】的工具集合

统计和分析系统性能[IO CPU 内存]的工具集合 blktrace http://www.oschina.net/p/blktrace 获取磁盘写入的信息 root@demo:~/install/percona-toolkit-2.2.1# debugfs -R 'stats' /dev/sda1 debugfs 1.41.11 (14-Mar-2010) debugfs -R 'stats' /dev/sda1|grep Block debugfs 1.41.11 (14-Mar-2010)

win7系统使用pptv看电影占用CPU内存高达100%怎么办

  win7系统使用pptv看电影占用CPU内存高达100%怎么办?说起pptv相信大家都不会陌生了,pptv是一款全球安装量最大的网络电视,拥有高清视频,一些win7系统用户使用pptv看电影时,发现pptv占用大量的CPU内存,已经高达100%,如果这时候打开其他程序很容易出现卡机现象,而且系统运行速度也会变慢很多,怎么办呢?这时候我们需要对pptv进行一些简单的设置,下面一起看看具体的解决方法. 1.如果我们不是从官方网站下载的pptv的话可以到官方下载最新版本的pptv了; 2.如果是官

windows-Windows服务器如何使用可以达到最佳使用率(CPU,内存等资源)?

问题描述 Windows服务器如何使用可以达到最佳使用率(CPU,内存等资源)? Windows服务器如何使用可以达到最佳使用率(CPU,内存等资源) A:服务器 Windows服务器配置信息如下: CPU:Intel(R) Xen(R) CPU E5-2403 0 @ 1.80GHz 1.80Ghz(2处理器) 内存:32.0GB 硬盘:2T 带宽:50Mb B:服务器 Windows服务器配置信息如下: CPU:Intel(R) Xen(R) CPU E5-2403 0 @ 1.80GHz

使用.NET FrameWork获取CPU,内存使用率以及磁盘空间

原文:使用.NET FrameWork获取CPU,内存使用率以及磁盘空间       在以前,我们想获取CPU,内存等信息就不得不借助win32 API来实现.但现在,.NET FrameWork已经把这些API封装到.NET类库中了,所以我们可以借助.NET类库很轻松的获取这些信息.首先,介绍几个要用到的类:      PerformanceCounter:表示windows NT性能计数器组件      ComputerInfo:提供用于获取与计算机内存,已加载程序集,名称和操作系统有关信息

linux系统使用python获取cpu信息脚本分享_python

linux系统使用python获取cpu信息脚本分享 复制代码 代码如下: #!/usr/bin/env Pythonfrom __future__ import print_functionfrom collections import OrderedDictimport pprint def CPUinfo():    ''' Return the information in /proc/CPUinfo    as a dictionary in the following format:

一个用了统计CPU 内存 硬盘 使用率的shell脚本_linux shell

复制代码 代码如下: #!/bin/bash#This script is use for describle CPU Hard Memery Utilizationtotal=0idle=0system=0user=0nice=0mem=0vmexec=/usr/bin/vmstatwhich sar > /dev/null 2>&1if [ $? -ne 0 ]then  ver=`vmstat -V | awk '{printf $3}'`  nice=0  temp=`vmst