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("%-16s\t %8.0f %2s\n",$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 %2s\n","Total Memory: ",tot,"KB")}'