blog advertising is good for you


blog advertising is good for you
User login

Monitor Uptime and Usage of Local Machines With rwhod

It’s an old Unix trick, but it’s so very nice to have. On your local machine, in Terminal, you have the who and uptime commands to see who is using your machine (be it someone logged into the console/GUI or over SSH) and uptime to see your uptime and load. Useful information, this.

But what about the other machines on your network? Do you need to shell out hundreds of dollars for something like Apple Remote Desktop to see what’s happening to every machine in your home or small business? Do you have to SSH to each and leave a window open just to put uptime in a loop to see what it’s doing? Do you have to install something like Webmin and setup a monitoring cluster? Or even setup email reports in cron to get the output of the commands?

Not really, no. Remote load and usage monitoring is built-in to Mac OS X.

I’ll start by saying you want to use this on small networks where privacy is not a concern. You can use this to see who is logged into a machine and, thus, a valid user account to try to get in as. This would be one of many reasons it’s off by default. The other is it runs on broadcasts and, in large numbers, could hinder network performance.

However, if you have desire or need to monitor machines around you, rwhod is a neat party trick. rwho and ruptime let you see a who and uptime report for all the machines on your subnet that are running rwhod. It’s really that simple.

$ rwho -a; ruptime -a
ahknight Kalyke:console Jul  6 14:50 48:14
ahknight Kalyke:ttyp1   Jul  8 14:52   :03
ahknight Kalyke:ttyp2   Jul  8 14:55   :06
ahknight Kalyke:ttyp3   Jul  8 01:54 13:07
ahknight Saturn:console Jul  7 03:25 35:39
Kalyke        up  2+00:15,     4 users,  load 0.18, 0.27, 0.25
Saturn        up  1+11:40,     1 user,   load 0.02, 0.05, 0.06

That’s all it is. But, now I can monitor my home server without logging into it because my local computer is watching for those rwhod broadcasts and logging them.

This simple trick requires one step: start rwhod as root. The rest just happens. Now, you can run it once, or you can put the following in /Library/LaunchDaemons and launchctl load it and the system will keep it going for you:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>bsd.rwhod</string>
	<key>ProgramArguments</key>
	<array>
		<string>/usr/sbin/rwhod</string>
	</array>
	<key>RunAtLoad</key>
	<true/>
</dict>
</plist>

After that’s done on every machine you want to monitor or listen for broadcasts from, run one of rwho or ruptime to test it.

Read the man pages on rwho, ruptime, or rwhod for more information.

Average rating
(0 votes)
About Adam Knight
Adam Knight's picture

Author Biography

Adam Knight is one of the founders of Mac Geekery and is a geek at heart. Programmer by day, hacker by night, his daily life revolves around the Macintosh platform, which he has been a user and programmer for since the early days of System 7 when his LCII replaced his Apple //c.

In-between tech jobs, he’s managed to learn the basics of any web hacker: PHP, MySQL, Perl, Apache, Linux, *BSD, and the intricacies of ./configure —prefix=~/bombshelter/. Today, codepoet is concentrating on blogging again, writing some software for the Mac by himself (including Notae) and for his company (such as Switchblade) and has a few other toys coming out soon.

Bug him over AIM or email [link fixed].

Post new comment
The content of this field is kept private and will not be shown publicly.
5 + 11 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.