This week after playing a bit with Google CL and cURL posting to Twitter and StatusNet, I wanted to go the next step and have a way to keep an eye on my Ubuntu server that runs my StatusNet instance.
On the Mac there is a free tool called GeekTool which is a System Preferences module that allows for some interesting desktop integrations with files, images and shell scripts. There is also an extensive community around this tool where useful scripts have been built for a number of actions.
Remote Server Stats:
In order to see that basic stats I wanted, I first needed to have a way to display these remote stats locally. This required me to write a script (serverstats.sh) to ssh to my server and run a simple command on Ubuntu to display the same sysinfo that comes up on a connected session:
The first challenge is to use ssh in a script that doen't contain my password. Typically an ssh session will prompt you with a password, so to keep the script secure and connect with a script, I need to create a public and private key for the ssh session to use. To do this, I ran this on my Mac (system to monitor from) in ~/.ssh/:
ssh-keygen -t dsa
This will generate two keys, one public and one private. The public key will be copied over to the remote server and the contents of the key will be stored in:
You can copy the contents running the following:
cat id_dsa.pub >> ~/.ssh/authorized_keys
The the authorized keys must be given access with the following:
chmod 600 ~/.ssh/authorized_keys
*For complete instructions check out: remy sharp's b:log post
Now I can simply ssh and I am into my remote server. Obviously this would be an issue if my local machine is compromised but I could always revoke the key on the server if that was the case. For my needs, it seemed to be a calculated risk!
Now I can go back to geek tool and setup my script to run and refresh. I used the Shell Geeklet and in the script area I added this:
echo "THE HEaRD Ubuntu Server Stats:
ssh ip-address-of-your-server ./serverstats.sh
I am diggin' Geektool and look forward to doing more script automation in the future. ~Lou
Post a Comment