Tuesday, June 23, 2009

Information Please

An article on Lifehacker featured an interesting utility called iotop, which gives a birds eye view of what your hard drive is up to. The commentors mentioned a couple of other interesting tools, although many seemed to be confused as to what iotop is measuring as opposed to some of the other utilities. I thought I'd do a quick write up about a few of these command line machine status reporters.



The most basic status tool is, of course, ps. In number of options, it competes with ls for most in the Linux manual! This is because it has 3 different command "modes" - UNIX, BSD and GNU versions, and all are usually mutually incompatible. ps gives you a basic snapshot of what programs are being run.



While ps is always around, the rest of these usually need special installation, although the next one, top, is almost always around. top adds more information but, most importantly, runs in a curses display, so it stays around and updates itself, giving you a constant view of what your CPU is up to. You can see it change dynamically as programs work your CPU harder. Use the 'h' key to display a help screen, giving you more sorting and display options.



View top in action


The most flexible version of ps is htop. This gives you even more information, more sorting options and an even better curses display. Again, use the 'h' command to get a full help display. I especially like htop for how it displays the complete command line.



View htop in action


iftop uses a top-like display to show you what is going on in your network (your interface). It displays the various network requests, who is making them and how much is coming and going on each. This is an especially useful command on a server, as you can see what your web server is working on, and keep useful totals.


View iftop in action



iotop again uses a top-like display to give you a real time, in-depth view of disk I/O. This is an especially useful diagnostic tool if you notice your hard disk is "thrashing" - ie, the red access light is doing a disco-like strobe effect and you're wondering who is doing all that hard drive dancing.



View iotop in action


saidar is another monitoring tool that shows a nice overview of everything going on in your computer. Useful information like CPU load, swap usage, disk space, and network traffic. Good quick clean overview.


View saidar in action


Next time, perhaps I'll take a look at some of the graphical system monitoring tools available for KDE and GNOME. If you have any other favorite terminal-based monitors, please mention them in the comments.




Wednesday, June 10, 2009

Screencasting the Creator

I'm trying out Nokia's fancy new Qt Creator IDE for developing Qt 4.5 applications. Looks pretty nice, even if Qt itself is a little fugly, given all the weird macros it uses to get its work done. Maybe this IDE will shield me from the worst of it?



Anyway, I'm going through the recommended book (C++ GUI Programming with Qt 4, Second Edition) on Safari and am finding it a bit of a chore. It is working with the older GUI design tool, Qt Designer, and not Qt Creator. As far as I can tell, there isn't much introduction material for Qt Creator. So I'll try and puzzle out the answer to some of the oddities and document them here.


So what I've done is create my very first screencast! I am using recordMyDesktop via its GUI interface qt-recordmydesktop, which works pretty well. I had the usual audio hassles, trying to figure out how to set up the mic for recording. I could never get it to use my USB headset, but luckily this lovely Plantronics USB headset comes with regular 3.5mm jacks that plug into a USB adapter, so by plugging the jacks into the back of the audio board, I could get it to record after trying various options in KMixer.


Coincidentally enough, the most recent issue of Linux Format magazine has a Roundup of screencasting tools. Their pick is the closed source DemoRecorder but it doesn't seem to offer anything that the free recordMyDesktop offers besides the ablity to save in multiple formats. recordMyDesktop only does Ogg Vorbis video, but all the upload sites convert it to Flash video anyway, so I don't really care.



I had a few problems getting the screencast to work. First off is a bug in Qt Creator, where if you rename the main widget, the compiler gets all weirded out. Took me a while to figure that one out. The workaround is to rename it from the Project creation dialog.



Then I was having problems getting the post-recording conversion to work. It would only do some of it, or not a complete audio track. Not sure what the work around was for that. I either got lucky finally or, by just leaving the computer alone until the process was done made it work. Finally, I got the 6 minute screencast to work.



I am using blip.tv to host the video. I've heard it does the best job at conversion and has the fewest restrictions on formats, as well as giving the most options for display. So, without further ado, is my very first screencast:







Wednesday, April 29, 2009

Pick The Best

The latest issue of Linux Format magazine has a very nice article on how to pick the best distro. This is a subject rife with controversy, but they do a very nice job of remaining bias free and objective. By listing a wide variety of user types, you can pick your area and see what they recommend.


