<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>biotext.org.uk &#187; linux</title>
	<atom:link href="http://biotext.org.uk/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://biotext.org.uk</link>
	<description>Not a typewriter</description>
	<lastBuildDate>Sat, 05 Feb 2011 14:18:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Installing Spotify on Fedora 13</title>
		<link>http://biotext.org.uk/installing-spotify-on-fedora-13/</link>
		<comments>http://biotext.org.uk/installing-spotify-on-fedora-13/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 11:52:55 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[redhat]]></category>
		<category><![CDATA[spotify]]></category>

		<guid isPermaLink="false">http://biotext.org.uk/?p=496</guid>
		<description><![CDATA[I&#8217;ve recently taken possession of a flashy new workstation running Fedora, and with joy in my heart went to install Spotify on it, only to discover&#8230; Noooo&#8230; They only offer .deb packages for Debian and Ubuntu. Thankfully, the solution was easier than I thought. Do all the following as root&#8230; 1. Install dpkg, the Debian [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently taken possession of a flashy new workstation running Fedora, and with joy in my heart went to install <a href="http://www.spotify.com/uk/download/previews/">Spotify</a> on it, only to discover&#8230; Noooo&#8230; They only offer .deb packages for Debian and Ubuntu.</p>
<p>Thankfully, the solution was easier than I thought. Do all the following as root&#8230;</p>
<p>1. Install dpkg, the Debian package management tool:</p>
<p><code>yum install dpkg</code></p>
<p>2. Download the base package for your architecture, and the gnome support package, from here:</p>
<p><a href="http://repository.spotify.com/pool/non-free/s/spotify/">http://repository.spotify.com/pool/non-free/s/spotify/</a></p>
<p>3. Create a temp directory, and unpack them there (we want to check for clashes):</p>
<p><code>mkdir spotify<br />
cd spotify<br />
dpkg -x ../spotify-client-qt_0.4.7.132.g9df34c0-1_amd64.deb .<br />
dpkg -x ../spotify-client-gnome-support_0.4.7.132.g9df34c0-1_all.deb .</code></p>
<p>4. This gives you a directory tree starting at <code>/usr</code>. You can check for clashes like this:</p>
<p><code>find -not -type d -exec ls -l /'{}' \;</code></p>
<p>&#8230; and make sure there&#8217;s no files found.</p>
<p>5. Then re-extract them into your root partition (hence checking for clashes first):</p>
<p><code>dpkg -x ../spotify-client-qt_0.4.7.132.g9df34c0-1_amd64.deb /<br />
dpkg -x ../spotify-client-gnome-support_0.4.7.132.g9df34c0-1_all.deb /</code></p>
<p>6. Finally, we need to manually install qt-x11 as this dependency is needed:</p>
<p><code>yum install qt-x11</code></p>
<p>7. Then just type <code>spotify</code> and log in!</p>
<p>Seems pretty stable so far, apart from a couple of minor glitches.</p>
<p><strong>EDIT:</strong> As suggested by Tyson Key in <a href="http://getsatisfaction.com/spotify/topics/spotify_on_fedora_13_audio_skips">this thread</a>, I got rid of the audio glitches by starting the PulseAudio volume control (<code>/usr/bin/pavucontrol</code>) before Spotify. Maybe this adds some buffering or something.</p>
<p><em>N.B. I take no responsibility if this process damages your computer, your music collection, your hearing or your sanity. Try at your own risk :-)</em></p>
]]></content:encoded>
			<wfw:commentRss>http://biotext.org.uk/installing-spotify-on-fedora-13/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Tunnelling a connection through 2 servers via ssh</title>
		<link>http://biotext.org.uk/tunnelling-a-connection-through-2-servers-via-ssh/</link>
		<comments>http://biotext.org.uk/tunnelling-a-connection-through-2-servers-via-ssh/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 19:19:28 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[OS X]]></category>

		<guid isPermaLink="false">http://biotext.org.uk/?p=490</guid>
		<description><![CDATA[This took a bit of head-scratching, so for future reference, or anyone else looking: Say I am working outside the office firewall, on a machine called home, and I need to get into a MySQL server inside it. (Doesn&#8217;t have to be MySQL, but just for argument&#8217;s sake.) There&#8217;s a machine called gateway I can [...]]]></description>
			<content:encoded><![CDATA[<p>This took a bit of head-scratching, so for future reference, or anyone else looking:</p>
<p>Say I am working outside the office firewall, on a machine called <code>home</code>, and I need to get into a MySQL server inside it. (Doesn&#8217;t have to be MySQL, but just for argument&#8217;s sake.)</p>
<p>There&#8217;s a machine called <code>gateway</code> I can ssh to and tunnel through, but for security reasons, the database server <code>mysql</code> doesn&#8217;t accept connections from <code>gateway</code> directly. But my desktop machine at the office (err&#8230; <code>desktop</code>) can connect to <code>mysql</code>.</p>
<p>One way round it is to ssh from <code>home</code> to <code>gateway</code> and forward a port on <code>gateway</code> to the ssh server on <code>desktop</code>:</p>
<pre>
home $ ssh -L 2222:desktop.example.org:22 -tAY gateway.example.org
</pre>
<p>And then in another terminal, ssh from <code>home</code> to <code>desktop</code> via this tunnel, forwarding another port on <code>home</code> to the incoming connections port on <code>mysql</code> (3306 in MySQL&#8217;s case usually):</p>
<pre>
home $ ssh -p 2222 -L 23306:mysql.example.org:3306 127.0.0.1
</pre>
<p>This time, you&#8217;re connecting to <code>home</code> port 2222, but because of the first command, this forwards you straight to <code>desktop</code> port 22.</p>
<p>Now both tunnels are in place, you can just connect to port 23306 on <code>home</code> and arrive by magic at <code>mysql</code>. In another terminal (or from your MySQL GUI):</p>
<pre>
home $ mysql -uUSER -pPASS -h127.0.0.1 -P23306
</pre>
<p>This example shows a tunnel-within-a-tunnel. There should be a way to make this work using end-to-end tunnelling instead, I tried but didn&#8217;t get anywhere. But that might be due to ssh server restrictions on our equivalent of <code>gateway</code>.</p>
<p>If none of this means anything, there&#8217;s an <a href="http://magazine.redhat.com/2007/11/06/ssh-port-forwarding/">intro to ssh port forwarding here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://biotext.org.uk/tunnelling-a-connection-through-2-servers-via-ssh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Back up all MySQL databases to separate files</title>
		<link>http://biotext.org.uk/back-up-all-mysql-databases-to-separate-files/</link>
		<comments>http://biotext.org.uk/back-up-all-mysql-databases-to-separate-files/#comments</comments>
		<pubDate>Thu, 13 May 2010 12:24:47 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://biotext.org.uk/?p=463</guid>
		<description><![CDATA[Note to self &#8212; so I don&#8217;t have to think about it again next time. #!/bin/bash export MYSQL_PWD=myrootpassword BACKUP_DIR=/mnt/backups/mysql_backups DATE=`date -I` for dbname in `mysql -uroot --batch --skip-column-names -e &#34;show databases;&#34; &#124; grep -v information_schema`; do /usr/local/bin/mysqldump -u root $dbname &#124; gzip -9 &#62; $BACKUP_DIR/$dbname-$DATE.sql.gz done &#160; # Clear backups older than 7 days /usr/local/bin/find [...]]]></description>
			<content:encoded><![CDATA[<p>Note to self &#8212; so I don&#8217;t have to think about it again next time.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">MYSQL_PWD</span>=myrootpassword
<span style="color: #007800;">BACKUP_DIR</span>=<span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>backups<span style="color: #000000; font-weight: bold;">/</span>mysql_backups
<span style="color: #007800;">DATE</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> -I<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">for</span> dbname <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>mysql <span style="color: #660033;">-uroot</span> <span style="color: #660033;">--batch</span> <span style="color: #660033;">--skip-column-names</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;show databases;&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> information_schema<span style="color: #000000; font-weight: bold;">`</span>; <span style="color: #000000; font-weight: bold;">do</span>
	<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>mysqldump <span style="color: #660033;">-u</span> root <span style="color: #007800;">$dbname</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">gzip</span> <span style="color: #660033;">-9</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$BACKUP_DIR</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$dbname</span>-<span style="color: #007800;">$DATE</span>.sql.gz
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Clear backups older than 7 days</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #007800;">$BACKUP_DIR</span><span style="color: #000000; font-weight: bold;">/*</span>.sql.gz <span style="color: #660033;">-mtime</span> +<span style="color: #000000;">7</span> <span style="color: #660033;">-delete</span></pre></div></div>

<p>Edited to include compression. Remember to include full paths if you&#8217;re running it from a crontab, just in case.</p>
]]></content:encoded>
			<wfw:commentRss>http://biotext.org.uk/back-up-all-mysql-databases-to-separate-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Chrome (actually Chromium) on Centos</title>
		<link>http://biotext.org.uk/google-chrome-actually-chromium-on-centos/</link>
		<comments>http://biotext.org.uk/google-chrome-actually-chromium-on-centos/#comments</comments>
		<pubDate>Wed, 12 May 2010 13:25:19 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://biotext.org.uk/?p=461</guid>
		<description><![CDATA[Joy at last! Chris Staite from the University of Birmingham has built a statically-linked version of Chromium, the open source version of Google&#8217;s Chrome browser, for Centos. You can get it from here. I was getting so sick of Firefox&#8217;s slowness and bloat, and Chromium is so much snappier, and more memory-efficient too. Although to [...]]]></description>
			<content:encoded><![CDATA[<p>Joy at last!</p>
<p>Chris Staite from the University of Birmingham has built a statically-linked version of Chromium, the open source version of Google&#8217;s Chrome browser, for Centos.</p>
<p>You can <a href="http://www.cs.bham.ac.uk/~cxs548/chrome">get it from here</a>.</p>
<p>I was getting so sick of Firefox&#8217;s slowness and bloat, and Chromium is so much snappier, and more memory-efficient too.</p>
<p>Although to be fair, I don&#8217;t have nearly so many extensions installed yet&#8230;</p>
<p>It should just work out of the box with no extra dependencies to install. I&#8217;m using 64-bit Centos 5.4, and although it&#8217;s a 32-bit app, it seems entirely happy so far.</p>
]]></content:encoded>
			<wfw:commentRss>http://biotext.org.uk/google-chrome-actually-chromium-on-centos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Things to try when VirtualBox networking messes up</title>
		<link>http://biotext.org.uk/things-to-try-when-virtualbox-networking-messes-up/</link>
		<comments>http://biotext.org.uk/things-to-try-when-virtualbox-networking-messes-up/#comments</comments>
		<pubDate>Fri, 26 Mar 2010 09:52:40 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[VirtualBox]]></category>

		<guid isPermaLink="false">http://biotext.org.uk/?p=447</guid>
		<description><![CDATA[This is really a note-to-self but it might help other people too. I have two network interfaces in my Ubuntu guest (on OS X 10.4 host), one NAT, one host-only. Sometimes one of them doesn&#8217;t get an IP address &#8212; in ifconfig it has an inet6 address but not an inet address. Today I tried [...]]]></description>
			<content:encoded><![CDATA[<p>This is really a note-to-self but it might help other people too.</p>
<p>I have two network interfaces in my Ubuntu guest (on OS X 10.4 host), one NAT, one host-only.</p>
<p>Sometimes one of them doesn&#8217;t get an IP address &#8212; in ifconfig it has an inet6 address but not an inet address.</p>
<p>Today I tried</p>
<p><code>sudo dhclient eth1</code></p>
<p>and it worked &#8212; all it needed to do was re-query VirtualBox&#8217;s built-in DHCP server.</p>
<p>I would have thought this would do that automatically:</p>
<p><code>sudo /etc/init.d/networking restart</code></p>
<p>However that didn&#8217;t help&#8230; But dhclient did.</p>
<p>Another recurring problem is that when I move between different networks, DNS resolution gets screwed up. There&#8217;s a description of this with a suggested work around (using VBox&#8217;s DNS Proxy) here:</p>
<p>http://forums.virtualbox.org/viewtopic.php?f=1&#038;t=28332</p>
<p>However, while this seemed to help with two of the networks I use frequently, it didn&#8217;t with a third, even after rebooting.</p>
<p>So, as suggested on one or two threads, I&#8217;ve removed the DNSProxy setting, and set the Ubuntu guest to use Google&#8217;s public DNS servers instead of those provided by the DHCP server for the NATted virtual NIC. (Blah blah blah.) Follow example here (more or less):</p>
<p><a href="http://grumpymole.posterous.com/how-to-use-google-public-dns-or-opendns-in-ub">http://grumpymole.posterous.com/how-to-use-google-public-dns-or-opendns-in-ub</a></p>
<p>Seems to be working so far&#8230; But only tested on one of the offending networks, and without rebooting yet. Updates to come later.</p>
<p>&#8230; Nope, after upgrading to Snow Leopard and the latest VirtualBox (it&#8217;s now from Oracle &#8212; scary), random problems persist.</p>
<p>Sometimes I&#8217;ll lose guest-host connectivity in the middle of a session, without any sleep or other interruptions, but will still be able to see the internet from the NAT adaptor.</p>
<p>One possible solution here involving using OS X itself as the NAT router:</p>
<p><a href="http://akutz.wordpress.com/2009/08/20/building-a-better-os-x-firewall-or-how-i-solved-the-nat-problem-for-virtualbox/">http://akutz.wordpress.com/2009/08/20/building-a-better-os-x-firewall-or-how-i-solved-the-nat-problem-for-virtualbox/</a></p>
<p>&#8230; but it&#8217;ll take work.</p>
<p>Or maybe a simpler version of the same approach: have a single host-only adaptor, use OS X&#8217;s internet sharing to share the AirPort card, and manually tell the vbox to use 192.168.56.1 as the default gateway:</p>
<p><a href="http://forum.virtualbox.org/viewtopic.php?f=1&#038;t=26544">http://forum.virtualbox.org/viewtopic.php?f=1&#038;t=26544</a></p>
<p>If all else fails, try using a different ethernet hardware emulator.</p>
]]></content:encoded>
			<wfw:commentRss>http://biotext.org.uk/things-to-try-when-virtualbox-networking-messes-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MacBook keyboard hacks for # (hash/pound/numbersign)</title>
		<link>http://biotext.org.uk/macbook-keyboard-hacks-for-hash-pound-numbersign/</link>
		<comments>http://biotext.org.uk/macbook-keyboard-hacks-for-hash-pound-numbersign/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 14:32:09 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[VirtualBox]]></category>
		<category><![CDATA[X11]]></category>

		<guid isPermaLink="false">http://biotext.org.uk/?p=412</guid>
		<description><![CDATA[One of the few annoying things about my oldish MacBook Pro is its keyboard, for example a few unresponsive keys, but particularly the lack of a # key. It&#8217;s a UK keyboard, and has £ for shift-3, and # is hidden in alt-3 (not labelled). This is fine in native desktop apps, but less fine [...]]]></description>
			<content:encoded><![CDATA[<p>One of the few annoying things about my oldish MacBook Pro is its keyboard, for example a few unresponsive keys, but particularly the lack of a # key. It&#8217;s a UK keyboard, and has £ for shift-3, and # is hidden in alt-3 (not labelled).</p>
<p>This is fine in native desktop apps, but less fine in some text-mode programs (e.g. vim), when for some reason this often produces a superscript <sup>3</sup> instead.</p>
<p>So I&#8217;ve set up a custom keyboard mapping in iTerm to map F3 to #, which works nicely. <strong>However!</strong></p>
<p>If I&#8217;m SSHed in to a remote Linux machine (or even my local Ubuntu VirtualBox) neither of these keys work in X apps. But, xmodmap (via the config file ~/.Xmodmap) can help. For some reason, Macs all have a dedicated key for these characters &#8212; § and ± &#8212; which <em>no-one</em> ever uses. But with this line in ~/.Xmodmap we can remap it to produce #:</p>
<p>keycode 18=numbersign</p>
<p><strong>UPDATE:</strong> I&#8217;ve found a better way which works pretty much globally&#8230;</p>
<p>Using <a href="http://scripts.sil.org/Ukelele">Ukelele</a> you can copy the British keyboard layout and then remap keys to your heart&#8217;s content. I&#8217;ve moved the § character to the alt-§ key combination, in case I ever need it, and moved the # character to the raw § key. This seems to be respected <em>almost</em> everywhere so I don&#8217;t need to mess around with alt-3 or F3 any more. Joy. It also works over <a href="http://www.jinx.de/JollysFastVNC.html">JollysFastVNC</a> to a remote RealVNC server, which none of the other methods did.</p>
<p>Unfortunately, things still aren&#8217;t perfect. If I actually open a VirtualBox console session into GNOME on the local Ubuntu VM, the pointless § and ± key actually produces &lt; and &gt; so neither of these tricks work. In fact, I can&#8217;t get anything to generate a # even though I have the MacBook Pro Intl keyboard layout selected in GNOME. Any ideas?</p>
<p><strong>UPDATE 2:</strong> YES!! I&#8217;ve finally cracked it for VirtualBox. With the help of the xkeycaps command, I discovered that X the keycodes coming into Ubuntu weren&#8217;t what I thought they were &#8212; somewhere the Mac-ness of the keyboard layout was getting lost. It turned out that the § key was generating keycode 94 instead. So I set up this in .Xmodmap on the Ubuntu VM:</p>
<p>keycode 94=numbersign</p>
<p>Now it works in VirtualBox too. Leave gifts of thanks below :-)</p>
]]></content:encoded>
			<wfw:commentRss>http://biotext.org.uk/macbook-keyboard-hacks-for-hash-pound-numbersign/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Simple server status monitoring with PHP and Perl</title>
		<link>http://biotext.org.uk/simple-server-status-monitoring-with-php-and-perl/</link>
		<comments>http://biotext.org.uk/simple-server-status-monitoring-with-php-and-perl/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 16:05:59 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Research]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://biotext.org.uk/?p=229</guid>
		<description><![CDATA[Recently, one of our web servers fell victim to an apparent DoS attack, being hammered with hundreds of simultaneous dynamic page requests, far more than it&#8217;s specced to handle. To its credit, it stayed up, although it took about five minutes to log in via ssh, and when we spotted what was happening, the load [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, one of our web servers fell victim to an apparent DoS attack, being hammered with hundreds of simultaneous dynamic page requests, far more than it&#8217;s specced to handle. To its credit, it stayed up, although it took about five minutes to log in via ssh, and when we spotted what was happening, the load average was over 100 which I think is the most loaded I&#8217;ve ever seen. The offending IP address was at UCSD who do a lot of bioinformatics, so there is a chance it was a misguided attempt to scrape a lot of data from us, rather than an actual hostile act, but in any case the upshot is the same.</p>
<p>It worried me that there was no easy way to remotely check the machine&#8217;s health, so I hacked together a quick PHP page to report various vital statistics on demand &#8212; load average, memory usage, disk usage etc. &#8212; and a Perl monitor that can raise the alarm if anything exceeds safe bounds.</p>
<p><span id="more-229"></span>The status script itself really is dead simple, it looks like this:</p>
<pre class="brush: php">

&lt;?php
    # status.php -- very simple server status monitor
    header( &#039;Content-type: text/plain&#039; );
    # Get and display load average times 3
    $load = sys_getloadavg();
    echo &quot;LoadAverage1: $load[0]\n&quot;;
    echo &quot;LoadAverage5: $load[1]\n&quot;;
    echo &quot;LoadAverage15: $load[2]\n&quot;;
    # Get and display all sorts of memory usage info
    echo join( &#039;&#039;, file( &#039;/proc/meminfo&#039; ) );
    # Get and display disk usage percentages
    $df = `/bin/df`;
    foreach( split( &quot;\n&quot;, $df ) as $line )
    {
        if( preg_match( &quot;/(\d+%)\s+(\S+)$/&quot;, $line, $matches ) )
        {
            $fs = $matches[ 2 ];
            $usage = $matches[ 1 ];
            echo &quot;Usage_$fs: $usage\n&quot;;
        }
    }
    # Count running processes
    $procs = `/bin/ps -e|wc -l`;
    echo &quot;RunningProcesses: $procs\n&quot;;
?&gt;
</pre>
<p>It uses PHP&#8217;s built-in sys_getloadavg function to return the load average, df to get the disk usage, and ps and wc to count the number of processes running. These should work on any Unix-ish system (let me know if they don&#8217;t!). Also, it uses the /proc filesystem to read lots of metrics about memory use, and this is Linux-specific. It produces output that looks like this:</p>
<pre>LoadAverage1: 0.59
LoadAverage5: 0.4
LoadAverage15: 0.29
MemTotal:      2021816 kB
MemFree:        337592 kB
Buffers:         35408 kB
Cached:         286676 kB
SwapCached:       3152 kB
Active:        1115608 kB
Inactive:       102288 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:      2021816 kB
LowFree:        337592 kB
SwapTotal:     4192956 kB
SwapFree:      4185596 kB
Dirty:             304 kB
Writeback:           0 kB
AnonPages:      893740 kB
Mapped:         119900 kB
Slab:           256036 kB
PageTables:      21240 kB
NFS_Unstable:        0 kB
Bounce:              0 kB
CommitLimit:   5203864 kB
Committed_AS:  1433344 kB
VmallocTotal: 34359738367 kB
VmallocUsed:    280284 kB
VmallocChunk: 34359458043 kB
HugePages_Total:     0
HugePages_Free:      0
HugePages_Rsvd:      0
Hugepagesize:     2048 kB
Usage_/: 48%
Usage_/var: 9%
Usage_/tmp: 1%
Usage_/dev/shm: 0%
Usage_/export/people: 16%
Usage_/home/bsm: 79%
Usage_/LINUX/local64: 94%
Usage_/cath/opt: 13%
Usage_/cath/svnbin: 23%
Usage_/nfs/mail: 82%
Usage_/LINUX/local: 89%
RunningProcesses: 149</pre>
<p>The Perl monitoring script is a bit more complex, so I&#8217;ve made it available for download <a title="server status check script (Perl)" href="http://biotext.org.uk/static/server_status_check.pl.v0_1">here</a>. It lets you set up a config file with rules specifying named fields from the PHP script&#8217;s output, along with maximum and/or minimum allowable values for them. From the script&#8217;s comments:</p>
<pre>#!/usr/bin/perl

# server_status_check.pl
# Andrew Clegg
#
# This script parses the output of status.php and compares it to a
# list of minimum and maximum allowable values for server resources
# specified in a config file. The config file contains one rule per
# line, like so:
#
# min MemFree 7500000
# min Usage_/LINUX/local64 95
# max LoadAverage5 0.1
#
# Any line not in this format causes an error. Do not include any
# percent signs, units (e.g. kB) etc. in the config file; these
# are automatically stripped out from the results of status.php
# before applying the rules.
#
# For each resource that is lower than a min value or larger than
# a max value, a warning is printed. Also, if the config file
# contains any rules which name resources that are not found in
# the output of status.php at all, a warning is printed for each.
#
# It returns 0 if everything is fine, 255 if an error occurred, or
# the number of warnings issued if one or more of the resource
# rules are violated.</pre>
<p>You invoke the monitor script like this:</p>
<pre>./server_status_check.pl http://my.server/status.php my.config.file</pre>
<p>And it returns output that looks like this if anything rules from the config file are violated:</p>
<pre>MemFree has value 229472 which is less than minimum 250000
Usage_/ has value 86 which is greater than maximum 50
SomeIncorrectVariableName not found in server status report</pre>
<p>Since the return code is non-zero in case of a problem, you can easily use it in a cron job or shell script to take action when a server&#8217;s vital statistics move into dangerous ranges.</p>
<p>Of course, being PHP, you can use it from the command line for a quick summary of the local machine&#8217;s resources by just typing</p>
<pre>php status.php</pre>
<p>There are plenty more complex server monitoring tools out there, but you probably have to be a skilled sysadmin to use them, whereas these tools took a few hours to write, and five minutes to install. As usual, suggestions are welcome, and you are free to use them wherever and however you like, but please credit me and include a link back here.</p>
<p>Andrew.</p>
]]></content:encoded>
			<wfw:commentRss>http://biotext.org.uk/simple-server-status-monitoring-with-php-and-perl/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Installing Flash on 64-bit Linux (Centos 5)</title>
		<link>http://biotext.org.uk/installing-flash-on-64-bit-linux-centos-5/</link>
		<comments>http://biotext.org.uk/installing-flash-on-64-bit-linux-centos-5/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 16:23:59 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[64bit]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[redhat]]></category>

		<guid isPermaLink="false">http://biotext.org.uk/?p=166</guid>
		<description><![CDATA[This took a fair bit of searching, and the answer&#8217;s non-obvious&#8230; Everybody (?) knows that in theory, if you have 64-bit Firefox on 64-bit Linux (x86_64), you can use nspluginwrapper to install 32-bit plugins, like the Flash Player. There&#8217;s some instructions here for example. However, those instructions are flawed in two regards. Firstly, Flash Player [...]]]></description>
			<content:encoded><![CDATA[<p>This took a fair bit of searching, and the answer&#8217;s non-obvious&#8230;</p>
<p>Everybody (?) knows that in theory, if you have 64-bit Firefox on 64-bit Linux (x86_64), you can use <a href="http://gwenole.beauchesne.info/en/projects/nspluginwrapper">nspluginwrapper</a> to install 32-bit plugins, like the Flash Player. There&#8217;s some instructions <a title="Installing Flash Player 9 On 64Bit Linux (x86_64)" href="http://www.howtoforge.com/installing-flash-player9-on-64bit-linux">here</a> for example.</p>
<p>However, those instructions are flawed in two regards.</p>
<p><span id="more-166"></span>Firstly, Flash Player 10 doesn&#8217;t come with a .xpt file any more, but that&#8217;s not apparently a problem.</p>
<p>Secondly, and more mistifyingly, nspluginwrapper seems to require you to give the <strong>absolute </strong>path to the plugin&#8217;s .so file, for some reason. So if you get an error like this:</p>
<pre>$ nspluginwrapper -v -i libflashplayer.so
*** NSPlugin Viewer  *** ERROR: libflashplayer.so: cannot open
shared object file: No such file or directory
nspluginwrapper: no appropriate viewer found for libflashplayer.so</pre>
<p>Then try again with the full path to the plugin:</p>
<pre>$ nspluginwrapper -v -i /home/bsm/clegg/.mozilla/plugins/libflashplayer.so
Install plugin /home/bsm/clegg/.mozilla/plugins/libflashplayer.so
  into /home/bsm/clegg/.mozilla/plugins/npwrapper.libflashplayer.so</pre>
<p>Restart Firefox, and away you go, joy! No feeling for stability yet, but I&#8217;ll post again if there are any problems.</p>
<p>Incidentally, I first tried installing nspluginwrapper via yum, and got a whole bunch of unsatisfied dependencies:</p>
<pre>Error: Package devhelp needs libgtkembedmoz.so, this is not available.
Error: Package devhelp needs libxpcom.so, this is not available.
Error: Package devhelp needs gecko-libs = 1.8.0.12, this is not available.</pre>
<p style="text-align: left;">Then I just tried installing the RPMs from the<a href="http://gwenole.beauchesne.info/en/projects/nspluginwrapper"> nspluginwrapper home page</a> (first the one marked Viewer, then the one marked Plugin) and it worked like a charm.</p>
<p style="text-align: left;">Hat tip to <a title="Ubuntu Forums" href="http://ubuntuforums.org/showthread.php?t=646167">this thread on the Ubuntu Forums</a> for finally revealing the key bit of information about absolute vs. relative paths.</p>
<p style="text-align: left;"><strong>UPDATE:</strong> Aaargh, sound doesn&#8217;t work. But that seems to be the fault of my ALSA drivers rather than Flash or nspluginwrapper. Apparently Flash can only use ALSA for sound, and not any of the other various Linux sound architectures, and only OSS works on this PC&#8230;</p>
<p style="text-align: left;">Andrew.</p>
]]></content:encoded>
			<wfw:commentRss>http://biotext.org.uk/installing-flash-on-64-bit-linux-centos-5/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Updating Subversion on 64-bit Linux (Centos 5)</title>
		<link>http://biotext.org.uk/updating-subversion-on-64-bit-linux-centos-5/</link>
		<comments>http://biotext.org.uk/updating-subversion-on-64-bit-linux-centos-5/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 11:18:28 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[64bit]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[redhat]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://biotext.org.uk/?p=102</guid>
		<description><![CDATA[I just ran into a problem when trying to upgrade to the latest rpm-packaged version of Subversion on Centos 5 x86_64 &#8212; simple solution, but not obvious, so hopefully this will help someone. It goes like this, as root: $ yum update subversion [normal messages snipped] Transaction Check Error:   file /usr/share/emacs/site-lisp/psvn.el from install of [...]]]></description>
			<content:encoded><![CDATA[<p>I just ran into a problem when trying to upgrade to the latest rpm-packaged version of Subversion on Centos 5 x86_64 &#8212; simple solution, but not obvious, so hopefully this will help someone.</p>
<p>It goes like this, as root:</p>
<pre>$ yum update subversion</pre>
<p>[normal messages snipped]</p>
<pre>Transaction Check Error:
  file /usr/share/emacs/site-lisp/psvn.el
from install of subversion-1.5.5-0.1.el5.rf
conflicts with file from package subversion-1.4.2-2.el5
  file /usr/share/man/man1/svn.1.gz
from install of subversion-1.5.5-0.1.el5.rf
conflicts with file from package subversion-1.4.2-2.el5
  file /usr/share/man/man1/svnadmin.1.gz
from install of subversion-1.5.5-0.1.el5.rf
conflicts with file from package subversion-1.4.2-2.el5
  file /usr/share/man/man1/svnlook.1.gz
from install of subversion-1.5.5-0.1.el5.rf
conflicts with file from package subversion-1.4.2-2.el5
  file /usr/share/man/man5/svnserve.conf.5.gz
from install of subversion-1.5.5-0.1.el5.rf
conflicts with file from package subversion-1.4.2-2.el5
  file /usr/share/man/man8/svnserve.8.gz
from install of subversion-1.5.5-0.1.el5.rf
conflicts with file from package subversion-1.4.2-2.el5
  file /usr/share/xemacs/site-packages/lisp/psvn.el
from install of subversion-1.5.5-0.1.el5.rf
conflicts with file from package subversion-1.4.2-2.el5</pre>
<p>WTF? Surely doing an update is supposed to replace files from an earlier release with a later one?</p>
<p><span id="more-102"></span>The reason, as my colleague <a title="Ian Sillitoe" href="http://cathdb.info/wiki/doku.php?id=cathteam:sillitoe">Ian</a> discovered, is that 64-bit Centos has both 32 and 64-bit versions of Subversion, which causes it to get its knickers in a twist when doing an update. So we just did the following:</p>
<pre>$ yum erase subversion.i386
$ yum update subversion</pre>
<p>to remove the 32-bit version and then just update the 64-bit one. Works fine. (Touch wood&#8230;)</p>
<p>Probably works with Redhat Enterprise (RHEL) too and possibly other distros.</p>
<p><strong>EDIT:</strong> If you only have the Centos base RPM repository, you won&#8217;t find svn 1.5.5 (or any recent versions). You need to set your system up to use RPMForge as well, as documented <a href="http://www.ultranetsolutions.com/CentOS-5-install-rpmforge-yum-repo.html">here</a>. Thanks to GR in the comments for pointing this out.</p>
<p>Andrew.</p>
]]></content:encoded>
			<wfw:commentRss>http://biotext.org.uk/updating-subversion-on-64-bit-linux-centos-5/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

