Modified for Nagios compatibility. Can be run with --debug for full output.