#!/bin/sh # Little Nagios check to save the Sendmail mailstats CATEGORY="" OUTPUT_PERFDATA="" # Stop at the first non-catched error set -e # We use the "idiom" suggested by http://www.etalabs.net/sh_tricks.html # based on "done </dev/null) EOF # if not all data is present, we return an unknown status # (remove this block if you don't mind) if ! echo "$OUTPUT_PERFDATA" | grep "MTA_msg" >/dev/null 2>&1 \ || ! echo "$OUTPUT_PERFDATA" | grep "MSP_msg" >/dev/null 2>&1 \ || ! echo "$OUTPUT_PERFDATA" | grep "MTA_tcp" >/dev/null 2>&1 \ || ! echo "$OUTPUT_PERFDATA" | grep "MSP_tcp" >/dev/null 2>&1 \ ; then echo "UNKNOWN" exit 3 fi # Remove starting space to OUTPUT_PERFDATA printf "OK|%s\n" "$( echo $OUTPUT_PERFDATA )"