I do have a couple of nits to pick with it though:



  • While Ubuntu has its strengths (the biggest of which is the vast and active user community), I think its choice of GNOME as its default desktop is a mistake. GNOME is quirky and quite different from Windows and offers up too many gratuitous changes from the "norm" for it to be a newbie friend face. KDE is much more "normal" in that respect.

  • I also disagree with the admittedly tepid recommendation to use the 64bit version of a distro. Again, just enough annoyances with not enough payback to discourage a newbie.



That being said, I enjoyed reading it and am itching to try a new distro. Still perfectly happy with my openSUSE, but I have a free 40gb partition just begging for some play time:) I did use their recommendation for Qimo as a "family friendly" distro and installed it on my daughters' computers, as WinXP was behaving very badly. They have really enjoyed the pre-installed games and creativity software. I just wish there was better support for it besides comments on a blog post. And I think it should pre-install Flash support, as that is the other big destination for the girls, Flash web games.



Now maybe try Fedora 10, which was included on a recent Linux Format DVD? Or Mandriva? or....



How to choose the best Linux distro for you | TuxRadar



Wednesday, March 11, 2009

import this


$ python
Python 2.5.2 (r252:60911, Dec 1 2008, 17:47:46)
[GCC 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision 135036]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
>>>



Tuesday, March 10, 2009

Magazine Heaven

My favorite Linux magazine, Linux Format (out of the UK) has some interesting news:




  • A very nice podcast, which can be found at Tux Radar. Three editors talk about a wide range of Linux subjects. I have been finding it very entertaining, even if they don't have their RSS feed tags quite set up correctly.

  • They offered up a free download of their issue 116, the KDE issue. The zip file with the 3 torrents (hires, lowres, and ISO) for it is here. Very nice job!

  • And most excitingly, as they announced at the end of their latest podcast, a deal on the subscription! It's hard to justify the US$130 in these tough economic times, even if it is the best Linux magazine going. But if you follow this link, you can subscribe for "only" US$95, which is a pretty good deal for 13 issues. Linux Format sub deal



Every issue is just jammed packed with great info, from news to in depth technical tutorials. I love the mix of articles, and I love the layout. Very clean look, well edited and good stories. I highly recommend it!



Linux Journal also recently had a special ($12 for 12 issues) but I'm pretty sure that was just a day long one. However, they do have a contest to give out some free subscriptions to the digital version. You can get more details here.




Thursday, February 26, 2009

Stale Lock

I did a bad thing the other day and have just barely lived to tell about it. I turned of my Linux box without shutting down. All you Linux & Unix veterans know my horror when I realized what I had just done. I hit the shutdown button and, when the screen briefly blanked out before going into the shutdown graphic, I hit the power button on my power strip to turn it all off. Oh oh, says I...



Now, I never used to shut off my machine(s). The only time I have ever had a hardware problem (he says, knocking on wood), is when I was turning on a machine. Given that, and some daemons that like to run in the background at night, I usually left my computers turned on.



But I have started to get more worried about power consumption, including 'zombie' electronic devices, I have started to power down all the computers in the house before I head to bed. It makes me feel all virtuous and green. But the other night I nearly paid dearly for my greeness.



When I turn the computer on the next morning, it booted to a text screen. Somehow, I just wasn't surprised. But I couldn't figure out why. dmesg told me nothing, nor did /var/log/messages. But when I tried to 'startx', I got a complaint about .X0.lock and a "stale NFS handle". How odd, as I don't use NFS at all.



Well, this file proved to be very difficult to get rid of. See, when your X server starts up, it creates this file to prevent X from running twice. So at startup, it checks to see if /tmp/.X0.lock exists. If it doesn't, X will create it and carry on its merry way. If it does, it assumes X is already running and will complain, albeit in a very obscure fashion. The usual solution, if you're sure there isn't a X server already running, is to just delete it. But 'stale NFS handle' files are a real pain to delete, especially if they aren't really NFS handles!



