Header Ads

  • New Updates

    How to make zabbix appliance 3.2 as mail server and send alert to email by using gmail and stunnel

    This is my little effort to explain how we can setup stunnel with zabbux and gmail,

    How to install stunnel in ubuntu 14.04.5 LTS ?
    How to install stunnel and configure gmail smtp  port 25 for gmail email ?
    How to setup email alert in zabbix ?
    How to make zabbix appliance 3.2 as mail server and send alert to email by using gmail and stunnel ?

    Requerments:

    1.Zabbix Appliance installed and configured
    2.Stunnel
    3.Gmail Account

    Install stunnel and configure

    Login as root and type

    # apt-get install stunnel

    After installation finish need to configure stunnel.

    vi /etc/default/stunnel4

    Change: ENABLED=0 to ENABLED=1

    Save and Quit.

    Create new stunnel configuration file.
    # cp /usr/share/doc/stunnel4/examples/stunnel.conf-sample /etc/stunnel/stunnel.conf
    edit it stunnel.conf
    # vi /etc/stunnel/stunnel.conf

    Remove ";" from lines

    output = /var/log/stunnel4/stunnel.log
    .
    .
    cert = /etc/stunnel/mail.pem
    .
    .
    [pop3s]
    accept  = 995
    connect = 110
    .
    .
    [imaps]
    accept  = 993
    connect = 143
    .
    [ssmtp]
    accept  = 465
    connect = 25
    .
    .
    [gmail-smtp]
    client = yes
    accept = 172.16.200.200:25
    connect = smtp.gmail.com:465
    .

    .

    After add above details then Save and Quit VI Editor.


    Then Create an Open SSL Certificate to with work Stunnel .

    # cd /etc/stunnel
    # openssl req -new -out mail.pem -keyout mail.pem -nodes -x509 -days 365 
    Start stop or restart STunnel
    # sudo /etc/init.d/stunnel4 stop
    # sudo /etc/init.d/stunnel4 start 
    # sudo /etc/init.d/stunnel4 restart
    If it is startling without any error, configuration is success.Otherwise need to troubleshoot it.

    To verify the service is running or not  ,
    Just gor to any machine that is in the same network and do telnet to port 25.

    In Windows OS,


    Go to CMD
    type
    telnet 172.16.200.200 25

    If it is not showing any failure message and established connection to port 25 means configuration is success.

    Some times there is a chance to block port 25 by  Ubuntu firewall iptables.
    so we need to add an exception in firewall iptables.


    Add Port exception in Ubuntu firewall iptables.

    Check first the firewall in ubuntu
    # ptables -L -n

    Then add port in firewall

    # iptables -I INPUT -p tcp -m tcp --dport 25 -j ACCEPT

    Then check again by doing telnet from any of outside machine .If it is success go to next steps,

    Configure email settings in Zabbix

    Go to Zabbix - Administration - Media Type


    Then Update. After got to Zabbix - Administration - Users
    Choose any user and edit media type as shown below,


    If you are using gmail for zabbix smtp alert, You should need to setup enable  "Allow Less secure App : ON"




    After that you need to configure an action trigger for testing this setup.
    Before make an action you should have Hosts configured in Zabbix.
    If you want to know how to configure host in zabbix follow below link ,

    Link will update soon

    Now go to Zabbix - Configuration - Action

    Type a name,
    New condition - Choose trigger - and browse your already configured (In host)server -  and select any of trigger , Here I choose MytestServer (My server Name) is Unavailable by ICMP.
    Then Go to Operations - New

    Configure like above picture,
    Then Setup Recovery Operations
    Refer above picture.
    Then update and save all settings.

    After that Test email setup by stop ping or shutdown Server,then check your e-mail after 3 minute.Default Zabbix ICMP trigger is 3 minute.

    If the tutorial help you, please comment below.

    Thank you.

    Post Top Ad

    Post Bottom Ad

    Ads