Archive - February, 2010

Resize tag cloud in WordPress

Simple plugin for changing font sizes in the WordPress tag cloud.

resize-tag-cloud.php

<?php
        /*
        Plugin Name: Resize tag cloud
        Plugin URI: http://poller.se/2010/02/resize-tag-cloud-in-wordpress/
        Version: 0.1
        Author: Fredrik Poller
        Author URI: http://poller.se/
        Description: Resizes tag cloud font sizes
        */

        function resize_tag_cloud_filter($args = array()) {
                // Do changes on the lines below
                $args['smallest'] = 8;
                $args['largest']  = 18;
                $args['unit']     = 'pt';

                return $args;
        }

        add_filter('widget_tag_cloud_args', 'resize_tag_cloud_filter', 20);
?>

No config from the admin panel, do changes in the script.

Put file in the wp-content/plugins/ directory of your WordPress installation and active from the admin panel.

Distributed filesystem with GlusterFS

This setup contains two GlusterFS-servers and one client, named s01, s02 and c01 in the examples below. Data stored in the mount point on c01 will be destributed to s01 and s02.

The Ubuntu APT repository doesn’t have the latest GlusterFS version, which we want. So we’ll have to build it ourself. Do this on all 3 nodes.

Install packages required to buld GlusterFS.

# aptitude install build-essential flex bison

Download and install GlusterFS. As of date, 3.0.2 is the latest version.

# wget http://ftp.gluster.com/pub/gluster/glusterfs/3.0/LATEST/glusterfs-3.0.2.tar.gz
# tar zxf glusterfs-3.0.2.tar.gz
# cd glusterfs-3.0.2
# ./configure
# make
# make install
# ldconfig

Make sure /export/sda2 exists on both servers, this folder will contain the data stored on the volume.

On s01, do this.

# mkdir /etc/glusterfs
# cd /etc/glusterfs
# glusterfs-volgen --name storage01 s01:/export/sda2 s02:/export/sda2
# ln -s s01-storage01-export.vol glusterfsd.vol
# /etc/init.d/glusterfsd start

On s02, do this.

# mkdir /etc/glusterfs
# cd /etc/glusterfs
# glusterfs-volgen --name storage01 s01:/export/sda2 s02:/export/sda2
# ln -s s02-storage01-export.vol glusterfsd.vol
# /etc/init.d/glusterfsd start

On c01, do this.

# mkdir /etc/glusterfs
# cd /etc/glusterfs
# glusterfs-volgen --name storage01 s01:/export/sda2 s02:/export/sda2

Edit /etc/fstab on c01 and add the following line.

/etc/glusterfs/storage01-tcp.vol        /storage        glusterfs defaults,_netdev      0       0

The share can now be mounted on the client.

# mount /storage
# mount
...
/etc/glusterfs/storage01-tcp.vol on /storage type fuse.glusterfs (rw,allow_other,default_permissions,max_read=131072)

That’s it, for more failsafe setup, consider using –raid for the glusterfs-volgen command.

Syncing djbdns zones with rsync

I wrote earlier about publishing zones with djbdns. That post didn’t cover zone sync between djbdns servers. This small guide assumes we’ll be syncing all zones between two servers, s01 and s02.

Doing this by using ssh keys instead of regular login has the benefit of not asking for your password when syncing the zones. You can skip this step if you want.

On s01, do the following.

# ssh-keygen -t dsa
# scp ~/.ssh/id_dsa.pub s02:.ssh/authorized_keys

The edit the Makefile file in the root folder of djbdns on s01 and make it look like this.

remote: data.cdb
        /usr/bin/rsync -az -e ssh data.cdb s02:/etc/tinydns/root/data.cdb

data.cdb: data
        /usr/bin/tinydns-data

Adjust all paths according to your own setup.

Running make will now sync your zones to s02.

# make
/usr/bin/tinydns-data
/usr/bin/rsync -az -e ssh data.cdb s02:/etc/tinydns/root/data.cdb
#

Nagios and use_large_installation_tweaks

When trying to figure out what kind of performance difference one could expect when enabling use_large_installation_tweaks in Nagios I did some benchmarking.

I used two 256MB Rackspace instances running Ubuntu 9.10, one with Nagios 3 and one with Nginx. I only did HTTP checks.

With use_large_installation_tweaks disabled (the default) the setup managed to do around 2000 checks per minute. Enabled, it did around 7500. In other words, quite a difference.