Akom's Tech Ruminations

Various tech outbursts - code and solutions to practical problems

Linux MySQL replication dies with fatal error 1236: Client requested master to start replication from impossible position

Posted by Admin • Friday, February 4. 2011 • Category: Linux
This time, my master-master setup stopped replicating with no explanation at all - running START SLAVE yielded no warnings or errors. Inspecting the log yielded the aforementioned error (on Ubuntu, mysql logs to /var/log/syslog by default):
[ERROR] Error reading packet from server: Client requested master to start replication from impossible position ( server_errno=1236) [ERROR] Got fatal error 1236: 'Client requested master to start replication from impossible position' from master when reading data from binary log [4654]: 110204 10:09:20 [Note] Slave I/O thread exiting, read up to log 'mysqld-bin.000742', position 4274

So at first I thought this was a weird bug or a stunnel issue, but looking at 'mysqld-bin.000742' on the master it turns out that it's only 3980 bytes - position 4274 is indeed impossible. But how did it get this way?

Continue reading "MySQL replication dies with fatal error 1236: Client requested master to start replication from impossible position"

Code and Hacks The Eclipse, PDT and Smarty dance

Posted by Admin • Monday, January 24. 2011 • Category: Code and Hacks
Eclipse is a great developer tool, and I use mine for Java, PHP, and C++. It actually does all of the above really well, but when it comes to Smarty template Syntax Highlighting, it's a tale of much suffering. I honestly am not even asking for any Smarty auto-completion - just pretty colors that tell me when I'm fat-fingering the syntax.

Fortunately there is a solution that appears to work, and here is the currently valid step-by-step

Continue reading "The Eclipse, PDT and Smarty dance"

Linux Simple flat file site search in PHP/Smarty

Posted by Admin • Wednesday, January 19. 2011 • Category: Linux
Sometimes using a real search implementation (Lucene, Sphinx) is just too much. The particular site I was working on is something like 30 pages, it's maintained as flat files (Smarty templates, but it's basically HTML on disk), and it really, really should not require megabytes of code and cron jobs to be able to search it!

That said, this is a simple search solution - it makes a lot of assumptions:

Continue reading "Simple flat file site search in PHP/Smarty"

Linux Predictable ALSA numbering of USB sound cards

Posted by Admin • Wednesday, January 12. 2011 • Category: Linux
I have 3 rather cute Monoprice usb sound cards for use by mmpd (client I wrote for multiple mpd instances). The great thing about them is that for $9 you can just keep adding zones to your music systems. The bad news is, UDEV will reorder sound cards on boot as it pleases.

Zones changing would be survivable in itself (reboots are rare), but I also have a webcam and an onboard sound card that I don't use - so sometimes the numbers I've configured mpd to use aren't even valid sound cards! On to the continuing search for a working solution

Continue reading "Predictable ALSA numbering of USB sound cards"

Linux Fixing digitemp with LinkUSB on kernels after 2.6.32-24

Posted by Admin • Tuesday, January 11. 2011 • Category: Linux
As many people have discovered, kernels after 2.6.32-24 changed the USB-RS232 serial driver to not set hardware flow control (RTS/DTS) flags. No doubt there was a good reason. Unfortunately, digitemp and owfs don't enable it either, also probably for a good reason - at least when applied to older devices. What this means is that now when you try to use a LinkUSB (and probably other DS9097U type hardware behind USB to Serial converters), digitemp and owfs no longer work.

Let's apply a time-tested hackish approach.

Continue reading "Fixing digitemp with LinkUSB on kernels after 2.6.32-24"

Linux How to take down your pfSense firewall with one checkbox

Posted by Admin • Saturday, January 1. 2011 • Category: Linux
Simple: create a Traffic Shaper queue but forget to choose a queue parent.

Your firewall will not pass any packets across, and you'll have no idea what hit you.

Automotive Troubleshooting car heat issues or why stop-leak is a bad idea

Posted by Admin • Saturday, October 30. 2010 • Category: Automotive
I got my truck exactly a year ago. It came complete with stop-leak (the red brick-colored pellets) in the system. I immediately flushed out all coolant and stop-leak (must have run 100 gallons through the system with a back-flush kit), but I guess that wasn't enough, as I suddenly found myself without any heat whatsoever. Now I am not that into heat, but the idea of a sheet of ice on the windshield with no recourse just doesn't sound like fun.

