<?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>Daniel Hall&#039;s Website &#187; System Administration</title>
	<atom:link href="http://www.danielhall.me/category/computing/linux/system-administration/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.danielhall.me</link>
	<description>Because the Internet doesn&#039;t have enough opinions already</description>
	<lastBuildDate>Sun, 23 Oct 2011 23:15:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>Error messages aren&#8217;t perfect</title>
		<link>http://www.danielhall.me/2011/04/error-messages-arent-perfect/</link>
		<comments>http://www.danielhall.me/2011/04/error-messages-arent-perfect/#comments</comments>
		<pubDate>Wed, 20 Apr 2011 11:03:49 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[System Administration]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Error]]></category>
		<category><![CDATA[NetWare]]></category>
		<category><![CDATA[NFS]]></category>
		<category><![CDATA[Novell]]></category>
		<category><![CDATA[Strace]]></category>
		<category><![CDATA[X]]></category>
		<category><![CDATA[Xauth]]></category>

		<guid isPermaLink="false">http://www.danielhall.me/?p=516</guid>
		<description><![CDATA[When diagnosing a problem with a complex system such as Linux you sometimes need to step back, stop what you&#8217;re doing and take a different approach. Usually when a program fails on Linux you will get some kind of error &#8230;<p class="read-more"><a href="http://www.danielhall.me/2011/04/error-messages-arent-perfect/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>When diagnosing a problem with a complex system such as Linux you sometimes need to step back, stop what you&#8217;re doing and take a different approach. Usually when a program fails on Linux you will get some kind of error message, traceback or coredump. Most people prefer to see some kind of error message rather than the latter two..</p>
<p>Tracebacks and coredumps are computer generated, which makes them more accurate then error messages, but harder for humans to understand. Error messages however are put in place by the programmer which means they can occasionally be misleading, inaccurate, ambiguous or just plain wrong. This is not always the programmers fault, sometimes its hard to describe exactly what went wrong. Other times the error describes the situation perfectly, but the sysadmin jumps to a different conclusion based on his circumstances.</p>
<h2>Example</h2>
<p>Some time ago we had some users complaining about a problem when trying to use X Forwarding via SSH. On this server /home was mounted off a Novell NetWare NFS share. They were getting the following output and were unable to run X11 applications.</p>
<p>[code]xauth: error in locking authority file /home/daniel/.Xauthority[/code]</p>
<p>Seeing this error I assumed that something was going wrong with the locking mechanism of NFS. I tried mounting the NFS share with the explicit lock option, but the same error remained. I tried explicitly giving the sync option too, but to no avail. I ended up trying many different NFS options until eventually I gave up and asked the Novell administrators to check their servers. I was convinced that something on their end was causing this locking error.</p>
<p>The Novell administrator responded that they could see nothing wrong on their end. This must mean that something was wrong on our side. I tried restarting the nfsstad and lockd initscripts and the whole machine but once again the same issue persisted. I checked the server using the rpcinfo command, which showed that everything was working fine. I even connected to the daemon using telnet (though I couldn&#8217;t talks its language) and confirmed a firewall was not in the way.</p>
<p>I thought that maybe there was something going wrong in the interaction between the client and the server, so I ran a tcpdump to capture all the packets transferred between them. this is where I made a small breakthrough. I found a NFS reply that had returned with SERVFAIL and error code 526. Googling for this error and Netware generally pointed towards a problem with character sets not getting preserved to the Novell server. There was nothing but ordinary characters on the filesystem, so much for that idea.</p>
<p>I wanted to know exactly what was happening when xauth was trying to lock the file, so I did an strace on it. Here are the last few lines (after xauth mmaped its libraries).:</p>
<p>[code]stat(&quot;/home/e71377/.Xauthority-c&quot;, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0<br />
unlink(&quot;/home/e71377/.Xauthority-c&quot;)    = 0<br />
unlink(&quot;/home/e71377/.Xauthority-l&quot;)    = -1 ENOENT (No such file or directory)<br />
open(&quot;/home/e71377/.Xauthority-c&quot;, O_WRONLY|O_CREAT|O_EXCL, 0600) = 3<br />
close(3)                                = 0<br />
link(&quot;/home/e71377/.Xauthority-c&quot;, &quot;/home/e71377/.Xauthority-l&quot;) = -1 ESERVERFAULT (Unknown error 526)<br />
write(2, &quot;xauth:  error in locking authori&quot;..., 65xauth:  error in locking authority file /home/e71377/.Xauthority<br />
) = 65<br />
exit_group(1)                           = ?[/code]</p>
<p>So it appears that this was not a file locking problem at all. xauth was successfully creating the files but it failed when it tried to create a hardlink. Reviewing the code for libXau (AuLock.c) revealed exactly why:</p>
<p>[code lang="c"]    while (retries &gt; 0) {<br />
        if (creat_fd == -1) {<br />
            creat_fd = open (creat_name, O_WRONLY | O_CREAT | O_EXCL, 0600);<br />
            if (creat_fd == -1) {<br />
                if (errno != EACCES)<br />
                    return LOCK_ERROR;<br />
            } else<br />
                (void) close (creat_fd);<br />
        }<br />
        if (creat_fd != -1) {<br />
#ifndef X_NOT_POSIX<br />
            /* The file system may not support hard links, and pathconf should tell us that. */<br />
            if (1 == pathconf(creat_name, _PC_LINK_MAX)) {<br />
                if (-1 == rename(creat_name, link_name)) {<br />
                    /* Is this good enough?  Perhaps we should retry.  TEST */<br />
                    return LOCK_ERROR;<br />
                } else {<br />
                    return LOCK_SUCCESS;<br />
                }<br />
            } else {<br />
#endif<br />
                if (link (creat_name, link_name) != -1)<br />
                    return LOCK_SUCCESS;<br />
                if (errno == ENOENT) {<br />
                    creat_fd= -1;       /* force re-creat next time around */<br />
                    continue;<br />
                }<br />
                if (errno != EEXIST)<br />
                    return LOCK_ERROR;<br />
#ifndef X_NOT_POSIX<br />
           }<br />
#endif<br />
        }<br />
        (void) sleep ((unsigned) timeout);<br />
        --retries;<br />
    }[/code]</p>
<p>xauth isn&#8217;t trying to lock the file through flock() or another file locking method, which means that it is not the cause. Instead xauth is creating a file, and then to make sure it is the only program altering .Xauthority it creates a link. If the link succeeds then its the only program, if not then another program has the lock. The problem happens when xauth tries to make the hardlink. Interestingly there is a fallback for non-POSIX systems, but as RHEL is POSIX compatible it is not used.</p>
<p>It appeared that the NFS server did not support hard links. To test this theory I created several files, and attempted to create hard links using &#8216;cp -l file1 file2&#8242;. and they failed in the exact same way. All I had to do now was explain to the Novell Administrator that the problem was not locking, and was in fact that we were mounting a filesystem which did not support hard links on a POSIX compatible system. The Novell share was changed to support hard links (don&#8217;t ask me how, I&#8217;m not a Novell guy) and everything was working again.</p>
<h2>Conclusion</h2>
<p>The lesson to take away from here is not that hardlinks are required on POSIX, or that xauth doesn&#8217;t use file locking but locks itself via a dance of hardlinks. The lesson here is that you should never trust error messages. Take them as a hint, use them as a starting point but do not take them as law. You need to remember that the error message was written by a human and you may not be interpreting it how it was written.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielhall.me/2011/04/error-messages-arent-perfect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mod_pagespeed is not (always) the answer</title>
		<link>http://www.danielhall.me/2011/04/mod_pagespeed-is-not-always-the-answer/</link>
		<comments>http://www.danielhall.me/2011/04/mod_pagespeed-is-not-always-the-answer/#comments</comments>
		<pubDate>Wed, 13 Apr 2011 10:59:44 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[System Administration]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[mod_pagespeed]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Profiling]]></category>
		<category><![CDATA[Web Page Performance]]></category>

		<guid isPermaLink="false">http://www.danielhall.me/?p=676</guid>
		<description><![CDATA[What is mod_pagespeed Google recently released a chunk of code in the form of an Apache module. The idea is that you install it in your Apache server, it sits in between your application and the web browser and modifies &#8230;<p class="read-more"><a href="http://www.danielhall.me/2011/04/mod_pagespeed-is-not-always-the-answer/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<h2>What is mod_pagespeed</h2>
<p>Google recently released a chunk of code in the form of an Apache module. The idea is that you install it in your Apache server, it sits in between your application and the web browser and modifies the served requests to make the page load faster.<br />
It does this by using combinations of filters, some are well known best practices, others are newer ideas. For example on filter simply minifies your JavaScript while another embeds small images in a page using data-uris. The changes these filters make range from low risk, to high risk. It should be noted that not all the filters will improve the page time some even making pages slower in some cases.</p>
<h2>So what&#8217;s the issue?</h2>
<p>The issue here really isn&#8217;t mod_pagespeed, but it&#8217;s the way people are viewing it. In my job as a Web Performance Engineer I have had several people recently say to me &#8220;let&#8217;s put mod_pagespeed on our web server to make it faster&#8221;. This is a break from normal attitudes, if someone were to to say &#8220;we should put our images into data-uris&#8221; then people would question the speed benefit, or the extra load on the server. For some reason when Google implement a page speed module people just assume that it will make their page faster, and that it will work in their environment. The truth is that Google really have no idea what the module will do to your page.</p>
<p>The second issue is that all these tweaks can usually be better implemented at the application level. If you minimize all your JavaScript as part of your build process then the web server will not have to do it for you. The same applies to data-uris. If they are simply part of the page then the browser doesn&#8217;t need to read in the extra image, uuencode it, then compress it. All that is quite a lot of work, which only really needs to be done once.</p>
<h2>So what should I use mod_pagespeed for then?</h2>
<p>You don&#8217;t always have access to the application code. If you are using third party software then before mod_pagespeed you may have had no control over the minification of CSS. This is where the module really shines. It gives you a layer between the application code and the web browser where you can apply all sorts of performance tuning.</p>
<p>The other advantage I can see is for looking for the best tunings to apply to your application quickly. You can setup mod_pagespeed and and run experimental tests with the filters on of and with a control to quickly figure out what rules you should apply in your application.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielhall.me/2011/04/mod_pagespeed-is-not-always-the-answer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rebooting with &#8216;The Big Hammer&#8217;</title>
		<link>http://www.danielhall.me/2010/12/rebooting-with-the-big-hammer/</link>
		<comments>http://www.danielhall.me/2010/12/rebooting-with-the-big-hammer/#comments</comments>
		<pubDate>Sun, 12 Dec 2010 00:57:40 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[System Administration]]></category>
		<category><![CDATA[Desperation]]></category>
		<category><![CDATA[Emergency]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Overkill]]></category>
		<category><![CDATA[Recovery]]></category>

		<guid isPermaLink="false">http://www.danielhall.me/?p=670</guid>
		<description><![CDATA[Today I had a machine I was working on spit the dummy in a really bad way. It had a tonne of IO errors to its root filesystem and eventually decided to remount it read only. Of course this meant &#8230;<p class="read-more"><a href="http://www.danielhall.me/2010/12/rebooting-with-the-big-hammer/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Today I had a machine I was working on spit the dummy in a really bad way. It had a tonne of IO errors to its root filesystem and eventually decided to remount it read only. Of course this meant that it was almost entirely wedged. I tried the reboot command, the init command and everything would lockup my terminal. Not having console or physical access to the machine I couldn&#8217;t simply hit the power button, so I used the Linux magic commands:<code></code></p>
<p><code><br />
# echo 1 &gt; /proc/sys/kernel/sysrq<br />
# echo b &gt; /proc/sysrq-trigger<br />
</code></p>
<p>Of course the disk errors meant that it was unable to boot but &#8216;The Big Hammer&#8217; struck me as something extremely useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielhall.me/2010/12/rebooting-with-the-big-hammer/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Protecting Email with DKIM</title>
		<link>http://www.danielhall.me/2010/07/protecting-email-with-dkim/</link>
		<comments>http://www.danielhall.me/2010/07/protecting-email-with-dkim/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 12:57:19 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[System Administration]]></category>
		<category><![CDATA[DKIM]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[Mail]]></category>
		<category><![CDATA[Phishing]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Spam]]></category>

		<guid isPermaLink="false">http://www.danielhall.me/?p=629</guid>
		<description><![CDATA[One of the problems with the email and the protocols used to transfer it (SMTP) is that they were designed long ago when the Internet was a much friendlier place. When SMTP was designed it was assumed that other hosts &#8230;<p class="read-more"><a href="http://www.danielhall.me/2010/07/protecting-email-with-dkim/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>One of the problems with the email and the protocols used to transfer it (SMTP) is that they were designed long ago when the Internet was a much friendlier place. When SMTP was designed it was assumed that other hosts on the Internet could be trusted. This is particularly visible in the configuration of relays where the sender doesn&#8217;t have to be identified. A mail relay will accept mail from any server regardless of where the mail appears to be coming from.</p>
<p>To attempt to rectify this SPF was created. To setup SPF you add either a TXT or an SPF record to the DNS zone you will be sending from. This record defines which servers are allowed to send mail that is coming from that domain. So on my domain danielhall.me I could publish an SPF record that says only my mail server is allowed to send mail that ends in @danielhall.me. Any mailservers receiving mail that is from my domain but not coming from an address listed in my SPF record can see that the mail is likely forged and throw it away. SPF works well in most situations but fails at a very common use case. If someone I send mail to tries to forward it to another address using an automatic process (no clicking forward in their client) then the mail will appear to come from my domain when it gets to the user it was forwarded to, however it will have came from the original recipients mailserver.</p>
<p>DKIM solves this problem by giving each sending mailserver a cryptographic key pair. The public keys is then published in a DNS record in that zone and stores the private key somewhere safe on the server. The server then proceeds to sign the headers (especially the From: header) and the body of all outgoing emails. This signature is then attached to the email as an extra header. When the receiving server get the email it gets the signature and uses that along with the list of signed headers to verify the signature against the public key of the signing domain. This means as long as the mail has passed through an authorised mailserver at any point it will be considered valid.</p>
<p>Setting up a DKIM is relatively simple process. You will need access to the  zone records for your domain and access to the configuration of all the mailservers which all mail originating at your domain passes through. You also need to be aware that signing mail makes it slightly more processor intensive to send an email. If you send a large amount of email this difference could be quite significant. If you&#8217;re using sendmail you may be able to alleviate it by switching to a less resource hungry MTA like Exim. You should also note that in some configurations DKIM can not be setup. For example if you use masquerading in sendmail DKIM will always fail as sendmail will modify the from header after signing.</p>
<p>Ultimately DKIM is a good move for the internet community at large, especially when combined with SPF. DKIM mail is assured to come from the sender and can be cryptographically proven so. While it does take more take a little more effort to setup and maintain it assures mail from your domain is secure and can be assured to have come from you or your company. Ultimately DKIM can protect your company against phishing attempts and boost your spam scores.</p>
<p><strong>Random thought:</strong> What would Email look like if it were designed today?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielhall.me/2010/07/protecting-email-with-dkim/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SSH Agent Forwarding</title>
		<link>http://www.danielhall.me/2009/08/ssh-agent-forwarding/</link>
		<comments>http://www.danielhall.me/2009/08/ssh-agent-forwarding/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 23:01:29 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://www.danielhall.me/?p=160</guid>
		<description><![CDATA[So you use keys to SSH between your hosts, and you either have separate keys for each machine you use, or worse you have the same key on each machine. Lets go over why each of those are bad, and &#8230;<p class="read-more"><a href="http://www.danielhall.me/2009/08/ssh-agent-forwarding/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>So you use keys to SSH between your hosts, and you either have separate keys for each machine you use, or worse you have the same key on each machine. Lets go over why each of those are bad, and lets see how SSH Agent forwarding will help with those issues and make things easier for you in general.</p>
<p>So the key part of why a SSH agent and SSH agent forwarding forwarding is so useful is due to the way keys can be attacked. If I wanted to get your SSH private key I could find some flaw in the system that would give me that /home/you/.ssh/id_rsa file you have. Of course a malicious user with root access to the system could just go in and grab it. You can prevent this kind of attack by setting a passphrase on the key. Of course the root user could replace SSH with a special version designed to get your passphrase, steal the key out of memory or setup a keylogger. This means effectively that your private key is not safe on any system where a person you don&#8217;t trust has root access, or has other users and exploitable vulnerabilities.</p>
<h2>Single Private Key on Multiple Machines</h2>
<p>In this example you&#8217;re trusting the security of every single machine you have your private key on. Should it get compromised then you have to revoke you public key from every host, and regenerate private keys to place on every host. Every time you put your private key on a machine you increase the chances that it could be compromised.</p>
<h2>Multiple Private Keys On Multiple Machines</h2>
<p>So we&#8217;re getting a little closer to a good solution. In this instance we don&#8217;t have to generate our key and roll it out to all hosts in event of a compromise. You can also have segregate groups, on set of keys for work, another for home and so on. Your keys can still be compromised easily though, and once compromised they can be used until you revoke them manually.</p>
<h2>SSH Agent Forwarding</h2>
<p>There is a way to keep your key safe from compromise. Now I&#8217;ll have to explain how SSH authenticates you using your key. When your authenticating with SSH keys your key isn&#8217;t sent, the server sends you some random data and challenges your client to encrypt it with your private key. It then verifies the encrypted data by decrypting it with the public key and checking if it matches the data originally sent. Now the way most people would SSH from the second host to another third host is to utilise a private key on the second host to connect to the third host. Unfortunately this method means that you have to store a key (that is open for compromise) on the second host. SSH agent forwarding tells the SSH client on the second server to send the challenge data through to the SSH client (or ssh agent) on the first host. The agent encrypts the data and sends it via the SSH session to the third client.</p>
<p>The beauty of this method is that the second host never sees a private key, and the challenge data is useless to try and connect to a different host. Even if the second host is compromised there isn&#8217;t a private key there to compromise. It should be noted that if the second host is compromised it can still request the agent identify for a different host, or the session to the third host can be taken over. Both these are temporary though and unless the malicious user installs their key (something easy to notice) they cannot get back in.</p>
<div id="attachment_173" class="wp-caption alignright" style="width: 160px"><a href="http://www.danielhall.me/wp-content/uploads/2009/08/SSHAgent.png"><img class="size-thumbnail wp-image-173 " title="SSHAgent" src="http://www.danielhall.me/wp-content/uploads/2009/08/SSHAgent-150x150.png" alt="Diagram detailing how an SSH connection is authenticated using agent forwarding." width="150" height="150" /></a><p class="wp-caption-text">Diagram detailing how an SSH connection is authenticated using agent forwarding.</p></div>
<p>If you want to know more about how this works, there is a wonderful tech tip at <a href="http://unixwiz.net/techtips/ssh-agent-forwarding.html">http://unixwiz.net/techtips/ssh-agent-forwarding.html</a>.</p>
<h2>But how?</h2>
<p>SSH agent forwarding is even easier than copying keys all over the place. The first step is to generate keys for all the machines you log on to directly. You need to be sure these machines are secure and that your keys will stay safe, though this is sometimes not possible. You then add the generated public key to the authorized hosts file of all the machines you will connect to from this one, including ones that take two or more steps to get to. Finally you edit your ~/.ssh/ssh_config file to tell SSH to forward your agent through those hosts. Include the intermediate hosts in this list, but not the endpoints. You could also use <a href="http://www.danielhall.me/2009/07/sshmenu/">SSHmenu</a> to add the arguments automatically to those SSH commands. The following disables forwarding to all hosts, and explicitly enables it to fred, and aaron.missgner.com.</p>
<pre>Host fred
  ForwardAgent yes

Host aaron.missgner.com
  ForwardAgent yes

Host *
  ForwardAgent no</pre>
<p><strong>Random thought: </strong>Linux has Plug &#8216;n Pray too, you plug the device in and pray the drivers aren&#8217;t proprietary.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielhall.me/2009/08/ssh-agent-forwarding/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>SystemTap</title>
		<link>http://www.danielhall.me/2009/07/systemtap/</link>
		<comments>http://www.danielhall.me/2009/07/systemtap/#comments</comments>
		<pubDate>Sat, 25 Jul 2009 00:10:31 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[Benchmarking]]></category>
		<category><![CDATA[Profiling]]></category>
		<category><![CDATA[Systemtap]]></category>

		<guid isPermaLink="false">http://www.danielhall.me/?p=32</guid>
		<description><![CDATA[SystemTap is the Linux analogy to Solaris DTrace and is similar to the strace command, only much much more powerful. It effectively lets you set breakpoints in the kernel to monitor what your applications are doing. For example if I &#8230;<p class="read-more"><a href="http://www.danielhall.me/2009/07/systemtap/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>SystemTap is the Linux analogy to Solaris DTrace and is similar to the strace command, only much much more powerful. It effectively lets you set breakpoints in the kernel to monitor what your applications are doing. For example if I was worried that some application I&#8217;d written was polling way too often, I could ask SystemTap to output the number of times my application calls poll() or select().</p>
<p>To use SystemTap first you write a simple script, or borrow one from someone else. On a Fedora system you&#8217;ll fine some sample scripts in /usr/share/doc/systemtap-0.9.8/examples provided you have SystemTap installed. You then run the <em>stap</em>; command. The stap command immediately begins parsing the scipt looking for any tapsets that your script uses and if it does it includes them. It then converts your script into C code and compiles it into a kernel module. This kernel module is inserted into the running kernel and stap attaches to it. The kernel module stays in the kernel until it is cancelled by the user, it reaches an exit function or it encounters too many errors.</p>
<p>While SystemTap can be used to simply dump loads of data about what an application is doing in kernel space that is not its purpose. SystemTap scripts are able to drill down, extract, process and format the data its gathering. For example if you were trying to find out what files a process was writing to your disks could just output every single write call and print it out, or you could keep the statistics and every ten seconds print the top ten files written to. SystemTap is designed to help you filter out all the noise and monitor only what you want to monitor.</p>
<p>The simple way to get started with SystemTap is to download the <a href="http://sourceware.org/systemtap/SystemTap_Beginners_Guide.pdf">Beginners guide</a> or the <a href="http://sourceware.org/systemtap/SystemTap_Beginners_Guide.pdf">Tutorial</a>. On Fedora systems when you install SystemTap you&#8217;ll find the tutorial at /usr/share/doc/systemtap-0.9.8/tutorial.pdf. SystemTap skills are handy for system administrators and developers, so if you fit into those categories I&#8217;d highly recommend you check it out.</p>
<p><strong>Random Thought:</strong> Where does /dev/zero come from and where does /dev/null go? What happens if you pipe /dev/zero to /dev/null?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielhall.me/2009/07/systemtap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux &#8216;top&#8217; Commands</title>
		<link>http://www.danielhall.me/2009/07/linux-top-commands/</link>
		<comments>http://www.danielhall.me/2009/07/linux-top-commands/#comments</comments>
		<pubDate>Sun, 05 Jul 2009 10:43:40 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[System Administration]]></category>

		<guid isPermaLink="false">http://server/~daniel/?p=3</guid>
		<description><![CDATA[As a sysadmin working with Linux PCs I often need real time data on the status of the systems I manage. For example I might need to know what is using up all the bandwidth on an interface, whats taking &#8230;<p class="read-more"><a href="http://www.danielhall.me/2009/07/linux-top-commands/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p><span>As a sysadmin working with Linux PCs I often need real time data on the status of the systems I manage. For example I might need to know what is using up all the bandwidth on an interface, whats taking up  all the memory or why my X displays are running sluggish. The impromptu</span><br />
standard for naming these commands is to add the &#8216;top&#8217; suffix. Here  is a list of my favorite 8 &#8216;top&#8217; commands.</p>
<h4>top</h4>
<p><span>Top, the grandaddy of all the Linux top commands, is most useful for  monitoring tasks running on your system. On my Fedora system its contained  in package <span>procps</span> which on Fedora 11 was 3.2.7. Top has many <span>keybindings</span> to change its behaviour, for example &#8216;f&#8217; is used to add and remove fields, &#8216;o&#8217; will help you reorder those fields and the lesser-than and greater-than</span> keys move the search field. You can type &#8216;h&#8217; for a bigger list.</p>
<h4><span><span>tload</span></span></h4>
<p>You caught me! This one doesn&#8217;t end with top, but I put it here because on Fedora it comes as part of the <span><span>procps</span> packages with top, <span>slabtop</span> and others.</span> tload is a good application to have in a small terminal in the background.  It comes packaged along with top. It displays a histogram of the current load for the system. I like to have it running in a transparent terminal that I leave open on my laptop.</p>
<h4><span><span>htop</span></span></h4>
<p><span>An improved, menu driven and colourised version of normal top. <span>Htop</span> allows</span> you to get information on each thread of a program or combine all thread like normal top does. Some would argue that its more powerful, but others simply say its bloated. Whatever you believe, it has some nice features that any<span> sysadmin will appreciate and you&#8217;ll soon be wishing <span>htop</span> was <span>avaliable</span></span><br />
everywhere.</p>
<h4><span><span>iftop</span></span></h4>
<p><span>top is to <span>cputime</span> what <span>iftop</span> is to your network interfaces. It displays a</span> list of the top servers that are exchanging data over the selected interface. Because of the way it captures packets from the interface it needs root <span><span>privleges</span> to run.</span></p>
<h4><span><span>iotop</span></span></h4>
<p><span><span>iotop</span> displays live system IO statistics. Like top it lists the top</span> applications that are using IO. It can be toggled with the &#8216;o&#8217; key to only<br />
display programs currently performing IO, which is useful on large servers.<span> You can read more about its <span>keybindings</span> on its <span>manpage</span>.</span></p>
<h4><span><span>slabtop</span></span></h4>
<p><span><span>slabtop</span> is especially useful for kernel developers and pedantic system</span> tuners. It displays a summary of all the slab objects allocated in the kernel. I can take options to tell it how to display its information, but only has two <span><span>keybindings</span>, <span>spacebar</span> is to refresh the screen and &#8216;q&#8217; is to quit. You can</span> <span>see its options on its <span>manpage</span>.</span></p>
<h4><span><span>xrestop</span></span></h4>
<p><span>For X developers there is a utility called <span>xrestop</span>. <span>xrestop</span> displays a list</span> of X server resources allocated. It can be useful to see if your application, or your X server is leaking resources. While it only accepts the &#8216;q&#8217; key to exit it does accept a few options.</p>
<h4><span><span>powertop</span></span></h4>
<p>Built by Intel to help tune laptops to get the best performance out of your battery. It shows the percentage time spent in each CPU state and lists the<span> programs and devices that caused the most wake ups from idle mode. Its most</span> useful feature though is that it will analyse your system and give a suggestion on action to be taken to save just that little bit more power.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielhall.me/2009/07/linux-top-commands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

