Wednesday, May 29, 2013

Easy-to-check systems monitoring on graphical Linux workstations

Leveraging Linux Virtual Consoles

Your "X Window" interface is rendered on only one of a handful of available virtual consoles.  Depending on your system and resources, you may be able to run multiple separate X Window interface.  But we won't dive into that here - let's look at what can be done with TEXT on your other virtual consoles.

Virtual console 1 can be switched to with control-alt-F1 - same for 2,3,4,5,6,7, etc.  Usually X is on virtual console 7 or so.

Console 1's going to display kernel boot messages, system messages etc. and almost always should have a login interface running on it, so you can login as "root" there if needed.  If you need to boot to single user mode for example you'll be interacting on that console.  It'd be best not to interfere with that.  Not saying it can't be done, but... you're experimenting with a crucial resource.

If you want to run text-based monitoring on a Virtual Console, I'd recommend running the monitoring on one of the virtual consoles 2..6  Then, just tap ctrl-alt-F2 (or 3, 4, 5, or 6- whichever you choose) to switch to that VC, check on resources, then ctrl-alt-F7 and you're back in X.

What monitoring tool to run on VC-2?  I recommend running 'top' on that virtual console. 
 
With Ubuntu, you can replace the "getty" commandline in /etc/init/tty2.conf with top.

I've done this myself - it works great.
# grep exec /etc/init/tty2.conf
exec /usr/bin/top < /dev/tty2 > /dev/tty2 2<&1

I replaced the line in the above file that usually execs "getty" with one that execs "top" instead.  I'm sure there's some way to get that to take effect right away but I just rebooted and it worked.

Once nice aspect of top is that you can control its refresh time.  The "s" subcommand can be used to sample more quickly (try .3 for example) or less quickly (maybe, every 15 seconds).

Because of the nature of how init will respawn the program, you can quickly return to once-per-second monitoring by exiting with q.

Another trick - to get top to stop altogether for a while, hit "h" for help - it'll display a help screen and while it's displaying that, it's not doing any monitoring.

Give it a try.  There are other monitoring tools of course - and there are also a few more VCs available for your use.  With a bit of tuning and thinking ahead, when your Linux system "bogs down" you'll be able to quickly assess why.

No comments:

Post a Comment