Smokes your problems, coughs fresh air.

Author: halfgaar (Page 23 of 26)

Halfgaar is Wiebe. Wiebe is a contributing author on this weblog. He also has a lot of stuff (such as long, in-depth articles) on his personal website.

Wiebe's day job is as a senior software developer and system administrator at YTEC.

In his free time, he built the free, open-source FlashMQ software. Together with Jeroen and Rowan, he is now building a managed MQTT hosting business around his open masterpiece.

Removing unwanted grey values in scanning white papers

When doing automated scanning, like I do to for properly organizing paper administration, the resulting images can get quite large because the background has near-white information that is still very complex to save. Imagemagick has nice solution for that; -white-threshold x%. It also has -black-threshold, should it be necessary.

Expanded output in MySQL prompt

When you have tables with a large amounts of columns, it can be easy to show the columns vertically, as opposed to horizontally. In Postgresql, you can toggle this with \x. In MySQL it’s a little bit different.

In MySQL you can end your query with a \G instead of a ; and it outputs like this:

select * from permission \G
*************************** 1. row ***************************
 pid: 1
 rid: 1
perm: access content
 tid: 0
*************************** 2. row ***************************
 pid: 2
 rid: 2
perm: access comments, access content, post comments, post comments without approval
 tid: 0

Simple, but I thought I’d blog about it.

Change in law regarding cell phone contracts

Cell phone providers in the Netherlands always try to screw you as hard as they can. The way it was, they were able to automatically extend your contract for another year. The way they screwed you here, is because when you sign up for a new contract, you often get discount. I for instance, was able to get a service worth € 17,50 per month for € 12,50 (240 minutes), the entire year. But, when the contract period would end, my contract would be extended automatically and I would pay € 17,50 per month for a year. You had to remember to call KPN before the contract would end and manually extend the contract to receive another discount.

The change in law is this: they now extend the contract one day, every day after the contract period is over. So, you can easily switch provider after you’ve seen that you suddenly pay € 17,50 instead of € 12,50, or sign up for another subscription at the same provider, or whatever you want to do.

Unfortunately, I couldn’t get the same amount of minutes (240) for € 12,50 again, but this time for € 15,00. For € 12,50 I would have gotten 130 minutes, which is too low. But luckily the guy gave me my first month for free, because I was long-time customer (or so he said), so that saves € 15,00, in other words, 6 months the difference between the 130 and 240 minutes. Yet in other words, I pay € 13.75 per month. I think this is an OK enough deal.

I could go through the hassle to see what kind of discount I get if I switch providers, because providers often give new customers more discount than existing ones, but I also hate that kind of administrative work and the risk of problems when I switch, so I’m happy now.

Setting paper size in Mozilla products

Mozilla products, firefox and thunderbird, seem to have the strange behaviour of overriding the paper size set by the operating system; it scales the page to letter and then prints it to A4.

To fix that, you need to go into about config and set the print_paper_data parameter to 9.

APC CS-500 causes USB disruption

I’m having a EM interference problem with the APC CS-500 UPS on two different locations. Those two locations are near each other and there seems to be something wrong the power grid in that area. Both UPS’s momentarily switch over to battery several times a day. Some of these times, the apcupsd daemon sends a message saying that the communication with the UPS has been restored (and therefore it had been lost at some point).

Here is the syslog of one of those computers with everything but the power failure and EMI notices filtered out:

