zpool hourly status check

I’m setting up cron job for a storage server using ZFS. There’s zpool status -x but it returns “all pools are healthy” (or “no pools available”) on no error and prints errors to stdout (instead of stderr), rendering it annoying for cron job.

#!/bin/sh

set -e
set -u

zstatus="`zpool status -x 2>&1`"
case "${zstatus}" in
  "all pools are healthy"|"no pools available")
    return 0
  ;;
  *)
    printf "%sn" "${zstatus}" >&2
    return 1
  ;;
esac

Put it in a file (e.g. /root/bin/zpool-status-cron), make it executable, and add it to crontab.

Announcing ecos – the collection of crappy scripts I wrote

Included in the package:

  • bash initialization script, mainly tested on OpenIndiana but should also good for Linux, *BSD and other *nix
  • tcsh initialization script. Mainly tested on FreeBSD
  • my hgrc. Obviously shouldn’t be used as is except if you want to give me the copyright of whatever you’re committing
  • tmux config. Blue bars instead of green. And minor tweaking
  • vimrc. Guaranteed to break vim-lite or whatever the default vi in Ubuntu. Also shouldn’t be used for most administrative task where tab should be tab and it should be 8 spaces long. Mainly for ruby development.
  • inputrc. Makes various application using readline much more awesome – especially if you’re not emacs user
  • Various scripts:
    • cek: check crc32 of a file and compares with the one in filename if exists. Useful for checking downloaded anime. Requires ruby
    • ed2k: generates ed2k link of a file. Useful for comparing against anidb database. Ruby is required.
    • putcrc: as the name says, puts crc32 of the file in its filename. Also requires ruby.
    • ren: rename anime files with whatever I like. In perl. Contains hundres of regexes. No test so it tends to break at unfortunate time.

Grab them here: [ bitbucket/edogawaconan/ecos ]