We’ve bought a cute little Shuttle KPC for the office. It’s a very compact PC that we’re going to use as a VOIP PBX. The bare-bone version of the machine ships with a motherboard and power supply already mounted in the case, but it lacks a CPU, memory or hard disk. Last week, for the first time in about 5 years, I built a computer. Not much has changed, though I did have a hard time mounting the CPU. It resulted in a broken fan/heat-sink assembly, though thankfully a replacement was only $20.
Today I loaded the operating system, Ubuntu Linux 8.10 “Intrepid Ibex” and got a taste of the latest Ubuntu release. As usual, I’m quite impressed, and the improvements in the two and a half years since I regularly used a graphical Linux interface are highly noticeable. There’s lots of animation and the experience is more… fun?
I thought it would be wise to stress test this little box, as even though it’s not going to get that much of a workout at our office, I wanted to make sure the CPU was seated properly and was being cooled appropriately.
The two tools I picked for the job are stress and cpuburn.
Like most programmers, I don’t like to repeat manual tasks, well, manually. We use Ubuntu Server almost exclusively on our servers and whilst package management is very simple (login, aptitude update, aptitude dist-upgrade, all done) when you have to look after many (fourteen and expanding) servers it can get repetitive.
I use Terminal (or is it called Terminal.app?) on Mac OS X as my terminal emulator, and I’ve messed around with using Applescript to open multiple tabs before, so I figured this was a problem worthy of a Sunday-morning.
What I envisaged was iterating over a list of servers and having Applescript manage a Terminal instance, opening new tabs where appropriate, and executing the upgrade command in each tab for each server. Sounds simple enough.
set tab_count to 0
set servers to {"astrotrain", "bumblebee", "grimlock", "ironhide", ¬
"jazz", "laserbeak", "mirage", "prime", ¬
"prowl", "ratchet", "ravage", "rumble", ¬
"soundwave", "wheeljack"}
-- Update the package list, dist-upgrade and remove the downloaded
-- packages so they're not included in the backups
set dist_upgrade to ¬
" 'sudo aptitude update &&
sudo aptitude dist-upgrade &&
sudo aptitude clean'"
-- Make our settings globally available
global tab_count, servers, dist_upgrade
-- Mainline
on main()
tell application "Terminal"
activate
repeat with server in servers
set cmd to "ssh -t " & server & dist_upgrade & " && exit"
my open_tab(cmd)
end repeat
end tell
end main
on open_tab(cmd)
tell application "Terminal" to activate
my create_new_window_or_tab()
tell application "Terminal" to ¬
do script with command (cmd) in last tab of window 1
end open_tab
on create_new_window_or_tab()
if tab_count ≤ 0 then
tell application "Terminal" to do script ""
set tab_count to tab_count + 1
else
tell application "System Events" to ¬
tell process "Terminal" to ¬
keystroke "t" using command down
end if
end create_new_window_or_tab
-- Run the mainline
main()
Apologies for the highlighting – the plugin doesn’t understand Applescript.