Aug  7 06:59:10 bitler apcupsd[22622]: Power failure.
Aug  7 06:59:18 bitler apcupsd[22622]: Power failure.
Aug  7 06:59:31 bitler apcupsd[22622]: Power failure.
Aug  7 06:59:35 bitler apcupsd[22622]: Power failure.
Aug  7 13:59:19 bitler apcupsd[22622]: Power failure.
Aug  7 13:59:38 bitler apcupsd[22622]: Power failure.
Aug  7 18:59:11 bitler apcupsd[22622]: Power failure.
Aug  7 18:59:25 bitler apcupsd[22622]: Power failure.
Aug  7 18:59:28 bitler apcupsd[22622]: Power failure.
Aug  7 21:29:12 bitler apcupsd[22622]: Power failure.
Aug  7 21:29:19 bitler apcupsd[22622]: Power failure.
Aug  7 21:29:23 bitler apcupsd[22622]: Power failure.
Aug  7 21:29:51 bitler apcupsd[22622]: Power failure.
Aug  7 21:30:05 bitler apcupsd[22622]: Power failure.
Aug  7 21:30:09 bitler apcupsd[22622]: Power failure.
Aug  7 21:30:12 bitler apcupsd[22622]: Power failure.
Aug  7 21:30:14 bitler apcupsd[22622]: Power failure.
Aug  7 21:35:21 bitler apcupsd[22622]: Power failure.
Aug  7 21:35:29 bitler apcupsd[22622]: Power failure.
Aug  7 21:35:32 bitler apcupsd[22622]: Power failure.
Aug  7 21:35:38 bitler apcupsd[22622]: Power failure.
Aug  7 22:39:11 bitler apcupsd[22622]: Power failure.
Aug  7 22:39:22 bitler apcupsd[22622]: Power failure.
Aug  7 22:39:31 bitler apcupsd[22622]: Power failure.
Aug  7 22:39:35 bitler apcupsd[22622]: Power failure.
Aug  7 22:39:36 bitler kernel: hub 5-0:1.0: port 1 disabled by hub (EMI?), re-enabling...
Aug  7 22:59:10 bitler apcupsd[22622]: Power failure.
Aug  7 22:59:25 bitler apcupsd[22622]: Power failure.
Aug  7 22:59:28 bitler apcupsd[22622]: Power failure.
Aug  7 22:59:32 bitler apcupsd[22622]: Power failure.
Aug  7 22:59:37 bitler apcupsd[22622]: Power failure.
Aug  7 23:59:32 bitler apcupsd[22622]: Power failure.
Aug  8 05:51:10 bitler apcupsd[22622]: Power failure.
Aug  8 05:51:21 bitler apcupsd[22622]: Power failure.
Aug  8 05:51:31 bitler apcupsd[22622]: Power failure.
Aug  8 05:51:35 bitler apcupsd[22622]: Power failure.
Aug  8 06:59:24 bitler apcupsd[22622]: Power failure.
Aug  8 06:59:32 bitler apcupsd[22622]: Power failure.
Aug  8 06:59:36 bitler apcupsd[22622]: Power failure.
Aug  8 11:29:11 bitler apcupsd[22622]: Power failure.
Aug  8 11:29:28 bitler apcupsd[22622]: Power failure.
Aug  8 13:59:17 bitler apcupsd[22622]: Power failure.
Aug  8 13:59:22 bitler apcupsd[22622]: Power failure.
Aug  8 13:59:23 bitler kernel: hub 5-0:1.0: port 1 disabled by hub (EMI?), re-enabling...
Aug  8 14:00:19 bitler apcupsd[22622]: Power failure.
Aug  8 18:59:37 bitler apcupsd[22622]: Power failure.
Aug  8 21:27:11 bitler apcupsd[22622]: Power failure.
Aug  8 21:27:16 bitler apcupsd[22622]: Power failure.
Aug  8 21:27:17 bitler kernel: hub 5-0:1.0: port 1 disabled by hub (EMI?), re-enabling...
Aug  8 21:27:25 bitler apcupsd[22622]: Power failure.
Aug  8 21:27:39 bitler apcupsd[22622]: Power failure.
Aug  8 21:29:11 bitler apcupsd[22622]: Power failure.
Aug  8 21:29:13 bitler kernel: hub 5-0:1.0: port 1 disabled by hub (EMI?), re-enabling...
Aug  8 21:29:22 bitler apcupsd[22622]: Power failure.
Aug  8 21:29:25 bitler apcupsd[22622]: Power failure.
Aug  8 21:29:27 bitler kernel: hub 5-0:1.0: port 1 disabled by hub (EMI?), re-enabling...
Aug  8 21:29:37 bitler apcupsd[22622]: Power failure.
Aug  8 21:29:38 bitler kernel: hub 5-0:1.0: port 1 disabled by hub (EMI?), re-enabling...
Aug  8 21:30:20 bitler apcupsd[22622]: Power failure.
Aug  8 21:30:22 bitler apcupsd[22622]: Power failure.
Aug  8 21:30:24 bitler apcupsd[22622]: Power failure.
Aug  8 21:30:28 bitler apcupsd[22622]: Power failure.
Aug  8 21:30:29 bitler kernel: hub 5-0:1.0: port 1 disabled by hub (EMI?), re-enabling...
Aug  8 21:30:37 bitler apcupsd[22622]: Power failure.
Aug  8 22:39:11 bitler apcupsd[22622]: Power failure.
Aug  8 22:39:25 bitler apcupsd[22622]: Power failure.
Aug  8 22:39:28 bitler apcupsd[22622]: Power failure.
Aug  8 22:59:11 bitler apcupsd[22622]: Power failure.
Aug  8 22:59:18 bitler apcupsd[22622]: Power failure.
Aug  8 22:59:26 bitler apcupsd[22622]: Power failure.
Aug  8 22:59:28 bitler apcupsd[22622]: Power failure.
Aug  8 22:59:40 bitler apcupsd[22622]: Power failure.
Aug  8 23:59:11 bitler apcupsd[22622]: Power failure.
Aug  8 23:59:22 bitler apcupsd[22622]: Power failure.
Aug  8 23:59:24 bitler apcupsd[22622]: Power failure.
Aug  9 05:54:10 bitler apcupsd[22622]: Power failure.
Aug  9 05:54:21 bitler apcupsd[22622]: Power failure.
Aug  9 05:54:22 bitler kernel: hub 5-0:1.0: port 1 disabled by hub (EMI?), re-enabling...
Aug  9 05:54:39 bitler apcupsd[22622]: Power failure.
Aug  9 06:59:10 bitler apcupsd[22622]: Power failure.
Aug  9 06:59:17 bitler apcupsd[22622]: Power failure.
Aug  9 06:59:19 bitler kernel: hub 5-0:1.0: port 1 disabled by hub (EMI?), re-enabling...
Aug  9 06:59:27 bitler apcupsd[22622]: Power failure.
Aug  9 06:59:28 bitler apcupsd[22622]: Power failure.
Aug  9 06:59:32 bitler apcupsd[22622]: Power failure.
Aug  9 06:59:36 bitler apcupsd[22622]: Power failure.
Aug  9 06:59:39 bitler apcupsd[22622]: Power failure.
Aug  9 12:59:22 bitler apcupsd[22622]: Power failure.
Aug  9 12:59:23 bitler apcupsd[22622]: Power failure.
Aug  9 12:59:27 bitler apcupsd[22622]: Power failure.
Aug  9 13:59:24 bitler apcupsd[22622]: Power failure.
Aug  9 13:59:28 bitler apcupsd[22622]: Power failure.
Aug  9 13:59:34 bitler apcupsd[22622]: Power failure.

