Disk and Memory Usage Scripts

At times I like to check my levels of disk and memory usage and it’s more available for me at times for me to do it from the command line. Therefore, I created two scripts for them:

$ devtop 
Filesystem  Size  Used  Avail  Use%  Mounted
/dev/sda1   291G  101G  187G   36%   /
/dev/sda2   166G   38G  121G   24%   /home

$ memtop
PROGRAM          %MEM  #MEM
firefox          14.0  1049.7 MiB
gnome-shell      2.2   165.84 MiB
thunderbird      1.9   143.773 MiB
gedit            0.8   63.8555 MiB
nautilus         0.6   44.9961 MiB
Xorg             0.5   38.5039 MiB
gnome-terminal-  0.3   28.8164 MiB
keepassx         0.3   27.6406 MiB
tracker-extract  0.2   21.1992 MiB

Both script are part of my genscripts-git that is in the Arch Linux User Repository.

About Todd Partridge (Gently)

Good times, good people, good fun.

Posted on 2012-08-02, in Command Line, Script. Bookmark the permalink. 5 Comments.

  1. Hi, thanks for the scripts!

    I’ve modified memtop a little bit — added a header with the overall memory info. Here is my version: https://gist.github.com/3243054

    BTW, there is a similar script to your devtop: http://freecode.com/projects/pydf It does about the same thing, but also adds colors.


    • Nice work on the script, I could see how overall memory usage could be useful.

      Had not heard about pydf before, thanks for bringing that to my information.

      Updated script to a more read able formatting, and output.

  2. Two things regarding ‘memtop’:
    1. I see ‘python2’ in the output – is it some kind of script / app? How do you know which one is it? ;P

    2. ‘head -n 10’ will print the first 10 lines (and it happens to be the default so you can use plain ‘head’). If you want top ten processes, you should use ‘head -n 11’, as did the author. Either way, that script doesn’t print “top five applications” like you say in the comment in the script :-)

    • Good points.

      Yeah, that’s python2 a programming language a lot of programs use :) (see it a lot on GNOME 3 even).

      Yeah, I knew about head by default showing 10 lines; however, I decided to define it because I thought I (or others) may want to change it. The, er, five applications, thing was my bad, oops, thanks for pointing it out.

  3. nice handy scripts you got there :). I have the following alias for getting the top25 most hungry ram proccesses:

    alias top25='while read command percent rss; do if [[ "${command}" != "COMMAND" ]]; then rss="$(bc <<< "scale=2;${rss}/1024")"; fi; printf "%-26s%-8s%s\n" "${command}" "${percent}" "${rss}"; done < <(ps -A --sort -rss -o comm,pmem,rss|head -26)'

    anyhow, just keep up to great work, there are great articles on your blog.

    take care,

    – d

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 58 other followers

%d bloggers like this: