BenV's notes

Archive for 2011

PostgreSQL 9.0 on Slackware

by on Jun.14, 2011, under Morons, Software

Another reason to avoid MySQL

Today MySQL has managed to piss me off enough to get rid of it for something I was working on.
The case:
I just created a brand new database. In that database I want to store items, and those items should be linked to users.
So as a first stab I had this CREATE TABLE statement:

CREATE TABLE user (user_id SERIAL, username varchar(255) UNIQUE NOT NULL, password char(32) NOT NULL, PRIMARY KEY (user_id));
CREATE TABLE item (item_id SERIAL, name varchar(255) NOT NULL UNIQUE, user_id bigint unsigned REFERENCES user(user_id),PRIMARY KEY (item_id)) ENGINE = InnoDB;

Guess what MySQL said? Of course, it said “Sure thing dude!”. And to make sure you believe me, here’s the verbatim:

mysql> CREATE TABLE user (user_id SERIAL, username varchar(255) UNIQUE NOT NULL, password char(32) NOT NULL, PRIMARY KEY (user_id));
Query OK, 0 rows affected (0.36 sec)
mysql> show warnings;
Empty set (0.00 sec)
mysql> CREATE TABLE item (item_id SERIAL, name varchar(255) NOT NULL UNIQUE, user_id bigint unsigned REFERENCES user(user_id),PRIMARY KEY (item_id)) ENGINE = InnoDB;
Query OK, 0 rows affected (0.32 sec)
mysql> show warnings;
Empty set (0.00 sec)

Well guess what….
Those references to the user table? What references? (continue reading…)

Leave a Comment :, , , more...

Check_MK plugin: daemontools

by on Jun.12, 2011, under Software

Another day, another plugin (aka package) for Check MK.
This time it’s a check for Daemontools, the daemon that keeps other daemons up and running.
Personally I use it for a lot of services on my servers, like Apache and Tinydns. However, sometimes a service is flapping in Daemontools
because of a configuration error or something similar and you fail to notice for hours because the service seems to be ‘up’ (but only for a few seconds before it restarts again).

This check makes sure all services that are supposed to be up (“normally up”) are up, and also it checks for how long they’ve been up.
If the uptime is only a few seconds it’ll issue a warning because it might be flapping.

Check_MK - Daemontools

Check_MK - Daemontools Perf-o-meter

[Download not found]
Leave a Comment : more...

Sony and their PSN

by on Jun.08, 2011, under Fun, Morons

I don’t like Sony much … in fact, I pretty much hate them and have to laugh every time I read a new post about them being hacked in whatever form.
No, you can’t feel sorry for corporations. Let alone corporations that fuck you over every chance they get.
That said, I do have a PS3 (running Dosbox and ScummVM among things), and I once had this PS3 connected to the PlayStation Network.

So they just sent me an email:

Sony: Playstation Store is back!

Sony: Playstation Store is back!

It says (in UTF-8 viewed through iso-8859-1):

Dear Playstation Network-user,

We are very happy that we can tell you that the access to the PlayStation-Store through PlayStation-3, PSP (PlayStation Portable) and Media Go on your PC has been completely restored.

And then they go on about what you receive as compensation (free game, free month of PlayStation Plus), but because they allegedly improved the security you have to change your password.
Then there’s a gibberish link to that I followed, hoping to be able to change my password.
This is what my browser showed:

Sony PlayStation stuff still down

Sony PlayStation stuff still down

Funny bastards 😉

Leave a Comment : more...

Check_MK plugin: qmail

by on Jun.08, 2011, under Software

Just a tiny update for my Check_MK qmail package.
It still checks the qmail queue size 🙂
New in this version is the added Perf-O-Meter. Shiny shiny!

Check_MK Qmail plugin v1.1

Check_MK Qmail Perf-O-Meter

[Download not found]
[Download not found]

Leave a Comment :, more...

World IPv6 Day!

by on Jun.08, 2011, under Morons

Today is proclaimed World IPv6 Day, in order to motivate everyone to just fucking get it done already. And test if people have issues today of course 🙂
They’ve had years and years and still major ISPs haven’t even heard of IPv6 or simply can’t be arsed because there’s little demand for it. (Boohoo, “it costs money to upgrade our ancient equipment“)
So attention everyone: if you don’t have IPv6 right now, mail your ISP, bug their contact for(u)ms, and spam their phones. You want it! 🙂
If you’re hosting content and don’t have it: bug your provider about it as well. It’s saddening to see how few hosting providers today still don’t offer IPv6, even though it’s been out there for over a decade!

One of the reasons my home connection is with XS4All is that they deliver native IPv6 to the doorstep.
All machines at home automagically receive an IPv6 address from my modem and it just works ™. No hassles with tunnels or anything, simply turn it on and it works.

As for the “Why would I care?“. Because it’s fun to play with. Because it’s neat to have so many public addresses.
No more NAT and port forwarding to get your webserver reachable on the internet, but simply open up port 80 in your firewall and you’re done!
You’ll have so many addresses (assuming your ISP are not major dickheads that only hand out single IPs, but they won’t) that you can put an IPv6 address
on every device you have, for every program you have, for every pixel on your screen and still you’ll have tons to spare.

If you’re not sure if you have it, there’s this test to check, but I sure hope you know about the state of your connection without such tests 😉

In case your stupid provider is being the usual dumbdumbhead and won’t be bothered (and obviously you can’t switch because they have the local monopoly) you can get IPv6 connectivity for free through a tunneling broker by at least two parties that I know of. One of them is Hurricane Electric, the other Sixxs (although they can be dicks, so I’ll be a dick by not linking them ;))
It will give you the ability to tinker with IPv6, so give it a shot if you’re new to it. Did I mention it’s free? 🙂

But how do I configure IPv6 on my Slackware machine?
Well, if you do it properly and get it through your ISP natively your modem will take care of it. It’ll announce your prefix to your network and if you have your kernel set to autoconfigure it (which is default, as long as you’ve loaded the ipv6 module) it’ll get an address based on your mac address.
Adding addresses manually is just as easy as with ipv4:

# Example out of thin air
root@somewhere# modprobe ipv6 # if you hadn't done this yet ;)
root@somewhere# ip -6 addr add 2001:1234:3214:abcd::80/64 dev eth0
root@somewhere# ip -6 route add default via 2001:1234:3214::1 dev eth0

So go and check it out, it can be fun 🙂

Oh yeah, obviously my notes are available on IPv6. And it seems to be a lot faster than google at the moment 😉

ipv6 ready

Leave a Comment :, more...

Check_MK plugin: lmsensors

by on Jun.07, 2011, under Software

On the subject of Pretty Graphs (see my earlier post), I decided to write a plugin (a.k.a. ‘Package’) for Check_MK in order to monitor (and make pretty graphs!) of the sensor output of lmsensors.
Most machines support this out of the box these days, and it’s always interesting to see the conditions of your machine. In case you don’t know, it gives the temperature and voltage of your CPU and mainboard. Thus it’s a good source for making pretty graphs 🙂

Since these plugins are very easy to install (once you’ve got check_mk up and running that is) and still nobody had written one for lmsensors, I decided to do it myself. Writing python isn’t my strongest point (yet), but these are good opportunities to learn.

One of the issues I ran into while writing the plugin was that PNP4Nagios fails on service names that have a plus character in them. For instance, I had Sensor +12V. This created the files Sensor_+12V.rrd and corresponding xml, but when one would go to the PNP4Nagios graph of that sensor it would request a file called Sensor__12V.rrd, which obviously failed.
Therefore I molested the names a bit, so your sensor might now be simply called MB12V instead of M/B+12V.

Configuration of LM-Sensors
For my plugin to work you need to make sure that you have the ‘sensors’ tool. This normally comes in a package called “lmsensors” or “lm-sensors”. Note that you obviously need some kind of hardware sensor on your machine that’s supported by lm-sensors for it to work, including the required kernel module. Fortunately this will often work out of the box.
After making sure you have sensors and that running ‘sensors’ will give output like this:

benv@localhost:~$ sensors
Adapter: ISA adapter
in0: +1.04 V (min = +0.00 V, max = +4.08 V)
in1: +1.66 V (min = +0.00 V, max = +4.08 V)
in2: +3.39 V (min = +0.00 V, max = +4.08 V)
+5V: +3.04 V (min = +0.00 V, max = +4.08 V)
in4: +3.10 V (min = +0.00 V, max = +4.08 V)
in5: +1.90 V (min = +0.00 V, max = +4.08 V)
in6: +4.08 V (min = +0.00 V, max = +4.08 V)
5VSB: +3.04 V (min = +0.00 V, max = +4.08 V)
Vbat: +3.30 V
fan1: 2235 RPM (min = 10 RPM)
fan2: 0 RPM (min = 0 RPM)
fan3: 2500 RPM (min = 0 RPM)
fan5: 0 RPM (min = 0 RPM)
temp1: +41.0°C (low = +127.0°C, high = +127.0°C) sensor = thermistor
temp2: +36.0°C (low = +127.0°C, high = +90.0°C) sensor = thermal diode
temp3: +38.0°C (low = +127.0°C, high = +127.0°C) sensor = thermistor
cpu0_vid: +1.250 V

Adapter: PCI adapter
temp1: +32.0°C (high = +70.0°C)

You might see things like ‘in0’ instead of ‘CPU Voltage’. Don’t ask me what voltage corresponds with what sensor on your mainboard, but you can rename the sensor output by editing /etc/sensors.conf or /etc/sensors3.conf depending on your flavor of linux.
In order for the check_mk plugin templates to recognize the type you’ll need to make sure they have some kind of indication of the type of sensor. For instance label the temperature sensors with ‘temp’ or ‘temperature’. The default names like ‘in0’ will also work, but something like ‘Pizza sensor’ obviously won’t.

To change labels or ignore certain sensors because they give bogus data (not connected etc), first find your adapter type.
In the example above this is it8720-isa-0228. Now edit the sensors.conf file and add a section
for this adapter if it isn’t already there.

Here’s an example for renaming in0 to “CPU Voltage” and turning off the second fan since it’s not connected.
Also we’ll change the minimum and maximum voltage for the CPU Voltage — this determines when nagios will send out an alarm or not:

chip "it8720-isa-0228"
set in0_min 1.0
set in0_max 2.0
label in0 "CPU Voltage"
ignore fan2

After changing the sensors file you’ll need to make lmsensors aware of the configuration change by running ‘sensors -s’. (might need root).

benv@localhost:~$ sensors -s
benv@localhost:~$ sensors
Adapter: ISA adapter
CPU Voltage: +1.31 V (min = +1.00 V, max = +2.00 V)
fan1: 2235 RPM (min = 10 RPM)
fan3: 2500 RPM (min = 0 RPM)
# some stuff deleted to save space :)

Tada. Now repeat this process for all sensors 🙂

There are two parts to installing a Check MK plugin. First on the host that actually runs check_mk we need to install the package. This is quickly done:

root@checkmk# wget
root@checkmk# md5sum lmsensors-1.4.mkp
115bd50557d1db7e934baa64e172e506 lmsensors-1.4.mkp
root@checmk# check_mk -vP install lmsensors-1.4.mkp
Installing lmsensors version 1.4.
Checks man pages:
Multisite extensions:
PNP4Nagios templates:
root@checkmk# check_mk -II 2 new checks
lmsensors.volt 4 new checks
root@checkmk# check_mk -O

Done. Soon there will be pretty graphs for this machine 🙂

Now for a remote machine you will need to put the agent in place. Since this is only a single file it’s trivial to do:

benv@checkmk$ scp /usr/share/check_mk/agents/lmsensors root@othermachine:/usr/share/check_mk/agents

Note that the place you want to put that thing in is the $MK_LIBDIR/plugins directory. In my case, this was /usr/lib/check_mk_agent/plugins, but it could very well be somewhere else on your system. You can find it in the check_mk_agent script if you don’t know:

benv@somemachine$ grep MK_LIBDIR `which check_mk_agent`
export MK_LIBDIR="/usr/lib/check_mk_agent"

Let Check_MK do an inventory on your remote machine [check_mk -II $machine] and the rest goes automagically! 🙂

And now we have pretty graphs for my sensors.
Comments and/or suggestions are welcome.

LMSensors in Check_MK

LMSensors in Check_MK

Version 1.1: now has pnp templates to put graphs of the same type together.
Here’s an example:

Now we have combined graphs

Now we have combined graphs (v1.1)

Version 1.2: changed sed to perl in agent plugin, sensornames with more than one space (among things) were giving issues. Thanks to Cyril Pawelko for finding the issue and helping with testing!

