
Glances - an easy CLI overview of your system (CPU, mem, I/O) - cgbystrom
http://nicolargo.github.com/glances/
======
boothead
The app looks really nice visually, a few points though:

except Exception: pass

is generally considered to be a code smell. The problem being that when you're
catching all exception information and throwing it away you will never know
what went wrong and where. If you're doing a try/except Exception nested
inside another except Exception then I would humbly suggest that you really
need to think about refactoring and restructuring.

Also, anywhere that you see a repeating pattern, you might be better off
wrapping it in a function or method rather than typing it out each time. For
example in your __update__ method starting at about line 400 you've got pretty
much the same code in two places with just a variable different between the
two.

~~~
JulianWasTaken
Besides upvoting for agreement with all the above (I didn't review the code
but certainly all this is worth fixing if present), I'll also say that you
probably shouldn't recommend people using `sudo` to install your thing in your
README / landing page.

~~~
akldfgj
What is preferred?

~~~
JulianWasTaken
Typically you just leave off the sudo and recommend people to just run pip
install mything. That's the only thing required, unless you have a Python that
has its `site-packages` directory in a place that isn't user writable, for
which people who are in this situation are generally aware of the proper
solution (which I'll mention in a sec anyhow).

You should essentially never use sudo to install any package, since even
_besides_ any security issues, it can clobber things on your system that are
necessary for your OS (by say, upgrading a package that your OS ships with).

I happen to not use my system's shipped Python at all, since I'm on OSX, but
if you are using it, you want to use `pip install --user mything`, no sudo
necessary.

------
sciurus
I will definitely try this out! Just from browsing the webpage it looks nice.

The psutil library doesn't use process accounting, does it? Without it,
Glances will miss processes whose lifetime is within a single check interval.

As always when this topic comes up, I have to give a recommendation for atop.
This LWN article goes into why it is awesome-
<https://lwn.net/Articles/387202/> . The logging and interactive examination
of historical process-level metrics is the killer feature for me. Here are
some screenshots- <http://atoptool.nl/screenshots.php>

------
vutekst
If you like this, you might also like htop, which is similar but markedly
faster at starting up.

~~~
rbanffy
nmon is another favorite of mine.

Of course, nothing beats tools like Munin. I even put business metrics there.

------
CGamesPlay
Just curious, is Glances the python script taking up 100% CPU and 1 GB of RAM
in that screenshot?

~~~
mhurron
Doubtful. I have glances running on a server at home updating on the default
1s timer, it uses 5% CPU. I should probably change that to a longer update
interval, but that server doesn't do much processing so it's not a big
problem.

You can also launch glances.py directly so if it is going to show up on the
process list it will be as 'glances.py' and not just 'python'.

------
mahmoudimus
First, this is cool! Good job!

Would you run this or would you run htop? I'm not sure when I'd use one over
the other.

Maybe someone less dense than I knows more and can tell me what the
differences are?

~~~
AncientPC
htop (and by extension top) is for CPU / memory / load information only.

Normally to get network and disk stats I have to run a combination of dstat,
iotop. A simple screenshot comparison: <http://i.imgur.com/eQPuQ.png>

OTOH htop takes up ~2MB per instance, while glances is taking up ~13MB.
Glances also doesn't have the ability to sort by columns except by CPU/mem %.
You can't kill browse or kill processes from the list either.

~~~
dave1010uk
For anyone who doesn't know, htop actually does a fair bit more. For example,
go to a process (arrow keys or "/" to search), then press "l" to show open
files (with lsof) or press "s" to show a strace. You can also renice processes
and send sigterm or other signals to them.

------
wcchandler
Not sure how this would work from a UI perspective but it'd be nice if you
could add other servers to be monitored. So instead of me having 20+ terminal
windows open, ssh'd into each box and running this app, I could run this app
from a central server that's showing all of them together.

Again, I have no idea how to present that nicely.

~~~
mhurron
If you have 20 servers, it's probably time to move on to a more robust
monitoring solution.

------
losvedir
Looks very nice. I'm a very happy user of iStat Menus for similar monitoring
on OS X.

One thing that iStat menus lacks, and I was hoping Glances had (but appears
not to) is a "top" like viewer for what is using bandwidth. Both applications
only give the overall bandwidth usage. I'll see my bandwidth shoot up hundreds
of Kbps out of nowhere and quickly try to determine what's using it through
combinations of looking at open programs (maybe they're updating in the
background), lsof -i, nettop if I can remember the name, but haven't been
particularly keen on any of them. Any recommendations?

~~~
sciurus
Nethogs (<http://nethogs.sourceforge.net/>) does what you want, but it's
linux-only.

~~~
akldfgj
Not Mac-able because it depends on procfs.

uch a tease:

The excellent Amit Singh rants about how useful procfs is and how Mac doesn't
have it, but then says it's not really needed, and then almost builds it
anyway, then gives up due to unrelated hardware problems:

<http://osxbook.com/book/bonus/ancient/procfs/>

(2003)

This case is one of the more blatant demonstrations showing the superiority of
The Unix Way of "everything is a file. "

------
atechie
This looks good. For cpu and memory checks I find htop to be more lightweight
and functionality wise is pretty good too. It doesn't show disk stats though,
for which something like atop should be used.

------
nodesocket
Glances looks great. Also we love `htop`. <http://htop.sourceforge.net>

------
scott_karana
Pretty sweet. One nitpick: any way of including disk wait?

------
xentronium
You should apt-add glances-stable instead of glances-dev (the latter doesn't
seem to work) on debian/ubuntu.

i.e.

    
    
        sudo add-apt-repository ppa:arnaud-hartmann/glances-stable && sudo apt-get update && sudo apt-get install glances

------
mschonfeld
Seems to run decently on my Mac 10.8

~~~
sfaruque
Could you share how you got this to work on your Mac?

~~~
crcastle
Another way to install this on OSX if you use Homebrew package manager.

1\. Install Homebrew if you don't have it already

    
    
      http://mxcl.github.com/homebrew/
    

2\. Install the brew-pip package

    
    
      brew install brew-pip
    

3\. Add Homebrew's pip path to your PYTHONPATH environment variable (you
probably should add this to some sort of shell initialization file like
~/.bashrc or ~/.zshrc)

    
    
      export PYTHONPATH=$(brew --prefix)/lib/python2.7/site-packages
    

3\. Now install any pip pacakges with Homebrew!

    
    
      brew pip Glances

------
zerd
Nice! I like how it shows all the vital information in very little space. I've
been using nmon for a while, which has some interesting features like
graphing, but doesn't utilize all the screen space very well.

------
trustfundbaby
Seems cool but I could not get this to install on Ubuntu 8 (old I know) ...
even trying to do a wget gave me this error

"ERROR: Certificate verification error for github.com: unable to get local
issuer certificate"

~~~
hardik988
Use wget with --no-check-certificate or change https to http

~~~
kylemaxwell
This seems like such a bad idea... certs exist in repos for very good reasons.

~~~
hardik988
Sure, but if you're simply downloading a shell script (whose source code you
can see) from github (a site you can trust), I don't see the issue.

