Easy server monitoring script

I manage or monitor a few servers, and it’s a good idea to keep an eye on how they’re holding up. The Linux uptime command is all I need – show me how long the server’s been up (or if it’s cycled recently – power hiccup?), and CPU load averages.

I just whipped up a dead-simple solution to let me embed the uptime reports from the servers into my retro homepage.

I’m quite sure there are better and/or more robust ways to do this, but this is what I came up with after maybe 2 minutes of thought.

On each of the servers, I added a shell script called “uptimewriter.sh” (in my ~/bin directory, so located at ~/bin/uptimewriter.sh). I made the file executable (chmod +x ~/bin/uptimewriter.sh) and used this script:

#!/bin/sh
echo "document.write('"`uptime`"');"

All it does is wrap the output of the uptime command in some javascript code to display the text when embedded on a web page. I then added it to the crontab on each of the servers, running every 15 minutes, and dumping the output into a file that will be visible via the webserver.

*/15 * * * *  ~/bin/uptimewriter.sh > ~/public_html/uptime.js 2>&1

Every 15 minutes, the uptimewriter.sh script is run, and output into a javascript file that can be pulled to display on a web page.

Then, on my retro home page, I added code to run the javascript file:

<script src="http://home.darcynorman.net/uptime.js" type="text/javascript" charset="utf-8" async defer></script>

When called from a web page, that will render the output of the uptime command, wrapped in a document.write() call as per the uptimewriter.sh script, displaying it nicely:

Screen shot 2010-10-29 at 11.51.32 AM.png

I can do some more work to style it a bit, so it wraps more nicely, but it’s a decent start.

Tips for using WordPress as a website manager

I’m working on a project that involves building a website to organize and present a bunch of content. We could do it in raw HTML, but it makes more sense to use a content management system. We could do it in Drupal, but my ability to make Drupal look good is somewhat lacking. So, I’m using a site on UCalgaryBlogs to take advantage of WordPress’ content management features. Here’s the basic how-to:

Basic setup:

First, create a page. Creatively call it “Home” or something. Go to Settings > Reading and set it as the front page.

Next, create your content as pages. Take advantage of WordPress’ parent-page feature to nest the pages as deeply as you want. I disabled comments and trackbacks on all pages, to keep it cleaner (and nobody’s likely to comment on the pages anyway – we’ll provide a feedback system for that).

I am using (at least for now) the default twenty-ten theme. It’s pretty complete, and looks great. Pages show up in the main navigation bar, and get full drop-down hierarchical menus built for them.

Enable the Pages widget under Appearance > Widgets. Makes it easier for people to scan to find a page, without having to hunt and seek through all drop-down menus. It’s trivial to provide both ways of navigating.

Plugins that help:

With that in place, WordPress becomes a very robust content management system. Much easier to build a website with a team of people through WordPress, than it is to collaborate over static HTML or some of the other options. Easy.

McLuhan’s global village, ca 1960

Stephen posted a link to this newly rediscovered video of Marshall McLuhan discussing media on CBC’s Explorations documentary series in 1960. This was 4 years before Understanding Media was published. It’s well worth watching. It strikes me that this kind of deep, theoretical presentation/discussion would likely be impossible to broadcast now.

video-takedown.jpg

UPDATE: As of October 27, 2010, the video was taken down from YouTube, due to a copyright violation claim by CBC. I suppose they’re planning to rebroadcast the 50 year old video at some point?

Screen shot 2010-10-27 at 1.31.17 PM.png

I’m sure McLuhan would have something to say about the message of copyright takedowns and the ephemeral nature of corporate digital media.