New HDD for my server

February 18, 2010 at 10:36pm Tagged: , with 0 Comments

I've been having some problems with the old(ish) 80GB HDD I've been using with my server—it developed bad sectors which made any disk-related operation (even (un)mounting partitions on different physical devices, for some reason) incredibly slow. I'm not exaggerating when I say that rebooting took about 45 minutes to an hour. Also, the bad sectors caused loads of error output to be logged and, as I thought a 5GB root partition would be more than enough, that quickly filled causing more problems…

So, yesterday I ordered a 160GB 2.5" SATA HDD, and it arrived today. I barely used any of the 80GB one, so I'm not sure what I'll do with 160GB… It took me about six hours to migrate from the old HDD to the new. If it wasn't so slow on (un)mounting, it'd have taken me about an hour, needless to say, today has been very frustrating.

…but, dear gods! I can't believe how much that HDD was slowing things down! I only really noticed it in mounting and doing large read/writes, but the whole thing is just so much faster! Of course, some of that will be due to changing to a SATA HDD from an old ATA one, and perhaps from using ext4 on most of the partitions instead of JFS, but the difference is really amazing. Things I had attributed to a limitation of my network speed—such as copying large numbers of files back and forth—now soar along. It's incredible really.

With a large disk, I decided to split up the whole into many partitions, so it's less likely for, say misbehaving log files, to grind the system to a halt. Also, I wanted to play with ext4, I've used JFS as my filesystem of choice for so long now I don't remember my initial reasons for doing so, but when I did settle on it, ext4 hadn't entered the mix so JFS might not be the best for me any more… But, I couldn't bring myself to fully leave JFS behind, so I settled on this partitioning scheme:

  • /boot: 128MiB, ext2
  • /: 15GiB, ext4
  • /home: 15GiB, ext4
  • /usr: 15GiB, ext4
  • /var: 15GiB, ext4
  • /srv: 100GiB, JFS

Of course, /srv isn't really 100GiB, but you know what I mean. The remaining space after 60ish GiB had been used for other things.

A short while ago I was looking at the Arch wiki article for installing a system with software RAID and LVM, it looks pretty simple. I've always imagined RAID and LVM as incredibly complex beasts only understandable by server admins. But, well, I am a server admin (albeit for a server with about three users), and it didn't seem too complex. So, at some point in the future when I have money and time to waste, I'll consider getting another two HDDs and setting up RAID 5 or something. I'll probably be on a new motherboard before then, though, as the one I'm using at the moment has only two SATA ports (and one PCI port, which is likely to be a more imminent limitation).

I have designs to, by the end of the year, have transformed my server into a much more powerful beast. Watch this space…

XMPP Status Updates

February 2, 2010 at 8:03pm Tagged: , and , with 0 Comments

Yesterday I had the idea of writing a cronjob to, every five minutes say, check things like the CPU load and temperature, and send me a message via Jabber is anything was amiss. I then realised that I could have this script send me a list of new posts in my RSS feeds, and a list of package updates, and even a notification when a torrent is done.

Today, I found sendxmpp, which, according to the website, “is a perl-script to send xmpp (jabber), similar to what mail(1) does for mail.” This seemed perfect for my needs, so I installed it, wrote the configuration file, ~/.sendxmpprc, which is in the following format and must be mode 0600:

# A comment
username@hostname password

The command itself is invoked as follows:

echo "message goes here" | sendxmpp jid

A subject can be given, but for my purposes that was unnecessary. I wrote a script to run be run by cron at 5 minute intervals to alert me if the fan speed, CPU and HDD temperatures, or load average crossed certain thresholds, as well as checking on my torrents and telling me if any had finished since the last message:

#!/bin/zsh

memmax=993.0

fanspeed=`sensors | grep fan1 | sed -e "s/fan1:\s*\([0-9]*\).*/\\1/"`
cputemp=`sensors | grep temp3 | sed -e "s/temp3:\s*+\([0-9]*\).*/\\1/"`
hddtemp=`sudo hddtemp -n /dev/sda`
memusage=`free -m | grep "buffers/cache" | sed -e "s/-\/+ buffers\/cache:\s*\([0-9]*\)\s*\([0-9]*\).*/\\1/"`
loadavg=`uptime | sed "s/.*load average: \(.*\)/\\1/"`

memcheck=$[ `free -m | grep 'buffers/cache' | sed 's/.*\([0-9][0-9][0-9]\).*[0-9].*/\1/'` / $memmax * 100 ]
loadcheck=`echo "$[\`uptime | sed "s/.*load average: \([0-9\.]*\)/\\1/" | sed "s/, .*//"\` * 100]" | sed "s/\..*//"`