I had an inkling that I needed to run fsck on the partition, but that's a problem on the root partition. Luckily, I have several other Linux partitions I can boot into, so I just booted up my openSUSE 11.1 and tried fsck from there. Haven't made the jump to 11.1 yet, as too many of my packages don't quite work right, or I don't like the newer versions (I'm talking to you, Eclipse Ganymede and Amarok 2). But fsck didn't find anything wrong either, so I was stuck for ideas.



But then I read about the force option for e2fsck, so I ran that. Voila! A few odd errors, but most especially an odd error with .X0.lock. So I mounted the filesystem while still in 11.1 and was finally able to delete the .X0.lock file. And the reboot back into my 11.0 openSUSE went swimmingly!



So the lessons learned:




  1. If X won't start, try removing the lock file found at /tmp/.X0.lock

  2. If you can't remove a file because there is a bogus 'stale NFS handle' error (and believe me, it doesn't let you do anything with it), try forcing an fsck on the partition





Wednesday, February 25, 2009

Big Bad SATA


So Best Buy had the much maligned Seagate 7200.11 Barracuda 1.5 terabyte hard drive on sale for a mere US$130. Given a couple of Best Buy rebates, I just couldn't resist picking it up for just a little of US$120 - incredible! I immediately went to the Seagate page to see if my drive had a firmware update, but luckily(?) it didn't so I was all set to install it.



Man, I just love the SATA connectors! Gone are the days of bending one of the gazillion little pins, or, even worse, getting it plugged in backwards. And no more slave/master settings either. Slid it into my tower, plugged two small cables into it and fired up the machine. It was immediately noticed and so now I needed to figure out how to partition it.



I created one 650gb partition for backups. I really truly am going to get a backup strategy implemented, especially now that my wife has her own laptop and is working from home. I'm going to run a Bacula server on my machine and Bacula clients on my box, my work box (WinXP) and my wife's Vista laptop. So I want to have plenty of room for storing select backups. I created this as an ext3 partition, with no access time tracking (for performance reasons), using YasT2's very easy Partitioner.



The other partition was a little more problematic. I want it to be the home for all our media - songs, movies, pictures. And I'll run a media server here. I have had real good luck with Mediatomb but Andrew Wafaa convinced me to try Coherence, a true DLNA/UPnP framework. It looks pretty neat - great, just what I need another project!



I wanted my media partition to be readable by WinXP as well as my openSUSE (and, in general, Linux) boots. I just checked so I know differently now, but I also thought that sharing a volume via Samba would require it to be a Windows partition as well. Turns out, that is a by now obvious bad conclusion, as Samba will share Linux partitions just fine. But as I wanted to use it natively as well, I still needed a Windows partition.



I was shying away from an NTFS partition, as I just wasn't sure how stable the NTFS-3G implementation was, so I started with a FAT32 partition. The biggest drawback with FAT32 is its 4gb max file size. It is also, I think, less efficient than NTFS in its structure, so it would use more space for such a large (nearly 750gb) partition. Once again, the Yast Partitioner worked great and was nearly instantaneous for FAT32 (or vfat) partition.



Now I wanted to move my ripped music CDs over to the new "mediax" partition (I couldn't use /media, as KDE uses that). As I wanted to preserve the time information, I used rsync:



$ rsync -auv Music /mediax
[lots and lots of]
/bin/cp: preserving times for `/mediax/Music/podcasts': Operation not permitted


That was odd. So without thinking about it too much, I decided to take the plunge and try out NTFS, as openSUSE 11 comes with read/write support "out of the box". So I reformatted it as NTFS (after rebooting into Windows, as Partitioner doesn't format NTFS) and tried again.



This time, it worked pretty well. openSUSE uses the "standard" NTFS-3G driver. There is an odd caveat about a slowdown with Amarok, my prefer music player, but it seems to have to do with writing, not reading, which I don't do much, so no big deal.



But I ran into a problem because of my change of heart. Because I had originally formated it with FAT32 (vfat) using the Partioner in YaST (openSUSE's graphical admin tool), and because Partioner doesn't support NTFS formating, I forgot to change the /etc/fstab file, so on reboot, it didn't work correctly. I then compounded errors by changing the 3rd column to being merely 'ntfs', which meant I was still getting the weird cp "Operation not permitted" error, which had me really confused. But I checked out swerdna's page on using NTFS on Linux and finally the light dawned on Marblehead. I changed the filetype to 'ntfs-3g' and now all is good and I can use my music collection whether I'm in Linux or (shudder) have to reboot into Windows.