#! /bin/bash to=$1 # subject=$2 # body=$3 # status="$(echo $body | cut -d\; -f3)" # , if text0=' , : ' text1=' 30 .' text2=':' text3=':' text4=':' text5=' :' text6=' : ' text7='Original event ID:' text8=' :' text9=' :' ack=`echo "select message FROM acknowledges WHERE eventid='$(echo $body | cut -d\; -f1)'" | mysql -uuser -ppassword -Dzabbix` # if [[ $status = "PROBLEM" ]]; then #if- , cat <<EOF | mail -s "$subject" "$to" $text0 $(echo $body | cut -d\; -f2) $text1 $text2 $(echo $body | cut -d\; -f3) $text3 $(echo $body | cut -d\; -f4) $text4 $text5 $(echo $body | cut -d\; -f5) $(echo $body | cut -d\; -f6) $text6 $text8 $ack $text7 $(echo $body | cut -d\; -f1) EOF else cat <<EOF | mail -s "$subject" "$to" $text0 $(echo $body | cut -d\; -f2) $text1 $text2 $(echo $body | cut -d\; -f3) $text3 $(echo $body | cut -d\; -f4) $text4 $text9 $(echo $body | cut -d\; -f5) $(echo $body | cut -d\; -f6) $text6 $text8 $ack $text7 $(echo $body | cut -d\; -f1) EOF fi
userid=`echo "select userid FROM acknowledges WHERE eventid='$(echo $body | cut -d\; -f1)'" | mysql -uuser -ppassword -Dzabbix` user=`echo "select alias [ name surname - ] FROM users WHERE userid=$userid" | mysql -uuser -ppassword -Dzabbix`
{EVENT.ID}; {INVENTORY.LOCATION1}; {TRIGGER.STATUS}; {TRIGGER.SEVERITY}; {EVENT.DATE}; {EVENT.TIME}
Source: https://habr.com/ru/post/223279/
All Articles