目录
------------------------- # 邮箱告警 ----------------------------------
1.安装mailx与postfix软件包
2.修改mailx配置文件
3. 创建文件夹
4. 编写mail-send.sh脚本
5. 将该脚本赋予执行权限
6. 进入web界面进行设置—> Alerts —> Media Types
7. 添加动作—> Alerts —> Actions —>Trigger Actions
8. 给用户添加邮箱告警 —> Users —>Users
9. 测试
------------------------- # SMS告警 ----------------------------------
1.上传脚本 sendsms.sh
2.为该脚本赋权限
3. 进入web界面进行设置—> Alerts —> Media Types
4. 添加动作—> Alerts —> Actions —>Trigger Actions
5. 给用户添加邮箱告警 —> Users —>Users
6.测试
------------------------- # 邮箱告警 ----------------------------------
1.安装mailx与postfix软件包
yum -y install postfix
yum -y install mailx
2.修改mailx配置文件
vim /etc/mail.rc
set ask askcc append dot save crt
ignore Received Message-Id Resent-Message-Id Status Mail-From Return-Path Via
set from=dba_alarm@xxx.com smtp=mail.xxx.com
set smtp-auth-user=dba_alarm@xxx.com smtp-auth-password=123456 smtp-auth=login
3. 创建文件夹
mkdir -p /usr/local/share/zabbix/alertscripts/
cd /usr/local/share/zabbix/alertscripts/
4. 编写mail-send.sh脚本
vim mail-send.sh
#!/bin/bash
messages=`echo $3 | tr '\\r\\n' '\\n'`
subject=`echo $2 | tr '\\r\\n' '\\n'`
echo "${messages}" | mailx -s "${subject}" $1
# ----------------------------------------------------------
5. 将该脚本赋予执行权限
chmod 777 mail-send.sh
chown -R zabbix:zabbix mail-send.sh
6. 进入web界面进行设置—> Alerts —> Media Types
7. 添加动作—> Alerts —> Actions —>Trigger Actions
8. 给用户添加邮箱告警 —> Users —>Users
9. 测试
------------------------- # SMS告警 ----------------------------------
1.上传脚本 sendsms.sh
#!/bin/bash
##########################################################################################
# send phone message
##########################################################################################
# message interface
HTTP_INTERFACE="http://xxx/message/rest/send"
# phones list
phones="$1"
# message content
content="$2"
# send message to one mobile
function generate_post_data() {
mobile=$1
cat << EOF
{
"sourceKey":"08",
"bizCode":"OPERATION_ALARM_NOTICE",
"sign":"XXXXXXXXXXXXXXXXXXX",
"mobile":"$mobile",
"content":"$content"
}
EOF
}
OLD_IFS=$IFS
IFS=","
# send message one by one
for item in $phones;do
curl -H "Content-Type:application/json" -X POST --data "$(generate_post_data $item)" "$HTTP_INTERFACE"
sleep 1
done
IFS=$OLD_IFS
cd /usr/local/share/zabbix/alertscripts/
2.为该脚本赋权限
chom 777 /usr/local/share/zabbix/alertscripts/sendsms.sh
3. 进入web界面进行设置—> Alerts —> Media Types
4. 添加动作—> Alerts —> Actions —>Trigger Actions
5. 给用户添加邮箱告警 —> Users —>Users
6.测试
文章来源:https://www.toymoban.com/news/detail-653449.html
文章来源地址https://www.toymoban.com/news/detail-653449.html
到了这里,关于Zabbix-6.4.4 邮箱告警&SMS告警配置的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!