How to Configure ‘Zabbix Monitoring’ to Send Email Alerts to Gmail Account – Part 4

How to Configure ‘Zabbix Monitoring’ to Send Email Alerts to Gmail Account – Part 4 - Hallo friend Tips and Trick Outside, In the article you read this time with the title How to Configure ‘Zabbix Monitoring’ to Send Email Alerts to Gmail Account – Part 4, we have prepared well for this article you read and download the information therein. hopefully fill posts Article Monitor, Article Zabbix, i hope with the article we write, you can understand. Well, happy reading.

Title : How to Configure ‘Zabbix Monitoring’ to Send Email Alerts to Gmail Account – Part 4
link : How to Configure ‘Zabbix Monitoring’ to Send Email Alerts to Gmail Account – Part 4

Read more


How to Configure ‘Zabbix Monitoring’ to Send Email Alerts to Gmail Account – Part 4



use script below:

#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Zabbix SMTP Alert script for gmail.
"""
import sys
import smtplib
from email.MIMEText import MIMEText
from email.Header import Header
from email.Utils import formatdate
# Mail Account
MAIL_ACCOUNT = 'your.account@gmail.com'
MAIL_PASSWORD = 'your mail password'
# Sender Name
SENDER_NAME = u'Zabbix Alert'
# Mail Server
SMTP_SERVER = 'smtp.gmail.com'
SMTP_PORT = 587
# TLS
SMTP_TLS = True
def send_mail(recipient, subject, body, encoding='utf-8'):
session = None
msg = MIMEText(body, 'plain', encoding)
msg['Subject'] = Header(subject, encoding)
msg['From'] = Header(SENDER_NAME, encoding)
msg['To'] = recipient
msg['Date'] = formatdate()
try:
session = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
if SMTP_TLS:
session.ehlo()
session.starttls()
session.ehlo()
session.login(MAIL_ACCOUNT, MAIL_PASSWORD)
session.sendmail(MAIL_ACCOUNT, recipient, msg.as_string())
except Exception as e:
raise e
finally:
# close session
if session:
session.quit()
if __name__ == '__main__':
"""
recipient = sys.argv[1]
subject = sys.argv[2]
body = sys.argv[3]
"""
if len(sys.argv) == 4:
send_mail(
recipient=sys.argv[1],
subject=sys.argv[2],
body=sys.argv[3])
else:
print u"""requires 3 parameters (recipient, subject, body)
\t$ zabbix-gmail.sh recipient subject body
"""
or download here 

Install guide:
  • Put this script in /usr/lib/zabbix/alertscripts and modify the 14,15, 21th lines
  • cd /usr/lib/zabbix/alertscripts
  • chmod 755 zabbix-alert-smtp.sh
  • chmod +x zabbix-alert-smtp.sh
  • Go to Zabbix web UI, Administration > Media types > Create media type
  • Enter Script namezabbix-alert-smtp.sh
  • Save
  • Configuration->Action->Report problems... -> Tab Operation check values remember to enable and save
    THIS STEP IS VERY IMPORTANT!!!
  • Administration->Users-> Into admin account (you can filter with listbox Users menu top right page) -> Tab Media ->Add -> Type -> listbox: zabbix-alert-smtp.py -> Send To -> your email -> Status -> Enable and save
    Hope to help someone...
source: https://gist.github.com/superdaigo/3754055#file-zabbix-alert-smtp-sh-L1



Declares Article How to Configure ‘Zabbix Monitoring’ to Send Email Alerts to Gmail Account – Part 4

That its all How to Configure ‘Zabbix Monitoring’ to Send Email Alerts to Gmail Account – Part 4 This time, hopefully can provide benefits to all of you. Okay, see you in another article posting.

You now read the article How to Configure ‘Zabbix Monitoring’ to Send Email Alerts to Gmail Account – Part 4 with the link address https://trik-outside.blogspot.com/2016/01/how-to-configure-zabbix-monitoring-to.html

Subscribe to receive free email updates:

0 Response to "How to Configure ‘Zabbix Monitoring’ to Send Email Alerts to Gmail Account – Part 4"

Post a Comment