Category Archives: Code

Tarsnap Nagios checks

While I have been using Tarsnap for a while now it is first recently I have gotten around to make Nagios monitor those backups. Given that I really don’t want to give the nagios user any actual access to my backups, I instead take the approach of having my backup script create a status file containing a Unix timestamp of the most recent backup.

My check_tarsnap Nagios plugin can then use that status file to check that the most recent backup isn’t older than a specified number of hours. For my nightly backups I have the Warning threshold set to 26 hours and the Critical threshold set to 42 hours.

(See the top comment in the plugin source for an example on how to create the status file.)

birthday reminders, vCard to e-mail

A couple of months ago I wrote a Python script which parses my vCard address book and reminds me about upcoming birthdays. Given that it has worked well for me I figured I would share it with the rest of you.

I have not added any e-mail capabilities to the script, as I find it cleaner to simply let cron pass along the output. For more information, see the README file.

(The actual vCard parsing is handled by  the Python vobject library.)

tarsnap bash-completion

I’m currently trying out the Tarsnap backup solution (beta). Since it doesn’t come with a bash-completion of its own I’ve created one myself. I really can’t stand working with –long-options without proper completion.

For now I maintain it as a “junk branch” in Launchpad.

https://code.launchpad.net/~andol/+junk/tarsnap-completion

UPDATE:  http://bitbucket.org/andol/tarsnap-completion/

So far there is only the initial commit, hence it is most likely far from perfect. Feel free to point our errors and suggest improvements.

(Once I’ve used Tarsnap some more, I’ll probably put my experiences into a blog post of its own.)

rdiff-backup bash-completion

I use rdiff-backup for most of my private backups. It’s a great piece of software. I just wish it had its own bash-completions.

(Problem solved.)

Update October 6th: Now included in Debian (sid).

/etc/init.d/autossh_tunnel.foo

Autossh is a nice way to keep a ssh connection alive. This is especially useful when it comes to ssh tunnels. To make things even more automagicial I have now written the init script template autossh_tunnel.foo.

A few import facts regarding the script:

  • Autossh 1.4 or later is required. Earlier versions of autossh doesn’t handle PID-files.
  • The init script is based on the start-stop-daemon. Hence it will probably only work on Debian, Ubuntu and similar systems.
  • There is no way to enter a password. A setup based on ssh-keys or similar is required.
  • Autossh doesn’t handle every kind of ssh problem. Because of that it is possible for the initial connection to fail without the init script knowing about it.

This is by the way my first real init script. Any feedback on it would be greatly appreciated.

line_removal.pl (known_hosts)

Manually removing entries from your known_hosts doesn’t take my of an effort. Still, it’s something you can grow tired of. Especially so after resent events (DSA-1571). That is why I’ve now written my very own line_removal.pl  script.

Basically you feed the script one or more line numbers. Corresponding lines in your ~/.ssh/known_hosts will then be deleted.

andreas@leto:~$ ./line_removal.pl 22
Removing line #22 from /home/andreas/.ssh/known_hosts

andreas@leto:~$ ./line_removal.pl 3 37 29
Removing line #37 from /home/andreas/.ssh/known_hosts
Removing line #29 from /home/andreas/.ssh/known_hosts
Removing line #3 from /home/andreas/.ssh/known_hosts

To be honest I really don’t know if I’ll ever use this script against more than one line at a time. Somehow it still seemed wrong not to support the option of feeding it multiple arguments.