host system checks for nefu

  • nefu - A network monitoring daemon is a nice, simple monitoring program that is a snap to set up. it’s all i need for the few hosts that i have colo’d around the country. the only drawback that i’ve found so far, is that it only monitors network services (http, dns, ntp, etc.), and i’d like to keep an eye on cpu load, disk space, and a few other things. so, i wrote a couple of things to add that capability.

hostchecks - is a python script:

hostchecks - perform host checks
dave w capella  <>
Sat Oct 13 19:58:33 PDT 2012

usage: hostchecks

- output written to /var/www/htdocs/status
- results: OK, ERROR - (message)
- usually take default exceptions and quit.
  not for public consumption, anyway.


  disks   checks disk space of mounts
  inodes  checks disk inodes
  mem     checks free memory
  swap    checks swap usage
  load    checks load average
  raid    checks raid health
  smart   checks smart status

this script must be run by root to write to the htdocs directory, and to run smartctl. it is run out of root’s crontab periodically; i run it every 5 minutes.

download here: hostchecks


nefu_get_host_status is a shell script that grabs the file generated by hostchecks and parse its output. the status file starts with a time stamp (in seconds) that is verified to be less than 10 minutes old. if all is well, the only other thing in the file is the word "OK", and the script prints "OK" and exits cleanly (status 0). this tells nefu that all is well.

otherwise, the script prints "ERROR", and the file contents (which contains the error), and exits with a status of 1 which tells nefu that there is a problem.

to implement, add a line to root’s crontab, e.g.:

*/5 * * * * /usr/local/bin/hostchecks

and a line to the nefurc like:

! nefu_get_host_status

note that nefu_get_host_status requires the name of the host to check as a command line argument. also, don’t forget to install the file in nefu’s shelltest directory, usually /usr/local/nefu/shelltests.

download from here: nefu_get_host_status

that’s it. reload nefu, and enjoy.