Since I had to figure out what the issue was step-by-step, I figured I'd write the process down for posterity (read: me, next time). So here it is...

Continue reading "Troubleshooting car heat issues or why stop-leak is a bad idea"

Asterisk Asterisk and obfuscated SIP port redirection - calls drop after 20 seconds

Posted by Admin • Tuesday, October 5. 2010 • Category: Asterisk
One of my asterisk setups got attacked recently by a brute force script kiddie. The attack is simple:
  1. Try sequential sip usernames from 1 to 10000, hoping that the admin chose a numeric username scheme
  2. If asterisk returns anything but a 401, then perhaps this is a real account, add it to the list
  3. If anything is on the list of "possibles", then brute force their passwords


Why this works:
  • Asterisk has no delay for failed logins, so a brute force attack is viable, hundreds of attempts per second are possible. Not sure what can be done about this
  • The admin didn't set alwaysauthreject = yes in sip.conf. It's off by default, why??? With this enabled, there is no way to tell if a username is valid from the reject response


To deal with this:

Continue reading "Asterisk and obfuscated SIP port redirection - calls drop after 20 seconds"

Linux Verizon Wireless tethering Ubuntu Karmic to a Storm 2

Posted by Admin • Friday, April 2. 2010 • Category: Linux
This topic is fairly well described, so this is just a quick how to for me. (This is for USB, I am not attempting bluetooth this time) UPDATE: I now use berry4all instead of the below. It just works, and there is a GUI


Old Way:

  1. sudo apt-get install libbarry0 barry-util barrybackup-gui
    Chances are you already have the first two in a karmic install, and you may not even need barrybackup-gui. I did not need to add any new apt repositories
  2. if the phone requires a password, edit /etc/ppp/peers/barry-verizon and change the pty line to read
    pty "/usr/sbin/pppob -P My_Password"
    Yes there is a password line in that file, but it doesn't seem to do anything, and I don't know how to use variables in a pppd script :-)
  3. sudo pppd call barry-verizon
    You should see the progress and the IP's relevant to the connection. If you're having trouble, add debug:
    sudo pppd debug call barry-verizon
Note1: In my experience, after I kill the pppd connection I can't reconnect until I momentarily unplug the phone. Also, mass storage mode is not necessary.

Note2: These steps should be similar for most providers. Look at /etc/ppp/peers/barry-* to see the predefined provider scripts.

Note3: I believe that the connection will fail miserably if you have any other network connection active on the PC besides the tethered phone.

Note4: I am posting this using my blackberry!

Low Tech Hacks Snowblower oil change with no mess

Posted by Admin • Sunday, March 21. 2010 • Category: Low Tech Hacks
Like most dutiful snowblower owners I change the oil in the spring. The manual says to change it every 25 hours - I don't put that many hours on the engine in a year but the oil probably shouldn't be kept in there that long.

The first year I did the oil change I wound up with a 4 foot oil puddle on my garage floor. Like most small snowblowers, mine has an extension oil drain pipe with a cap. You're supposed to unscrew the cap and drain the oil into something. Well, mine unscrewed at the base - the whole pipe came out, pouring oil down the machine's body and causing me to bring shovelfuls of sand in to clean up the mess. But, there is a better way. (And this is my notepad for next year)

Continue reading "Snowblower oil change with no mess"

Linux Postfix satelite mail configuration with special needs

Posted by Admin • Monday, February 15. 2010 • Category: Linux
OK so I have special needs. (Either that or I am just oblivious to a working example of this).

