dufault.info

Ramblings of a phone weenie, Linux sysadmin, and other things geeky

22  07 2008

The Wordpress Google Analytics plugin screwed me

I just noticed that after upgrading the Google Analytics plugin for Wordpress, my settings weren’t carried over, and that Google Analytics hasn’t been able to track my pageloads.

:(

I guess it should have squawked someplace that it wasn’t configured… that’d of been nice.  It’s not like the tracking data is critical, but I was definately starting to wonder why my traffic halved one day, and dried up the next.


19  07 2008

The Linux Magic SysRq key

I find it shocking how many people don’t know about this neat Linux key combination that let’s you execute various low level commands regardless of the system’s state (as long as it’s running and hasn’t panicked.)

From the Wikipedia page:

It is often used to recover from freezes, or to reboot a computer without corrupting the filesystem.

How it works: you press a key combination consisting of Alt, SysRq and your command key, and the Linux kernel will trigger that action, regardless of system load. This is a great way to recover a system quickly without triggering a hard reboot, as disk fscks can be lengthy, and involve data loss. Not to mention, the ability to sync the cached data from RAM to the disk is great, especially with computers running database services.

How to enable it? Easy, just add this to /etc/sysctl.conf on your Linux-based system, and run sysctl -p for the settings to become active:
kernel.sysrq = 1
# Copy paste command for the lazy...
$EDITOR /etc/sysctl.conf
sysctl -p

The best way to recover a system will involve multiple commands, this is taken from the Wikipedia excerpt:

unRaw (take control of keyboard back from X),
tErminate (send SIGTERM to all processes, allowing them to terminate gracefully),
kIll (send SIGKILL to all processes, forcing them to terminate immediately),
Sync (flush data to disk),
Unmount (remount all filesystems read-only),
reBoot. These keystrokes should be entered a few seconds apart.

For more information about this nifty Linux-only feature, check out Wikipedia

Source: http://en.wikipedia.org/wiki/Magic_SysRq_key


17  07 2008

Scripts To Make Administrating Lots of MySQL Databases a Little Easier

This post is probably only helpful to a system administrator of large shared servers that happen to have a lot of MySQL databases.

These scripts are meant to administrate all of the databases and tables on a single server currently, I might refine them to also work only database or table name’s supplied.

One of the scripts, tableCheck, will access mysql using the username and password in /root/.mysql.cnf, and run a “check table $name” command, and error out if a table has been corrupted.

Another of the scripts, probably a bit heavy-handed, tableRepair, doing the same thing as tableCheck only running a repair query.

tableOptimize runs a “optimize table $name” query on all tables available, which is nice to do occasionally to speed up queries due to nasty things like table fragmentation.

Lastly, findLargeDatabases is a simple script that’ll show you the largest databases you have in order of size, so you can refine your efforts to optimizing those.

Here’s the goods!
scripts.tgz


17  07 2008

Forcibly Triggering a Kernel Panic on Linux

This might sound strange, as people usually want to fix or prevent these from happening, I’m trying to test/ create a method of logging kernel panic messages to a remote logging server. All of the existing tutorials I found on the net were for Linux 2.4, or were incomplete.

My method involves creating a Linux kernel module, that when it’s inserted, causes the panic.

Here’s my my tarball: (includes the module source and a makefile)
kernelpanic.tgz

Here’s how to compile it: (you’ll need the the kernel sources installed at /usr/src/linux of your current running version)
make -C /lib/modules/$(uname -r)/build M=$(pwd)

After it’s done compiling: (WARNING, THIS WILL CRASH THE MACHINE, and you need to be root)
insmod panic.ko

To recover from the crash, just reboot your computer.

Let me know if this is any good in the comments, and any improvements I can make!

Should I obfuscate the source code at all to prevent misuse of this? Since you need root access to insert a kernel module, and anyone with root access can halt the machine, I find the ramifications of releasing this information moot. Comment!

Here’s where I found a quick howto on creating a Linux 2.6 kernel module:
http://tldp.org/LDP/lkmpg/2.6/html/x279.html


15  07 2008

Gnome Do

I use Ubuntu at work, and today one of my coworkers linked me to Gnome Do:
https://wiki.ubuntu.com/GnomeDo

I remember seeing it a few weeks ago, but was busy with something and brushed it off.  Now, I’ve installed it and played with it some — it’s awesome.  Kind of like launchy for Windows, but on steriods.

Give it a try!


15  07 2008

A Wordpress Gripe

I updated to Wordpress 2.6 today, and again, I’m amazed at the tediousness of it. I’m suprised that they haven’t mastered a good way of doing this. For example, the guys at SMF have a system in place that either remembers or you type in your FTP password, and it updates your SMF installation. Granted, Wordpress now has this functionality for updating plugins, but not the base system yet.

What gives?


15  07 2008

SD write support on the Android port to the Vogue

Today, Martin Johnson released something I’m been waiting a long time for in his progress of porting Android to the Vogue — SD controller support!

I haven’t tested this yet, I’ll be playing with it tonight when I get off work.

Here’s the notes from Martin:

The SD driver now works, this means you don’t have to run everything from an initrd and your settings will be saved across reboots. It also means that the [HTC] titan should boot (though I haven’t tried it and the keyboard won’t work), titan owners let me know. To use the new version, download the android.zip file below. In it are 6 files, put system.img(128M) and data.img(128M) onto the sd card in your phone (the “\Storage Card” folder), put zImage, default.txt, haret-0.5.1.exe and initrd.gz anywhere you like and then run haret. The data.img file holds your settings and applications, it’s just an ext3 filesystem so on a linux box you can mount it to add applications and import contacts etc..

Here’s the link to his homepage:
http://it029000.massey.ac.nz/vogue/

Man, I can hardly wait to play with this tonight.

**UPDATE**: Doesn’t seem to work with my 4GB SDHC card, init dies and loads a shell. I saw a mention of sdhc it in the driver messages though.  Works fine with my 1GB card.
**UPDATE**: Martin updated his kernel driver to be 4 times faster, and included sdhc support.


11  07 2008

Missing Google Maps Mobile v2.2.0 on a Windows Mobile phone

This is just a gripe that Google hasn’t released Google Maps Mobile v2.2.0 for a Windows Mobile-based phones or pocket PCs yet.  The version has been out for the Blackberry’s for weeks… Where’s my update!?


10  07 2008

Compiling a Shell Script To Obscure the Source

Well, there’s been a few times that I’ve written a shell script that was really neat.  Something that other people would have paid for a copy of. (I was too lazy to rewrite it in another language.) Up until now, I wasn’t aware you could compile a shell script, in the attempts from keeping people from pirating your work. Apparently I’ve head my head stuck in the sand.

Here’s the link to the manual page for it: shc

Here’s the link to the tool: shc.tgz

I’ve tried this with bash and sh scripts, it seems to work great.

Also, before you think that it’s 100% secure (nothing really is) there’s already been a audit of the process, and an auditor was able to decompile the original script from the encrypted binary. Source


26  06 2008

Installing a grsec-patched kernel on a CentOS 5 or RHEL 5 server

Here’s my little guide for upgrading a CentOS server to a grsec-patched kernel. At the time of this writing, this was the latest stable grsec patch available.

Fetch the sources:
wget http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.24.5.tar.bz2
wget http://grsec.linux-kernel.at/grsecurity-2.1.11-2.6.24.5-200804211829.patch.gz

Extract:
tar xjf linux-2.6.24.5.tar.gz
gzip -d grsecurity-2.1.11-2.6.24.5-200804211829.patch.gz

Patch the kernel:
patch -p0 < grsecurity-2.1.11-2.6.24.5-200804211829.patch
cd linux-2.6.24.5 && make clean && make mrproper

Copy the previous kernel config to use:
cp /boot/config-`uname -r` .config

Edit your kernel:
make menuconfig

Read more…


Next Page »