zabbix 以html格式邮件报警

样板:

#邮件报警脚本
  1. #!/bin/sh
  2. export smtpemailfrom="Zabbix_monitoring@ecvision.com"
  3. export zabbixemailto="$1"
  4. export zabbixsubject="$2"
  5. export zabbixbody="$3"
  6. export smtpserver=mail.server.host
  7. #export smtplogin=SMTP_LOGIN
  8. #export smtppass=SMTP_PASSWORD
  9. /usr/bin/sendEmail \
  10. -f $smtpemailfrom \
  11. -t $zabbixemailto \
  12. -u $zabbixsubject \
  13. -m $zabbixbody \
  14. -s $smtpserver:25 \
  15. -o tls=no \
  16. -o message-content-type=html \
  17. -o message-charset=utf8 \
  18. -o tls=auto >>/tmp/sendEmail.log
 
 #html格式
  1. <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">
  2. <tbody><trstyle="mso-yfti-irow:0;mso-yfti-firstrow:yes">
  3. <tdcolspan="2"style="border:none;padding:.75pt.75pt.75pt.75pt">
  4. <pclass="MsoNormal"><spanlang="EN-US"style="font-family:&quot;Verdana&quot;,sans-serif"><ahref="http://internal.ecvision.cn/zabbix/index.php"style="color:#000000;text-decoration:none;">Zabbix
  5. Monitoring System Notification</a></span><spanlang="EN-US"style="font-size:10.0pt;
  6. font-family:&quot;Verdana&quot;,sans-serif">
  7. <o:p></o:p></span></p></td>
  8. </tr>
  9. <trstyle="mso-yfti-irow:1">
  10. <tdnowrap=""style="border:none;background:#D9D9D9;padding:.75pt.75pt.75pt.75pt">
  11. <pclass="MsoNormal"><b><spanstyle="font-size:10.0pt;font-family:
  12. &quot;Verdana&quot;,sans-serif">Trigger Status: </span></b></p></td>
  13. <tdstyle="border:none;background:#FF8080;padding:.75pt.75pt.75pt.75pt">
  14. <pclass="MsoNormal"><spanstyle="font-size:10.0pt;font-family:&quot;Verdana&quot;,sans-serif">{TRIGGER.STATUS}</span></p></td>
  15. </tr>
  16. <trstyle="mso-yfti-irow:2">
  17. <tdnowrap=""style="border:none;background:#F2F2F2;padding:.75pt.75pt.75pt.75pt">
  18. <pclass="MsoNormal"><b><spanlang="EN-US"style="font-size:10.0pt;font-family:
  19. &quot;Verdana&quot;,sans-serif">Trigger Name:
  20. </span></b></p></td>
  21. <tdstyle="border:none;padding:.75pt.75pt.75pt.75pt">
  22. <pclass="MsoNormal"><spanlang="EN-US"style="font-size:10.0pt;font-family:&quot;Verdana&quot;,sans-serif">{TRIGGER.NAME}</span></p></td>
  23. </tr>
  24. <trstyle='mso-yfti-irow:4'>
  25. <tdnowrap="nowrap"style='border:none;background:#D9D9D9;padding:.75pt.75pt.75pt.75pt'><pclass="MsoNormal"><b><spanstyle='font-size:10.0pt;font-family:
  26. &quot;Verdana&quot;,sans-serif'lang="EN-US"xml:lang="EN-US">Trigger Severity:
  27. </span></b></p></td>
  28. <tdstyle='border:none;background:#FFFF80;padding:.75pt.75pt.75pt.75pt'><pclass="MsoNormal"><spanstyle='font-size:10.0pt;font-family:&quot;Verdana&quot;,sans-serif'lang="EN-US"xml:lang="EN-US">{TRIGGER.SEVERITY}
  29. </span></p></td>
  30. </tr>
  31. <trstyle="mso-yfti-irow:5">
  32. <tdnowrap=""style="border:none;background:#F2F2F2;padding:.75pt.75pt.75pt.75pt">
  33. <pclass="MsoNormal"><b><spanlang="EN-US"style="font-size:10.0pt;font-family:
  34. &quot;Verdana&quot;,sans-serif">Trigger Time:</span></b></p></td>
  35. <tdstyle="border:none;background:#F2F2F2;padding:.75pt.75pt.75pt.75pt">
  36. <pclass="MsoNormal"><spanlang="EN-US"style="font-size:10.0pt;font-family:&quot;Verdana&quot;,sans-serif">{EVENT.DATE}&nbsp;&nbsp;{EVENT.TIME}</span></p></td>
  37. </tr>
  38. <trstyle='mso-yfti-irow:6'>
  39. <tdnowrap=""style="border:none;background:#D9D9D9;padding:.75pt.75pt.75pt.75pt">
  40. <pclass="MsoNormal"><b><spanlang="EN-US"style="font-size:10.0pt;font-family:
  41. &quot;Verdana&quot;,sans-serif">Trigger Severity:</span></b></p></td>
  42. <tdstyle='border:none;padding:.75pt.75pt.75pt.75pt'><pclass="MsoNormal"><spanstyle="font-size:10.0pt;font-family:&quot;Verdana&quot;,sans-serif">{TRIGGER.NSEVERITY}</span></p></td>
  43. </tr>
  44. <trstyle="mso-yfti-irow:7">
  45. <tdnowrap=""style="border:none;background:#F2F2F2;padding:.75pt.75pt.75pt.75pt">
  46. <pclass="MsoNormal"><b><spanlang="EN-US"style="font-size:10.0pt;font-family:
  47. &quot;Verdana&quot;,sans-serif">Host Name:</span></b></p></td>
  48. <tdstyle="border:none;background:#F2F2F2;padding:.75pt.75pt.75pt.75pt">
  49. <pclass="MsoNormal"><spanstyle="font-size:10.0pt;font-family:&quot;Verdana&quot;,sans-serif">{HOST.NAME}</span></p></td>
  50. </tr>
  51. <trstyle="mso-yfti-irow:8">
  52. <tdnowrap=""style="border:none;background:#D9D9D9;padding:.75pt.75pt.75pt.75pt">
  53. <pclass="MsoNormal"><b><spanstyle="font-size:10.0pt;font-family:
  54. &quot;Verdana&quot;,sans-serif">IP Address:
  55. </span></b></p></td>
  56. <tdstyle="border:none;padding:.75pt.75pt.75pt.75pt">
  57. <pclass="MsoNormal"><spanstyle="font-size:10.0pt;font-family:&quot;Verdana&quot;,sans-serif">{HOST.IP}</span></p></td>
  58. </tr>
  59. <trstyle="mso-yfti-irow:9">
  60. <tdnowrap=""style="border:none;background:#F2F2F2;padding:.75pt.75pt.75pt.75pt">
  61. <pclass="MsoNormal"><b><spanlang="EN-US"style="font-size:10.0pt;font-family:
  62. &quot;Verdana&quot;,sans-serif">Item Values:</span></b></p></td>
  63. <tdstyle="border:none;background:#F2F2F2;padding:.75pt.75pt.75pt.75pt">
  64. <pclass="MsoNormal"><spanlang="EN-US"style="font-size:10.0pt;font-family:&quot;Verdana&quot;,sans-serif">{ITEM.NAME1} ({HOST.NAME1}:{ITEM.KEY1}): {ITEM.VALUE1}</span></p></td>
  65. </tr>
  66. <trstyle="mso-yfti-irow:10;mso-yfti-lastrow:yes">
  67. <tdnowrap=""style="border:none;background:#D9D9D9;padding:.75pt.75pt.75pt.75pt">
  68. <pclass="MsoNormal"><b><spanlang="EN-US"style="font-size:10.0pt;font-family:
  69. &quot;Verdana&quot;,sans-serif">Original Event ID:<o:p></o:p></span></b></p></td>
  70. <tdstyle="border:none;padding:.75pt.75pt.75pt.75pt">
  71. <pclass="MsoNormal"><spanlang="EN-US"style="font-size:10.0pt;font-family:&quot;Verdana&quot;,sans-serif">{EVENT.ID}</span></p></td>
  72. </tr>
  73. </tbody>
  74. </table>
  75. <pclass="foot"align="center"style="text-align:center"><spanlang="EN-US"style="font-size:10.0pt;font-family:&quot;Verdana&quot;,sans-serif"><ahref="http://internal.ecvision.cn/zabbix/index.php"style="color:#000000;text-decoration:none;">Generated by Zabbix,
  76. the OpenSource monitoring solution by AmberRoad.com</a>
  77. </span></p>
 





posted @ 2016-08-17 19:12  betterman.com  阅读(475)  评论(0编辑  收藏  举报