~~~
Firehed
If it can't validate the cert, it could be the sign of a MITM attack. Likely?
No, but I wouldn't take content with cert issues and run it as root. At least
not without validating it in some other way.

~~~
hardik988
You're right. It very well could be a MITM attack. But I guess you could see
the source code for yourself after you've downloaded it right?

Anyhow, I agree that using --no-check-certificate is usually a bad idea.

------
dazzawazza
Runs well on my FreeBSD 9.0 box. Thanks.

------
ralph
dstat(1) is another of this ilk, also Python. I prefer it because new results
are printed under old, giving history in scrollback. If on a machine where
these aren't available, `vmstat 1' is the standard historical fallback.

------
w1ntermute
You could create a nice desktop widget out of this by piping it to Conky.

~~~
hendry
Or you could just use conky

------
ck2
Is it on yum for centos?

I was playing with htop but it's not really any better than top.

~~~
sciurus
Try atop. There's an overview at <https://lwn.net/Articles/387202/>

It's available through the EPEL yum repository
[http://dl.fedoraproject.org/pub/epel/6/x86_64/repoview/atop....](http://dl.fedoraproject.org/pub/epel/6/x86_64/repoview/atop.html)

~~~
clinth
Not in its documentation, but atop requires root. If you're on a VM somewhere,
you might be happier with htop or glances.

~~~
sciurus
You can run atop without root, it just won't use process accounting so you may
miss some processes (but so would htop and glances).

I'm not sure what being on a VM has to do with anything.

It would be nice if there was a way (e.g. a command-line argument or atoprc
setting) to disable the ability to kill processes from within atop; then it
would be safer for an admin to make it executable as root by regular users.

~~~
clinth
Apologies, I based my comment on atop's README:

    
    
        For interactive use it is sufficient to install ATOP with the command (as root):
    
            make install
    

I wouldn't have guessed the reference to root was optional! Thanks for the
pointer.

------
sounds
Just a thought - ethtool and miitool provide link status for a network
interface. I didn't study the code to see how this gets the network speed, but
if it isn't using something like ethtool/miitool, you might want to.

------
alpeb
This is extremely nice. Thank you!

------
adri9n
Using it now, thanks for sharing!

------
amirf
Wow... Kudos on a great job!

------
anon987
You'll probably want to change the name. HP/UX has similar performance
monitoring tools named Glance and GlancePlus that are unlocked via license
keys. These tools have been around for at least 15 years, they are installed
with the base OS (and thus are well known within the community), and perform
the same functions as your software (performance monitoring).

~~~
batgaijin
Also it looks like the font the interface uses is a bit rounded. I'd recommend
something blockier to prevent litigation.

~~~
srj55
explain?

~~~
mhurron
Threadshitting about Apple.

