Wednesday, December 20, 2006

MyTop without the fuss

People ask me all the time "is there something up with the database?" Of course half the time this means "Is my DNS screwed up again" or "I got a 404 error" but the database always takes the blame. I think this is largely becasue it is the least understood piece of a complicated system and thus a bunch of suspicious voodoo.

In anycase it is a good policy to keep a constant eye on critical database systems so you have an immediate answer to one of these queries. One great tool for this job is MyTop. MyTop is a `top' clone for MySQL

mytop is a console-based (non-gui) tool for monitoring the threads
and overall performance of MySQL 3.22.x, 3.23.x, and 4.x servers. It
runs on most Unix systems which have Perl, DBI, and Term::ReadKey
installed. And with Term::ANSIColor installed you even get color. As
of version 0.7, it even runs on Windows (somewhat).


The problem is it has a few dependancies which may not be installed on the DB machine. Many DBs are firewalled off from the interenet so installing the modules via CPAN or apt-get is not an option.

Here is a command line "replacement" for MyTop. OK it only does 1/2 what MyTop does, but in the UNIX tradition it does that one thing well. Best of allit only needs the watch command and MySQL tools. Try this next time you log onto your mysql server:

watch mysqladmin -u monitor status processlist


You should get a line of server performance followed by a listing of what MySQL threads are running and what they are up to. You will need a monitor user or some user who can connect (only connect and select privilages should be needed).

Try this no fuss no muss MyTop replacement and I thoink you will be hooked.

Saturday, September 23, 2006

9 Ways to save Gas

Here are nin ways you can save gas without spending a lot of money. Most of the methods listed cost you nothing. If you apply a couple of them I bet you will be surprised how much gas and money you can save.

1) Track your gas mileage. You might want to do this before making any improvements to gain a base line. Then you can measure how much improvement you have made. If you have a miles per gallon gauge in your vehicle, but it might be more accurate to measure it the old fashion way.

Next time you go to the gas station fill the tank to the top. Get a receipt and make a note of the mileage. Also make a not of the gallons you put in. Next drive as you normally would. Next time you need gas fill it all the way to the top again. Do the same as last time and make a note of the mileage and the number of gallons you put in.

Now you can compute the miles per gallon you averaged between fill ups. Subtract the mileage from the last fill up from the first fill up to obtain the miles driven. The miles per gallon is the number of gallons you filled the last fill up divided by the miles driven.

Keep the up and watch the improvements as you follow the remaining steps. Also be aware if your milage starts to fall. Maybe then it is time to check over your car.

2) Keep your tires properly inflated. More than half of the vehicles on the road have under inflated tires. You can gain up to %15 by properly inflating your tires. Buy a tire gauge from the local auto store. The gauges on the compressed air centers at gas stations are rarely maintained, often abused, and often deliver very inaccurate readings. The correct tire pressure for your vehicle can be found in the door jam of the drivers side door. The pressure shown on the tire itself is the maximum pressure. Use the pressure shown in the door jam or owners manual of your car. Over inflating your tires may cause them to wear out too soon.

3) Take that junk out of your trunk. Exsess weight is the enemy of your car gas mileage. All that weight requires energy to accelerate and that requires gasoline. That extra weight also causes unwanted wear and tear on your vehicles brakes, tires and other systems. Race car owners go through a lot of extra steps to reduce weight as much as possible, so give your vehicle a break and clean out that trunk.

4) Drive the speed limit especially on the highway. Driving fast creates unnecessary drag which requires more energy to overcome. The gasoline sapping power of the wind grows at a power of two which quickly requires more energy than propelling the weight of the vehicle itself.

5) Remove any roof rack, wings, or other exterior pieces which negatively affect your cars aerodynamics. These pieces like your roof rack or that cool wing on your trunk are actually robbing you of gas mileage. Even ski racks and bike racks disrupt the airflow around your car enough to significantly affect your mileage. This is most noticeable if you drive a lot on the highway where aerodynamics matters more (see above).

6) Get a tune up. A better running car will be more efficient and save on gas. Pay attention to the ignition system; coil, spark plugs, sparcplug wires, etc. A good strong spark will ignite the gas for a better burn. The fuel delivery system is also an area of concern. The carburetor and fuel injection system should receive an inspection. All of this can be done with a basic tune up from a reputable shop. The most inexpensive tuneup package from a chain auto store should suffice. Just make sure they go over the ignition and fuel delivery system. You might pay a little for new spark plug wires if yours are old and cracking. Otherwise stick with the basics. A cracked or leaking exhaust system can through off a fuel injection system and should probably be repaired. Any defective systems in your vehicle can and does affect your gas mileage. Have it inspected and repair it when you get the bread.

7) Shop for the cheapest gas online. There are many sites popping up which allow you to search for the cheapest gas in your area. I find this one GasBuddy to be pretty good. Users post the price of gas in their area and you can then drill down from state, to county and township to find the bast price. Many more site are available from google.

8) Buy your gas when it is cool outside. Gasoline expands and contracts just like any other substance. The ground heats up through out the day and this heats up the gasoline in the stations holding tanks. This makes the gasoline expand. So if you are buying gas in the late afternoon, then you are wasting money. The bast time to buy gas is early in the morning when the ground is cool and the gas is denser. Pumps in Canada and other countries adjust to take this factor into account, but this is not required in America.

9) Easy on the pedal. Take is easy when accelerating from that stop light. Racing the guy in the next lane will only get you to the stop light faster with a lighter gas tank. Heavy acceleration uses more gas than gentle driving. The ideal pace in the city would be gentle acceleration which gets you to the next intersection right before the light changes so you gracefully cruise along your route. If only we all could be so lucky.

Tuesday, January 25, 2005

Basic CMS Software

The web was created to be a two way affair. Scientists perhaps even the rest of us were meant to consume information, link to sources of good relevant information, and ultimately publish our own information. It has turned out to be a mostly one way affair. Most of us read certain sights (most often the same ones) then write an email or two. Once in a while we create "My Pages" or publish a list of links, but this is usually as far as it goes.

Perhaps part of the reason the web is still mostly a one way medium is the lack of good content management systems. Creating web site with navigation, consistent look and feel templating, etc is not that easy. There is a surprising amount of planning and coordination required to create a site structure, add HTML pages in a purposeful way, manage images all with some purpose. Many companies peddle enterprise level software for this purpose. So far I haven't found one of those which really works well enough to justify the enterprise level price tag, that that is a subject for another post.

Personal site management is another story. Blogs are becoming more and more ubiquitous. Blog SW companies and companies that provide blog services (like this one) are getting snapped up by larger more established companies. Is this the sign that people want to produce web content?

Blog Software creates a linear narrative. All blogs are ordered chronologically. Most of them are personal in nature. Some are dedicated to a particular theme or topic. Blog software offers a home page of the most recent posts, navigation by month and year, and search function. Most offer some sort of RSS functionality so others can keep up to date via RSS readers. Many have a blog roll feature which allows the blog author to link to other blogs the author reads or thinks are related to this one. Blogs are chronological, personal, and related to one another in a community.

Wiki software on the other hand is highly hyperlinked. There is no intrinsic order like with blogs although there is often a most recent page in a wiki. Wikis are typically organized around a topic. Search is a primary function for finding pages in a wiki. Browsing is done randomly by users searching and following links. Editing and publish wiki pages is done in a special wiki markup language. Wiki markup is easier than html, offers quite a lot of power (hyperlinks, bold, ordered lists, etc), but it is harder than dealing with blog SW.

Finally applications like Ruby on Rails and Jifty are making it easier for mear mortals to make database driven sites and applications with minimal coding.

The web is coming full circle and returning to its original intention of becoming a two way medium.

In Search of a Good UNIX Desktop

I have been trying to find a UNIX distribution I like for a desktop workstation. I really like BSD (FreeBSD in particular) but I feel Linux is better suited for the desktop because of the availability of binary packages particularly plugins (like Real Audio, Flash, etc), device drivers (video cards, NICs, etc) and other applications like Oracle which I need for the drivers if nothing else.

As for Linux distributions, I really like Gentoo . I use Gentoo at work for many of our linux servers and it's great. I like Portage the package manager and the fact that Gentoo builds from source. It is very customizable and I feel like a macho geek when I boot from CDROM and roll my own machine the way I want.

I was running Gentoo for a while as a desktop machine. I had X, Window Maker, Mozilla, Open Office, and etc. I kept up with system updates via emerge system and emerge world. This worked great until one day it wanted to build GTK. It filled up my /var partition, so I enlarged it (thank you LVM), and it built. A while later it wanted to rebuild X and Mozilla and other large programs. I was happy with the way these programs performed and was not looking for any new features, but of course I would be happy to upgrade if they presented a security risk.

The problem is that although I love the amount of customization and performance tweaks building from source gets you, building large packages like X and Netscape takes too much space and CPU time. I suspect that many times these packages require recompilation and installation it is a new version of the software driven by new features. I will probably want these new features some day and I don't want to be running software that is three years out of date, but most days I just want to get my work done and I recompiling X isn't in the critical path that day.

I used to run Redhat. I actually cut my teeth on Slackware (I actually discovered Linux after searching Usenet for Slackware), but switched to RedHat early on because of the highly touted package manager RPM (seeing a pattern here?). RedHat was great. The installer detected hardware, X configuration was automatic and eventually it became the default Linux distribution. The problems started with upgrading packages and installing packages which weren't necessarily included by RedHat. Cut to the chase and call it dependancy hell. It was also hard to customize exactly what went on the machine. You had three default options; workstation, server, and everything. I usually took everything because the one time I tried workstation I ended up reaching for my install CDs and adding more packages (why are the header files not installed by default?) until everything was installed anyway. RedHat Network was a good idea if not a bit annoying, but later it was just annoying. I don't feel like paying for it (this is like free beer right) and I don't want to upgrade my "profile" every three months. There are other choices.

I never actually tried Debian. It was the first distribution with a truly advanced package manager and it is still truly free (beer and speech), but it is so behind the curve. This might be a feature, but I guess I like being closer to the bleeding edge of software releases.

I made a server machine with LFS (Linux From Scratch) and it was a real eye opener. It was quite a learning experience bootstrapping an OS completely from scratch. I highly recemend building an LFS system for every UNIX Sysadmin or anyone that wants to know more about the real nuts and bolts of UNIX. I would like build another LFS system (perhaps inside an LVM volume and booting it with VMWare or User Mode Linux) and use it as a testing ground for experimenting with new features like new filesystems, RC strategies and better booting methodologies, but it isn't an ideal choice for a desktop workstation.

So right now I am running OpenSuSe. I decided to jump ship from Gentoo to SuSe after it kept choking when updating. SuSe 9.1 came with a 2.6 kernel and other cutting edge features which attracted me. YAST turned out to be a pretty good administrative tool. I have to admit though that it is not as widely supported as Redhat/Fedora or even Gentoo with its fanatical userbase. Running Linux on my Sony notebook is still hit and miss.

Hubbert Peak of Oil Production -- Peak Oil

One seriously bleak but very plausible scenarios for the future. The Peak Oil problem. From the summary page at Hubbertpeak.com:

It is widely accepted that oil is a finite resource; there are basic laws which describe the depletion of any finite resource:


  • Production starts at zero;
  • Production then rises to a peak which can never be surpassed;
  • Once the peak has been passed, production declines until the resource is depleted.


What happens after the peak is reached? The supply of oil decreases while the price increases. The bottom line could be chaos for society (especially American society) which is heavily reliant on oil. This includes heavy industry, manufacturing, agriculture, consumer goods, and retail. Some are predicting the peak could be as early as November of 2005.

Could Peak Oil be another Y2K scare? Perhaps, but consider the man hours that went into reprogramming, testing, and safe guarding systems against possible Y2K bugs in the few years leading up to 2000. Did this preparation save us against the catastrophic failure that were predicted? Maybe the lack of spectacular failures covered up many smaller failures which did happen.

Now look at what kind of preparation is being done to guard against a Peak Oil crisis. SUV's are the most popular selling vehicles on the market. Car manufactures are resisting legislation from ecological groups to scale down the size and appetites of their most popular selling vehicles. The electrical grid seems more unstable than ever with day long blackouts over major portions of the East Coast and rolling blackouts in California. Attempts to create more natural gas burning substations to alleviate the problems in California are met with "Not in My Backyard" protests. In other words it doesn't look like much is being done.

What other signs are there? Gas prices at the pumps are $2.00/gallon here in California. Crude oil prices are up to record highs as well. There are US troops in Iraq, presently one of the most oil rich nations in the world. Current President George W Bush is seeking to open up Alaska and other untapped reserves for exploration.

What should we do?

* Reduce our dependency on oil especially foreign oil. Dump your SUV. Buy a hybrid or other gas miser.
* Invest in energy stock. After the peak there will be a scramble for replacement energy (coal, nuclear)
* Invest in defense stock. There could be battles over remaining (middle east) large oil reserves.
* Research alternative energies. Hydrogen seems the most feasible right now. Solar?
* Consider the availability of local sources of food, water, and energy. Go Canada?

The timing of the oil peak is definitely debatable, but oil is definitely a finite resource and subject to the laws of physics and economics. Economic and/or political conditions may cause us to lessen our dependency on foreign oil in particular and oil in general if we are fortunate. Although I do not predict a doomsday scenario, I do think there will be a change in lifestyle, business, and perhaps society in general as the importance of renewable energy sources increases due to reduced oil production capacity.