Version 1.3: minor change to PNP templates — Nico Weinreich informed me that his fan templates weren’t working correctly so I updated the regular expression used to match corresponding sensor types. If you didn’t have this issue this update won’t do anything useful for you 🙂

Version 1.4: Seems like I was a dumbass and didn’t check the 1.2 package properly. This package really makes it work with perl instead of sed.
Also updated the voltage pnp template to hopefully match more voltage sensors.
Note: if the pnp4nagios template doesn’t work for you, check your pnp4nagios perfdata dir, for example /var/lib/pnp4nagios/perfdata/ and see what .rrd files exist for your host. They are based on the sensor name, so if your sensor name is “St John”, it will not match the voltage template. These names come directly from your sensors.conf (if you don’t have it the default names for the sensors).
See above on how to rename your sensors.

Version 1.5: Another bug spotted by Cyril! The pnp4nagios temperature template had a botched variable name.

lmsensors-1.6.mkp (3973 downloads)      SHA1: 42f7f7eebf803fb3ed755107521761bfb4fbb6bc  MD5: 199266bfd9d750243b9bc49773b6b4d6
[Download not found]
[Download not found]
[Download not found]
[Download not found]
[Download not found]
[Download not found]

35 Comments more...

Fighting with PNP4Nagios

by on Jun.07, 2011, under Software

So today I noticed my pretty Check MK graphs were broken. Trying to view a random Check_MK service’s PNPGraphs gave this error:

Warning: preg_match() [function.preg-match]: Compilation failed: unknown option bit(s) set at offset 0 in /usr/lib/kohana/system/core/utf8.php on line 30

Fatal error: PCRE has not been compiled with UTF-8 support. See PCRE Pattern Modifiers for more information. This application cannot be run without UTF-8 support. in /usr/lib/kohana/system/core/utf8.php on line 38

Of course this is after I had upgraded some Slackware packages in the daily upgrades (I still run Slackware Current on non production machines, keeps things interesting) including PHP and Perl, so I wasn’t really surprised.
I reinstalled RRDTool since the perl bindings were gone (and of course I once again had to fight it) and decided to upgrade PNP4Nagios while I was at it.
However, no dice. Searching for the error gave nothing, hence this post.

To be sure it wasn’t what they (google) claimed it would be, I checked for UTF-8 support in my libpcre:

benv@graphs$ pcretest -C
PCRE version 8.12 2011-01-15
Compiled with
UTF-8 support
Unicode properties support
Newline sequence is LF
\R matches all Unicode newlines
Internal link size = 2
POSIX malloc threshold = 10
Default match limit = 10000000
Default recursion depth limit = 10000000
Match recursion uses stack

Jup, UTF-8 support is there, along with Unicode stuff. Yay.

Next thing I noticed was that the new PHP version was complaining about extensions that wouldn’t load.
For instance didn’t exist anymore, and some other junk failed as well. It’s possible that this error has been around for a while on that machine, but it was time to fix it!
Since my php.ini was from 2008 I decided to simply take the stock /etc/httpd/php.ini-production for now.
After that change php was again bitching about not being able to load extensions, but this times it were different ones.
Apparently they now have ‘libenchant‘ for spell checking, so that was one of the other failures.
To fix that problem use ‘slackpkg install enchant‘. (that’ll teach me to run the slackpkg install-new every once in a while :p)

Restarting Apache the hard way (not “apachectl restart” but /etc/rc.d/rc.httpd restart) helped for the PNP4Nagios error.
However, upgrading it introduced a new gimmick called:

Please check the documentation for information about the following error.

Undefined index: auth_enabled
file [line]:

application/models/auth.php [22]:


Right. Upgrading my Check_MK to 1.1.10p3 didn’t help.
However, checking the pnp4nagios config.php file made me aware that they added some options.
After merging in the new config.php options from their sample dir it finally worked again.
The new options I had to add when going from pnp4nagios version 0.6.7 to 0.6.13 were:

$conf['zgraph_width'] = "750";
$conf['zgraph_height'] = "450";
$conf['auth_enabled'] = FALSE;
# Adjust the next one to your configuration, it's probably different :)
$conf['livestatus_socket'] = "unix:/var/lib/nagios/rw/live";
$conf['allowed_for_all_services'] = "";
$conf['allowed_for_all_hosts'] = "";

Hooray, pretty graphs are back 🙂

