mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-02-03 18:49:29 -05:00
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@747 f882894a-f735-0410-b71e-b25c423dba1c
25 lines
603 B
Bash
Executable file
25 lines
603 B
Bash
Executable file
#!/bin/bash
|
|
# mail_error -o file -m email_address command
|
|
# Runs command from cron and redirects all output to file
|
|
# If command rc != 0, sends output to email_address
|
|
|
|
function die { echo $1 ; exit 1; }
|
|
|
|
# Must be export so that sfsnapshot uses correct versions
|
|
# of GNU toolchain
|
|
export PATH=$HOME/bin:$HOME/local/bin:$PATH
|
|
|
|
while getopts "o:m:" c; do
|
|
case $c in
|
|
o) output_file=$OPTARG;;
|
|
m) email=$OPTARG;;
|
|
\*) echo "oops";;
|
|
esac
|
|
done
|
|
shift $(($OPTIND-1))
|
|
|
|
[[ -z $1 ]] && die "Must specify command"
|
|
|
|
if ! "$@" > $output_file 2>&1 ; then
|
|
mail -s "mail_error fail: $1" $email < $output_file
|
|
fi
|