As you can see, all the EMI notices correspond exactly with the UPS switching over to battery; all the EMI notices are 1 or 2 seconds after the power failure notice, without exception. And no, I didn’t just show the EMI notices that suit me; these are all of them.

APC suggested it might have something to do with the 3rd party software (because they don’t support Linux themselves), but that’s ridiculous of course. The software doesn’t have the ability to command the UPS to switch over to battery, so the order of events has to be that the UPS switches and that the USB hub is disrupted by that. This is exactly the order of events the logs show.

I think this problem is common in the CS type of UPS’s and perhaps in other models as well and that just because of the frequent switching it shows more often. I still have to find out whether it’s the proximity of the UPS to the computer or if the EMI is traveling over the USB cable. Putting the UPS about a meter below the machine didn’t help, anyway.

One very big problem with this situation is that I can’t reliably connect a USB hard disk to the system for backups. The filesystem and the data on it will not take kindly to connection interrupts.

Setting up Rsync daemon

What can you do when you want to backup your entire machine to a remote location but only have non-root shell access? You use rsyncd.

On the server you need to configure a module in /etc/rsyncd.conf:

[module_name]
uid=0
gid=0
path=/path
transfer logging=no
read only=no

Then you need to rsync using a destination like user@host::module_name/

To make it work, you first need to set up a tunnel using SSH, because the rsync port (873) is not open in the firewall, most likely. So, you do this:

ssh -N -L 873:localhost:873 user@host

I wrote a script to automate this all. Perhaps I will follow-up on this post sometime and post it.

Xerox 7232 communication failure

The Xerox 7232 color laser printer we’re leasing at work has a very vague problem causing communication failures all the time. When you boot it, it works fine. After a while it starts getting slow. And if you wait even longer, it doesn’t work at all anymore. This happens within a few minutes.