LMSensor Fan1 speed graph

Pretty graphs!

1 Comment :, , , , , more...

Review: Fable 3

by on Jun.05, 2011, under Software

A short summary of my Fable 3 experience so far.

Fable III

Fable 3

First we install it, and immediately we notice the Windows Game Live Garbage Cancer. So far so bad.
However, apart from the login bugging me every time I start the game it works fine.

The game itself looks fine, better than the previous Fable I played at least. The story is pretty standard, you’re a prince and your evil brother – the king – is ruining everything.
You’re the hero who has to murder him. Or something.
So the first thing you do is shake everyone’s hand for 5 minutes, apparently people love you when you shake their hands long enough.
Then you go through the usual “Get kicked out of the castle and start your quest” ritual. Speaking of rituals, did I mention I hate unskippable cutscenes?
Especially when starting the game, who the fuck cares that Microsoft made the game…
Anyhow, after running around a bit and getting your first skills you find yourself in the familiar guild room, a safe place to save your game and switch clothes etc.
Reminded me of Baldur’s Gate’s pocket plane.

Next you go to villages to gather allies. Which means helping them out first. Which means shaking hands, and smashing monsters.
Oh yeah, “prove you’re a hero” so they can teach you how to use your sword and gun in addition to the magic you started off with.
Great great. In the second village your run into you can do minigames like Guitar Hero, only more retarded because there are only two buttons involved.
If that wasn’t easy enough already, they also have Pie Making Hero. Same game with only 3 notes per song. So before you know it you have enough money
to buy several houses. So much for that.

Other villagers give you quests after whistling to them for an hour (did I mention it gets really old, really fast?), and strangely they all need you to get the same hidden
package in the other village, or talk to the same retard in that other village to pass a message.
I’d like to get a list of my active quests, but that isn’t unlocked at this part of the game yet.
So I decided to go on with the story to unlock that part, but just after traveling back to the village my windows decided to BSOD. Probably related to that new NVIDIA driver update from yesterday.
Anyhow, I reboot windows, restart Fable 3, get through the sickening unskippable intro garbage, log into LIVE.
[Windows LIVE] Saaay, your savegame …. isn’t.
[BenV] What?
[LIVE] Your save is corrupt, so we’ll just start the game from scratch again. Would you like a Prince or a Princess?
[BenV] !(@3(@^$*&%^*(@$#(@*$%3*REBOOT*

So much for Fable 3 and windows.

Just tried to get the game working in wine. With some hassle I got through the installation.
However, the game won’t start becaseu FS3Secu.exe crashes. Garbage DRM as always.
Couldn’t find a crack that would bypass this exe though, so no luck for Wine at the moment.

Leave a Comment :, more...

Commandline XLS/DOC to PDF converting

by on Apr.04, 2011, under Software

Since this took me 5 years to find through google, this is another reference post.
Converting word and/or excel documents to PDF format should be easy.
Unfortunately it takes Libreoffice (or whatever your variant is today), but it works:

$ libreoffice -headless -convert-to pdf /tmp/bla.xls
convert /tmp/bla.xls -> /tmp/bla.pdf using calc_pdf_Export

No garbage paid for converters needed, just garbage libreoffice.

Update: since libreoffice is still the same garbage as openoffice (maybe it’ll improve some day) I ran into this error
on my production machine:

$ libreoffice -headless -convert-to pdf /tmp/bla.xls
[Java framework] Error in function createSettingsDocument (elements.cxx).
javaldx failed!

Apparently this is caused by libreoffice wanting to do some garbage in its home directory. Except for my headless user doesn’t have a workable home.
Oh yeah, there’s a -nofirststartwizard option but it doesn’t help. This is solved by setting HOME to /tmp for instance:

$ HOME=/tmp libreoffice -headless -convert-to pdf /tmp/bla.xls

Leave a Comment more...

Xen, DRBD and live migration

by on Mar.10, 2011, under Software

Once again I have some new hardware that’s been labeled “Xen Server”.
This time I want to set it up in a way that brings some redudancy so we can actually have 1 server fail and still have our hosts up and running.
(or at least back up in a few minutes instead of several hours).
To achieve this goal I will install the latest version of Xen (which seems to be 4.01) and use DRBD with LVM for storage. (continue reading…)

1 Comment :, , , , more...