human choroinic gonadotropin

GGTSdotNET

The notes of a madman

Listing top 5 memory consuming apps on a remote windows machine

Posted by grigsby on March 17, 2010

I recently had the need to be able to see what applications were consuming the most amount of memory on a remote windows system. I only needed to do this on demand, and it was not something that I needed to do all the time. To get the view I wanted I resorted to using a combination of pslist from the PStools package and the *nix like environment for Windows Cygwin. Below is the shell script i came up with. I’m sure somebody could make it cleaner, but this is what I found that worked. I post this here for my own reference and as a gift to the world (I know, it’s the thought the counts).


#!/bin/bash

# Printf description :
# %-16s 16 character text field, left justified.
# t Tab
# %8.0f 8 character, numberic field, no decimal
# %2S 2 Character text field, right justified.
# ,$1,$4,"KB" First field from awk, Fourth Field from Awk, Text "KB"
# $4 is the amount of memory used by the application or its "working set"

echo ""
echo "Top 5 memory usage on egi6w008"
echo""
/cygdrive/d/workdir/bin/pslist -m \\hostname| awk '{printf("%-16st %8.0f %2sn",$1,$4,"KB")}'| sort -k 2,2n | tail -n5
echo ""
/cygdrive/d/workdir/bin/pslist -m \\hostname | awk '{tot=tot+$4} END {printf("%14s %8.0f %2sn","Total Memory: ",tot,"KB")}'

Add A Comment