Wednesday, April 22, 2009

network monitor?

Dear Lazyweb, I want a web-based display of everything that's happening on my network. This is easy, and there are dozens of apps for this, however I also want:

- easy to install. "apt-get install beer && firefox http://localhost/beer" should do it.

- default install doesn't ask me for a MySQL root password, or have me edit a something configuration something plugin something, I just want to see roughly what it looks like and does.

- default install should show me something about the local machine (and hopefully, the local network) w/o editing a zillion configuration files.

- hopefully web-based, but a X11 application is good too.

Ideas? Here are some that fail the test:
- Nagios. Lots of stuff, but fails the "show me now" test.
- Munin. A little lighter than Nagios, but similarly uncommunicative.
- Cacti. Well, maybe I'll give this one another five minutes to find the URL.
- Monit. Awesome *very* fast and light web-based tool, alas lacks pretty graphs. It's a distributed process-control tool.
- Tomato. Awesome, very pretty, lots of interactive graphs. Only monitors itself, the router.
- Gkrellm. Fast graphs, not ugly. Only monitors one machine at a time.
- Conky. Similar to gkrellm(?)

Suggestions?

Date and Time in Ubuntu

This lets you interactively set your time zone:
dpkg-reconfigure tzdata

This sets the clock:
ntpdate ntp.ubuntu.com

Server names in Dnsmasq

My domain name service (DNS) is running on a router using the wonderful Tomato firmware. When a computer boots up, it sends its hostname (i.e. "sally") to the router, which records the hostname and returns the corresponding IP ("192.168.7.10").

This is all grand. But, what if different services require a computer to have multiple names? That is, when the Puppet service fires up on my lappytop, it looks for the hostname "puppet" by default. Given the above scheme, a computer has one and only one name; DNS doesn't know that "sally" is also known as "puppet".

Here's how to fix that. The router is running Tomato, which uses Dnsmasq as the DNS service. It automatically figures out the normal hostname/IP mapping, for instance "sally" in the above example. We can tell it to point other names, like "puppet", to individual IP addresses.

Open up the Tomato administration page. Click Advanced / DHCP-DNS, and paste this into the Custom Configuration block after enabling all three checkboxes:
bogus-priv
expand-hosts

domain=lan

# service names, these are in addition to /etc/hostname
# for each computer:
address=/puppet.lan/192.168.7.13

To test:
$ ping -c1 puppet
PING puppet.lan (192.168.7.13) 56(84) bytes of data.
64 bytes from spootoxin.lan (192.168.7.13): icmp_seq=1 ttl=64 time=0.077 ms

--- puppet.lan ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.077/0.077/0.077/0.000 ms

Notice the system translates "puppet" to "puppet.lan" -- these are different names! The results for "dig puppet" and "ping puppet" can be different.

Check /etc/resolv.conf :
domain lan
search lan
nameserver 192.168.7.1




Thanks to http://ponderer.org/tomato_firmware for the tip!

Saturday, April 18, 2009

Fast Parallel Downloading (for apt-get)

I'm rebuilding a Ubuntu server. Normally apt-get downloads one file at a time, which can get dull when you're installing 598 files. I found the tool "apt-fast" which downloads one or two files quickly, by downloading with multiple streams per file. This is somewhat sketchy, as it requires installation of additional software, assumes the file gets spliced together correctly, and doesn't gracefully handle network problems.

I have a solution: xargs

Xargs walks on water. It is incredibly useful. In a nutshell, it runs a single command on a list of files. I'll post a lot more later, but here's how to speed up apt-get:

cd /var/cache/apt/archives/
apt-get -y --print-uris install ubuntu-desktop^ > debs.list
egrep -o -e "http://[^\']+" debs.list | xargs -l3 -P5 wget -nv
apt-get -y install ubuntu-desktop^

Replace "ubuntu-desktop^" with whichever task or package you want. Since ubuntu-desktop is a task, a huge collection of packages, the "^" on the end is required (and magic).

The options say to take three packages into a batch (-l3), and download five batches at a time in parallel (-P5). These settings are arbitrary, but provide a nice speedup while also not hammering the Ubuntu repository servers too hard.

Wednesday, April 8, 2009

Makefile for Python testing

This version supports Emacs's awesome Flymake syntax checker:

RECENT_PY := $(shell ls -1t *.py | awk '!/flymake/ {print; exit}')

all test test-fast:
./$(RECENT_PY)

Tuesday, April 7, 2009

Agile Software Development

I suggest everyone run, not walk, to read Alistair Cockburn's "Agile Software Development (2nd edition)." He talks about how people learn, and how Agile turns software development into a "cooperative game", like rock climbing. That is, developers have different roles, and each role supports the others so the team can progress farther, producing more software features to deliver to the client.

The author's notes on how people learn helped me immediately in my teaching practice. My classes are both more accessible (can help more people) and more focused (presenting more sophisticated knowledge.)

(Note the 2nd ed is a bit different from the 1st, and so recommended.)

Thursday, April 2, 2009

modest makefile for rapid Java testing

This makefile is designed to help test several Java programs, each one in its own self-contained source file, for example "hello.java" If you type "make hello.test", the program will be compiled and executed. To test everything in the directory, type "make test-all". To rebuild everything then re-test, do "make clean test-all".

To test a new program, just start writing it. When "make test-fast" is executed, the class file will be built, then run. That is, you never have to update the Makefile -- it picks up the most recent Java source file automatically.

I bind "make test-fast" to the big keypad Enter key, but that's for another blog post.

RECENT_JAVA := $(shell ls -1t *.java | head -1)

all test-fast: $(basename $(RECENT_JAVA)).test

test-all: $(patsubst %.java,%.test,$(wildcard *.java))

%.class: %.java
javac $<
%.test: %.class
env CLASSPATH=.:$(CLASSPATH) java $(basename $<)

check-syntax:
javac -Xlint $(CHK_SOURCES)

clean:
rm *.class

don't let network/disk hogs take over

Long-running or big I/O programs -- disk copies or network downloaders -- can make your system sluggish. To remedy this, tell the Linux kernel that those processes should only hit the disk if the system is idle, that is in scheduling class "3".

NOTE: this command, like most examples, is safe. It only prints out what would be done. To actually run this and other shell examples, remove the "echo" statement.

pgrep bash | xargs -i --no-run-if-empty echo ionice -c3 {}

moving old directories out of the way

This oneliner moves all non-2009 directories into a subdirectory:

mkdir OLD
echo mv `ls -1tl | awk '!/2009-/ {print $NF}'` OLD/

show Java problems in realtime in Emacs

after installing Flymake, create this Makefile:

all:

check-syntax:
javac -Xlint $(CHK_SOURCES)

art for William S Burroughs!

Track 16 Gallery