Welcome to Robot Dialogs. This is a place where I will record my progress, mistakes, errors, failures, lessons learned and hopefully occasional success in my designs and implementations of robots and other technical endeavors. I will try to make it as educational, informative and entertaining as I can...

Saturday, July 30, 2011

Adventures In Server-land: Power Up (Post-Boot) Server Status Email

Lately my projects have taken a back seat to some other higher priority stuff (including setting up the new web page for CCCKC (my local hackerspace) and various KC Maker Faire duties.

On my own time I've been working to build a low power server. Something I can leave on all the time without burning holes in my wallet. Really that's just an excuse...any money I would have saved was dumped into good hardware and setup time, but whatever. I think the main point is that (when I've finished) I should have a server that I can leave on and have reliable file storage/access anywhere. And I will have learned something (supposedly).

The Server:
At full load this server uses less than 70 watts! (My main PC uses 160W at idle, 300-400W at full load...)

I don't think I'll go into full detail with every software thing I've done so far (I can't remember most of the steps, and I'm not really qualified to explain them). I will however give the short list:
  • Ubuntu Server 11.4
  • LAMP (Apache, mySQL, PHP) Mostly so I can have a quick easy status check from any device.
  • smartmontools - For S.M.A.R.T hard drive monitoring
  • mdadm - For raid (still playing with raid drives, burning in disks and practicing for failures.)
  • samba - still tinkering... local file share access (tests show ~100MB up/down speeds...awesome!)
  • sftp - still tinkering... remote file share access (dunno yet...)
  • lm-sensors - CPU temperature
  • hddtemp - HD temperatures
Anyways I started this post to talk about a script I made while tinkering today. Firstly I followed this guide to get command line email via gmail working...and then went about making a robust post-boot status report script. This serves three purposes:
  • After a power failure/reboot I get an email immediately.
  • The email has important/useful status information about the server before any users get there hands in the mix.
  • The script serves as a library of useful sys-admin commands. Things I wouldn't normally use and, therefore, forget easily.
Here's what I did:

Create a file called onboot-report.sh with the following:
Note: You should change some@email.com to your own email...and you may need to change the FILE and MAIL_FILE locations... Most of those commands are explained very well here.

Now the only thing left is to make onboot-report.sh run after power-up:

In Ubuntu you just have to run the script in the file /etc/rc.local by adding the following:
I also have the following in /etc/rc.local I find it extremely useful because it lets me know that I can reestablish ssh sessions after a reboot without plugging in a monitor... It's not very complicated, it just makes the PC speaker beep three times after it's completely powered up.

Oh, maybe it's obvious, but after you install "beep" (sudo apt-get install beep) you can only test it from the server itself (tty1-ttyX) not via ssh (which will just beep your local PCs speaker).

No comments:

Post a Comment