The problem seems to occur faster when you print from certain machines on the network. However, given enough time, none of them work anymore. The machines are a mix of Windows 2000 and Windows XP machines and there is no correlation between the OS and the degree of communication difficultly.

The problem has nothing to do with this existing Microsoft knowledge base item, as I will show with network traffic logs.

When the printer just starts and works fine, the communication is as follows: the client sends a [SYN] packet, the printer responds with [SYN, ACK] to which the client sends another [ACK]. At this point, the connection is established and the client starts sending data packages. After two packages the printer sends an [ACK] back. As the Microsoft’s knowledge base article states, TCP sends [ACK]’s every two packets, so this is normal. This repeats a number of times until the printer starts printing.

The following TCP/IP analysis shows it clearly (192.168.1.205 is the client, 192.168.1.103 is the printer. Don’t pay attention to the source port network name):

wireshark-screenshot-success2

When the communication problems begin, the difference is that after the first two data packets are sent, the printer doesn’t send the expected [ACK] packet. The client keeps sending retransmissions until the printer eventually sends a [RST] (reset):

wireshark-screenshot-failed2

The printer obviously doesn’t adhere to TCP/IP standards. Xerox technical support likes to claim that the problem is in our network, because the fault doesn’t (easily) happen when they connect a laptop to the printer with a crosslink cable, but this evidence clearly shows the printer is at fault. Even if it starts doing this because of some invalid data packet our client PC’s might send, it’s still faulty behavior. To such an extent even, that if any server or client machine would have this problem, it would be classified as a security risk, because it is then susceptible to denial of service attacks.

Installing grub on RAID1

When you have your kernel image and grub boot stages on a Linux software RAID1 partition, installing grub needs a bit of trickery.

It determines on what hardware device those files are located by looking at /etc/mtab. It will find /dev/md/0 for / or /boot (or whatever) where the files are located. That device has no BIOS device, because it is managed by the Linux kernel. Therefore, when you try to install grub, it says: “/dev/md/0 does not have any corresponding BIOS drive.“. But because the underlying partitions in a RAID1 have the same data as the virtual device, we can trick grub.

All we have to do is edit /etc/mtab and replace the /dev/md/0 with /dev/sda1 (or whatever). You can then run grub-install hd0. Of course, make a backup of mtab first so you can revert it after having installed grub.

I find it kind of weird that grub doesn’t determine that the device in question is a RAID1 and that it can simply use the underlying device; the internet is filled with people having the same problem. If anybody knows a more elegant solution than this, I’m all ears.

Based on the comments, this is what you need to install it from the grub prompt:

# grub
grub> root (hd0,0)
grub> setup(hd0)
grub> root (hd1,0)
grub> setup (hd1)

Fixing “expected NAV packet but none found” error on some downloaded DVD’s

With certain DVD’s, Xine fails when seeking in the movie saying “Expected NAV packet but none found”. It seems that I have finally found out how to fix this and it is not even difficult. If the theory is correct, it only happens with DVD’s obtained as an ISO image.

What you need to do, is mount the image over the loopback, copy the data files to another location and playing those copied files should work. You can then burn them to a video DVD if you want to, of course.

I have no idea why this works or what causes the error, but I’m glad I finally figured it out.

Also, some of these DVD’s don’t even play on normal players (so it’s not just Xine). This should fix that as well, but I have yet to test that.

Impossible to fix file collision when upgrading qt 4.3 to 4.5

I’m trying to upgrade my qt 4.3 to 4.5. Version 4.5 seems to be split up in several ebuils, one of which is qt-dbus. When trying to install qt-dbus, it says that the files conflict with qt-4.3. This is only normal, because in version 4.3, the files did belong to qt.

The thing is, some time ago, collision protection was disabled by default, which I thought made sense because when I tried enabling it, I’d get errors like these all the time. I disabled it for now (by putting “-collision-protect -protect-owned” in the FEATURES variable in make.conf), to be able to install Qt, but because it is enabled by default, I’d rather not keep it disabled.

(Text was copied from the post I made on the Gentoo forum about it.)

« Older posts Newer posts »

© 2024 BigSmoke

Theme by Anders NorenUp ↑