PrintLogo

Grabbing Top Stats Remotely




One particularly useful tool for systems administration is top. One thing you may not be aware of, is that you can output the information top provides to a file. You may also not know that you can run commands like this remotely via ssh. Here is a short script that demonstrates this:

#!/bin/sh
/usr/bin/ssh user@domain.com "top b -n 1 > /tmp/topstats";
/usr/bin/scp user@domain.com:/tmp/topstats /tmp/topstats

The b -n 1 is the number of iterations. If you use -n 3, you will get three different sets of stats. The default refresh is 5 seconds, so this would take 15 seconds for three iterations.

u-1@srv-1 stats $ ./gettop.sh
topstats             100% |*****************************|  4241       00:00





This article comes from NetAdminTools:
http://www.netadmintools.com/

The URL for this story is:
http://www.netadmintools.com/art223.html

Copyright 1997-2007 NetAdminTools.com. Read our Terms of Use.