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:
*/15 * * * * ~/bin/uptimewriter.sh > ~/public_html/uptime.js 2>&1
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:
I can do some more work to style it a bit, so it wraps more nicely, but it’s a decent start.