# Add notifications about the system not acting as it should - 2 spaces after the ] to line up with torrent messages.
[ $fanspeed  -ge 4750 ] && echo "[status]  Northbridge fan speed too high: $fanspeed RPM" >> /tmp/xmppmessages
[ $cputemp   -ge 50   ] && echo "[status]  CPU temperature too high: $cputemp °C"         >> /tmp/xmppmessages
[ $hddtemp   -ge 45   ] && echo "[status]  HDD temperature too high: $hddtemp °C"         >> /tmp/xmppmessages
[ $memcheck  -gt 33    ] && echo "[status]  Memory usage too high: $memusage / $memmax MB" >> /tmp/xmppmessages
[ $loadcheck -ge 50   ] && echo "[status]  Load averages too high: $loadavg"              >> /tmp/xmppmessages

# Only show torrents whose status has changed
if [[ ! -f /tmp/torrentstatus ]]; then
    w3m -dump "http://localhost/rtorrentinfo.php?seed=1" | awk '{print "[torrent] " $0}' > /tmp/torrentstatus
    cat /tmp/torrentstatus >> /tmp/xmppmessages
else
    w3m -dump "http://localhost/rtorrentinfo.php?seed=1" | awk '{print "[torrent] " $0}' > /tmp/torrentstatus2
    comm -1 -3 /tmp/torrentstatus /tmp/torrentstatus2 >> /tmp/xmppmessages
    mv /tmp/torrentstatus2 /tmp/torrentstatus
fi

# Send and clear the messages
sendxmpp mike@barrucadu.co.uk < /tmp/xmppmessages
echo > /tmp/xmppmessages

The reason I use a file to store the messages and then send them all in one go is because various other scripts append text to it—such as my hourly pacman database sync to notify me of new updates, and my hourly RSS sync, to notify me of new messages.

rtorrentinfo.php is a simple script I wrote to list seeding or leeching torrents, along with how much is complete (for leeching packages). I don't think it's overly relevent to the topic of the post, so if you want it, ask in the comments or send me an email.

My Server

January 14, 2010 at 11:08am Tagged: and , with 1 Comment

I've decided to remove the generally weeks-out-of-date server page from my website and instead post about it here whenever I do a significant or interesting change. So, this post isn't really anything new, it's just covering/updating the server page that currently exists.

My server was built on the 22nd of July, 2009, and is named Eihort. All of my computers are named after Great Old Ones—some people use celestial bodies or flowers as a naming scheme, I use ancient powerful deities waiting for the stars to be right to destroy us all…

Hardware

Motherboard
Gigabyte GA-GC230D
Processor
Intel Atom 230
Case
Compucase 8K07
PSU
120W
HDD
60GB 2.5" Fujitsu MHT2060AT
Memory
1GB DDR2

Functionality

Currently my server is being a jack-of-all-trades, everything I can think of that a networked computer would be useful for (NTP server, SAMBA, torrenting, bitlbee, …) it does. So, rather than list all of the software used on it I'll just describe what it does:

Web server
I have a local webserver which contains my homepage, the control panel for the server, and various other utilities. It also houses my RSS/Atom feed aggregator which checks for updates hourly.
IM
Ok, this isn't likely to change, so I'll name the software. I run bitlbee, so I can IM from my laptop without having to install any extra IM software, and use just an IRC client.
Media player
I have a portable HDD full of music, and some pretty good 2.1 speakers on my desk. These are hooked up to the server, on which I run various utility programs you can find on my code page.
File sharing/downloading
I have a few network shares on the server (notably: /media, so I can share any attached devices), as well as a torrent client and HTTP download manager. The torrents and downloads only run between midnight and 8AM though, as that is when my bandwidth is free.
Utilities
And all the rest: openntpd, sshd, uptimed, etc.

Particularly Handy

There are a couple of things the server does that are particularly handy, such as downloading updates for my laptop: my laptop sends a list of updates to the server through the network share, the server downloads them, and sticks them on the share for my laptop to pick up and move to the pacman cache; and adserver blocking: I download a big list of adservers every month via cron and parse it to generate a blocklist using BIND, so any computer using my server as its main DNS server is (mostly) ad-free when browsing.

Status Script

This is my favourite achievement on the server, a status/administration script written in PHP that can tell you how much bandwidth has been used by individual users of the proxy server, start and stop torrents, edit the DNS blacklist, et cetera. To get an idea of what it does check the source code in github.

There's also a nigh-perpetually outdated screenshot here.

Photos

Photos from the assembly and set-up:

1 2 3 4 5 6 7 8 9