样板:
#邮件报警脚本
#!/bin/sh
export smtpemailfrom="Zabbix_monit[email protected]"
export zabbixemailto="$1"
export zabbixsubject="$2"
export zabbixbody="$3"
export smtpserver=mail.server.host
#export smtplogin=SMTP_LOGIN
#export smtppass=SMTP_PASSWORD
/usr/bin/sendEmail \
-f $smtpemailfrom \
-t $zabbixemailto \
-u $zabbixsubject \
-m $zabbixbody \
-s $smtpserver:25 \
-o tls=no \
-o message-content-type=html \
-o message-charset=utf8 \
-o tls=auto >>/tmp/sendEmail.log
#html格式
<tablealign="center"class="MsoNormalTable"border="1"cellpadding="0"style="mso-cellspacing:1.5pt; border:solid black 1.0pt; margin-top:50px;mso-yfti-tbllook:1184;mso-padding-alt:0cm0cm0cm0cm">
<tbody><trstyle="mso-yfti-irow:0;mso-yfti-firstrow:yes">
<tdcolspan="2"style="border:none;padding:.75pt.75pt.75pt.75pt">
<pclass="MsoNormal"><spanlang="EN-US"style="font-family:"Verdana",sans-serif"><ahref="http://internal.ecvision.cn/zabbix/index.php"style="color:#000000;text-decoration:none;">Zabbix
Monitoring System Notification</a></span><spanlang="EN-US"style="font-size:10.0pt;
font-family:"Verdana",sans-serif">
<o:p></o:p></span></p></td>
</tr>
<trstyle="mso-yfti-irow:1">
<tdnowrap=""style="border:none;background:#D9D9D9;padding:.75pt.75pt.75pt.75pt">
<pclass="MsoNormal"><b><spanstyle="font-size:10.0pt;font-family:
"Verdana",sans-serif">Trigger Status: </span></b></p></td>
<tdstyle="border:none;background:#FF8080;padding:.75pt.75pt.75pt.75pt">
<pclass="MsoNormal"><spanstyle="font-size:10.0pt;font-family:"Verdana",sans-serif">{TRIGGER.STATUS}</span></p></td>
</tr>
<trstyle="mso-yfti-irow:2">
<tdnowrap=""style="border:none;background:#F2F2F2;padding:.75pt.75pt.75pt.75pt">
<pclass="MsoNormal"><b><spanlang="EN-US"style="font-size:10.0pt;font-family:
"Verdana",sans-serif">Trigger Name:
</span></b></p></td>
<tdstyle="border:none;padding:.75pt.75pt.75pt.75pt">
<pclass="MsoNormal"><spanlang="EN-US"style="font-size:10.0pt;font-family:"Verdana",sans-serif">{TRIGGER.NAME}</span></p></td>
</tr>
<trstyle=‘mso-yfti-irow:4‘>
<tdnowrap="nowrap"style=‘border:none;background:#D9D9D9;padding:.75pt.75pt.75pt.75pt‘><pclass="MsoNormal"><b><spanstyle=‘font-size:10.0pt;font-family:
"Verdana",sans-serif‘lang="EN-US"xml:lang="EN-US">Trigger Severity:
</span></b></p></td>
<tdstyle=‘border:none;background:#FFFF80;padding:.75pt.75pt.75pt.75pt‘><pclass="MsoNormal"><spanstyle=‘font-size:10.0pt;font-family:"Verdana",sans-serif‘lang="EN-US"xml:lang="EN-US">{TRIGGER.SEVERITY}
</span></p></td>
</tr>
<trstyle="mso-yfti-irow:5">
<tdnowrap=""style="border:none;background:#F2F2F2;padding:.75pt.75pt.75pt.75pt">
<pclass="MsoNormal"><b><spanlang="EN-US"style="font-size:10.0pt;font-family:
"Verdana",sans-serif">Trigger Time:</span></b></p></td>
<tdstyle="border:none;background:#F2F2F2;padding:.75pt.75pt.75pt.75pt">
<pclass="MsoNormal"><spanlang="EN-US"style="font-size:10.0pt;font-family:"Verdana",sans-serif">{EVENT.DATE} {EVENT.TIME}</span></p></td>
</tr>
<trstyle=‘mso-yfti-irow:6‘>
<tdnowrap=""style="border:none;background:#D9D9D9;padding:.75pt.75pt.75pt.75pt">
<pclass="MsoNormal"><b><spanlang="EN-US"style="font-size:10.0pt;font-family:
"Verdana",sans-serif">Trigger Severity:</span></b></p></td>
<tdstyle=‘border:none;padding:.75pt.75pt.75pt.75pt‘><pclass="MsoNormal"><spanstyle="font-size:10.0pt;font-family:"Verdana",sans-serif">{TRIGGER.NSEVERITY}</span></p></td>
</tr>
<trstyle="mso-yfti-irow:7">
<tdnowrap=""style="border:none;background:#F2F2F2;padding:.75pt.75pt.75pt.75pt">
<pclass="MsoNormal"><b><spanlang="EN-US"style="font-size:10.0pt;font-family:
"Verdana",sans-serif">Host Name:</span></b></p></td>
<tdstyle="border:none;background:#F2F2F2;padding:.75pt.75pt.75pt.75pt">
<pclass="MsoNormal"><spanstyle="font-size:10.0pt;font-family:"Verdana",sans-serif">{HOST.NAME}</span></p></td>
</tr>
<trstyle="mso-yfti-irow:8">
<tdnowrap=""style="border:none;background:#D9D9D9;padding:.75pt.75pt.75pt.75pt">
<pclass="MsoNormal"><b><spanstyle="font-size:10.0pt;font-family:
"Verdana",sans-serif">IP Address:
</span></b></p></td>
<tdstyle="border:none;padding:.75pt.75pt.75pt.75pt">
<pclass="MsoNormal"><spanstyle="font-size:10.0pt;font-family:"Verdana",sans-serif">{HOST.IP}</span></p></td>
</tr>
<trstyle="mso-yfti-irow:9">
<tdnowrap=""style="border:none;background:#F2F2F2;padding:.75pt.75pt.75pt.75pt">
<pclass="MsoNormal"><b><spanlang="EN-US"style="font-size:10.0pt;font-family:
"Verdana",sans-serif">Item Values:</span></b></p></td>
<tdstyle="border:none;background:#F2F2F2;padding:.75pt.75pt.75pt.75pt">
<pclass="MsoNormal"><spanlang="EN-US"style="font-size:10.0pt;font-family:"Verdana",sans-serif">{ITEM.NAME1} ({HOST.NAME1}:{ITEM.KEY1}): {ITEM.VALUE1}</span></p></td>
</tr>
<trstyle="mso-yfti-irow:10;mso-yfti-lastrow:yes">
<tdnowrap=""style="border:none;background:#D9D9D9;padding:.75pt.75pt.75pt.75pt">
<pclass="MsoNormal"><b><spanlang="EN-US"style="font-size:10.0pt;font-family:
"Verdana",sans-serif">Original Event ID:<o:p></o:p></span></b></p></td>
<tdstyle="border:none;padding:.75pt.75pt.75pt.75pt">
<pclass="MsoNormal"><spanlang="EN-US"style="font-size:10.0pt;font-family:"Verdana",sans-serif">{EVENT.ID}</span></p></td>
</tr>
</tbody>
</table>
<pclass="foot"align="center"style="text-align:center"><spanlang="EN-US"style="font-size:10.0pt;font-family:"Verdana",sans-serif"><ahref="http://internal.ecvision.cn/zabbix/index.php"style="color:#000000;text-decoration:none;">Generated by Zabbix,
the OpenSource monitoring solution by AmberRoad.com</a>
</span></p>
时间: 2024-10-01 20:56:35