My needs are:
  1. Do not receive inbound mail
  2. Do not deliver mail locally at all
  3. Send all outbound mail through an upstream relay (ISP's smtp)
  4. Qualify local addresses with a valid domain name (ISP's smtp will reject invalid domains)
  5. Map some local addresses to convenient aliases (distribution lists in the real mail system - google apps in this case)


Doesn't seem so hard, right? So I started with the postfix "Satelite System" option in ubuntu installer, and then...

Continue reading "Postfix satelite mail configuration with special needs"

Linux Software RAID in Ubuntu Karmic 9.10

Posted by Admin • Monday, February 15. 2010 • Category: Linux
I am writing this down because it was somewhat hard to figure out how much of the HOWTO's out there are out of date. This is not particularly difficult, but it's my first RAID setup and this blog is my notepad. I am setting up a RAID1 on a Dell Precision 490 with two brand new 500GB SATA drives.

First I tried using BIOS RAID. My system doesn't have a true RAID controller card and after some trial,error and googling I decided to forget it and go with an industrty standard (MD) Linux software RAID. I reset my drives to non-raid in the BIOS, popped in Ubuntu server x64 CD and went on ahead.

Continue reading "Software RAID in Ubuntu Karmic 9.10 "

Linux MySQL replication dies with ERROR 1201 (HY000): Could not initialize master info structure

Posted by Admin • Friday, February 12. 2010 • Category: Linux
On a fine happy morning I am greeted with an alert that slave is not running. Running start slave yields this:
ERROR 1201 (HY000): Could not initialize master info structure; more error messages can be found in the MySQL error log
Enabling the log yielded nothing. Googling yielded This Page that helped me a lot, but I didn't have to do quite as much work all over again. Here is what I did.

Continue reading "MySQL replication dies with ERROR 1201 (HY000): Could not initialize master info structure"

Code and Hacks Splitting a large image to print on multiple sheets

Posted by Admin • Wednesday, December 23. 2009 • Category: Code and Hacks
This really seems like such a simple task, doesn't it? All I wanted was to print a large (48 megapixel) raytraced image I generated onto several pages, and then tape them together to make a poster.

In my efforts to find a convenient tool to do this, I've attempted the following:
  • Kinko's: (or any neighborhood print shop). I am listing this option because it eliminates the need to do this altogether - they can print an image on a huge poster all at once. This 'should' work, and is probably the best but most expensive option. In my experience, Kinko (Fedex) simply could not receive the image, perhaps they can't handle large uploads.
  • Online Printers: You are probably seeing some options in the google ads on this page already. Of course, I wanted it right now, so that was not an option
  • Rasterbator: A great tool, but not what I need. It creates nice looking multi-page PDF's from low-res images by using the old school newspaper graphic dot approach.
  • Adobe Illustrator (CS3): It seems to have a "print on multiple pages" option in the print dialog, but I've tried every single setting, and it always loses about a 1/4" off the sides, making them un-stitchable. Maybe I'm just Adobe-dumb. Illustrator also insisted that I trust it to manage the print colors rather than trust my printer (a solid-ink Phaser), and the printouts came out practically all brown until I told it to trust the printer. It easily wasted $30 of solid ink before I gave up on Illustrator
  • Photoshop: It can be done. Easiest way is to add guides (view menu) using percentages (eg 50%, 25%, as needed), then select the area between guides (snaps to guides), and copy into new images. This is labor intensive, but if you're careful with mouse movement you should get the right pieces. If you're printing on a small quantity of sheets, this is the best option probably. You can also paste each copied sliver into the same second image - you will then retain any options you've set for that document (such as layout, color quality, etc). Maybe there is a plugin for photoshop that does this automatically?
  • Gimp: Apparently there is a poster plugin of some sort, but in my haste to get this out the door I didn't have the time to understand how to install/compile/use Gimp plugins
  • ImageMagick: This is what I ultimately used. Being a command-line tool it doesn't have a nice visual "layout and split" interface. But what it does have to offer is reliable operation, unix style - one thing, done right. Read more for details on how, below.
  • PDF: What I have not tried is to use the ImageMagick approach above, then auto-convert each image into a PDF and stitch them into one document so they can be printed all at once. I'm not sure if this can be done (easily). If I have to do this again, I'll look into this. (Update: This is no longer necessary, see Geeqie note below)

Continue reading "Splitting a large image to print on multiple sheets"

Hardware Hacks D945GCLF fan issues and alternatives

Posted by Admin • Saturday, December 12. 2009 • Category: Hardware Hacks
I've had my D945GCLF (the Intel Atom 230 board) up for 440 days. That's an impressive uptime until you realize that it's a Gentoo box running asterisk, mpd, and not much else. As anyone familiar with D945GCLF or D945GCLF2 knows, the northbridge has an aluminum heatsink with a 40mm fan. Most people have had theirs fail right away, but I was lucky enough to have mine last over a year before starting to vibrate and slow down. Once I started getting Nagios alerts about high temps, it was time to do something.

I never liked the idea of small fans. A 40mm sleeve bearing wonder is certainly no exception. When it comes to cooling, I always look for big and slow - and that in my book means 120mm running at 7V speeds. I looked for a replacement fanless heatsink but couldn't find one that was reported to fit. Here is what I did:

Continue reading "D945GCLF fan issues and alternatives"