Hi Rajesh,

as far as I know (but may be wrong) the "mailers" config has to be
defined before any listen, frontend or backend directives. Also the
"email-alert" has to be defined after the backend. So in your case it
would look like this:

#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
    log         127.0.0.1 local2

    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group       haproxy
    daemon

    stats socket /var/lib/haproxy/stats

#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
#    option log-health-checks
    option http-server-close
    option forwardfor       except 127.0.0.0/8 <http://127.0.0.0/8>
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 3000

mailers mta
 mailer smtp1 127.0.0.1:25 <http://127.0.0.1:25>

#---------------------------------------------------------------------
#HAProxy Monitoring Config
#---------------------------------------------------------------------
listen haproxy3-monitoring
    bind :8080                #Haproxy Monitoring run on port 8080
    mode http
    option forwardfor
    option httpclose
    stats enable
    stats show-legends
    stats refresh 5s
    stats uri /stats                             #URL for HAProxy monitoring
    stats realm Haproxy\ Statistics
    stats auth root:sangbe            #User and Password for login to
the monitoring dashboard
    stats admin if TRUE
    default_backend app                    #This is optionally for
monitoring backend

#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------
frontend main
    bind :80
    option http-server-close
    option forwardfor
    default_backend app


backend app
    balance     roundrobin
#    option httpchk #HEAD / HTTP/1.1\r\nHost:\ localhost    #Check the
server application is up and healty - 200 status code
    server  11-80-R7-CLST-Node1    10.10.11.80:80
<http://10.10.11.80:80> check
    server  DS-11-81-R7-CLST-Node2    10.10.11.81:80
<http://10.10.11.81:80> check

    email-alert mailers mta
#    email-alert level alert
    email-alert from redm...@netrovert.net <mailto:redm...@netrovert.net>
    email-alert to rajesh.ko...@netrovert.net
<mailto:rajesh.ko...@netrovert.net>

Regards,
Daniel

Am 24.08.17 um 15:20 schrieb Rajesh Kolli:
> Hi Daniel,
>
> Thanks for your quick response...
>
> i am getting this error if i use mailers section in my configuration.
> ---------------------------------------------------------------------------------------------------------
> [root@DS-11-82-R7-CLST-Node1 ~]# systemctl status haproxy.service -l
> haproxy.service - HAProxy Load Balancer
>    Loaded: loaded (/usr/lib/systemd/system/haproxy.service; enabled)
>    Active: inactive (dead) since Thu 2017-08-24 18:43:23 IST; 4s ago
>   Process: 6511 ExecStart=/usr/sbin/haproxy-systemd-wrapper -f
> /etc/haproxy/haproxy.cfg -p /run/haproxy.pid (code=exited,
> status=0/SUCCESS)
>  Main PID: 6511 (code=exited, status=0/SUCCESS)
>
> Aug 24 18:43:23 DS-11-82-R7-CLST-Node1 systemd[1]: Starting HAProxy
> Load Balancer...
> Aug 24 18:43:23 DS-11-82-R7-CLST-Node1 systemd[1]: Started HAProxy
> Load Balancer.
> Aug 24 18:43:23 DS-11-82-R7-CLST-Node1 haproxy-systemd-wrapper[6511]:
> [ALERT] 235/184323 (6512) : parsing [/etc/haproxy/haproxy.cfg:81] :
> unknown keyword 'mailers' in 'listen' section
> Aug 24 18:43:23 DS-11-82-R7-CLST-Node1 haproxy-systemd-wrapper[6511]:
> [ALERT] 235/184323 (6512) : parsing [/etc/haproxy/haproxy.cfg:82] :
> unknown keyword 'mailer' in 'listen' section
> Aug 24 18:43:23 DS-11-82-R7-CLST-Node1 haproxy-systemd-wrapper[6511]:
> [ALERT] 235/184323 (6512) : parsing [/etc/haproxy/haproxy.cfg:117] :
> unknown keyword 'email-alert' in 'backend' section
> Aug 24 18:43:23 DS-11-82-R7-CLST-Node1 haproxy-systemd-wrapper[6511]:
> [ALERT] 235/184323 (6512) : parsing [/etc/haproxy/haproxy.cfg:119] :
> unknown keyword 'email-alert' in 'backend' section
> Aug 24 18:43:23 DS-11-82-R7-CLST-Node1 haproxy-systemd-wrapper[6511]:
> [ALERT] 235/184323 (6512) : parsing [/etc/haproxy/haproxy.cfg:120] :
> unknown keyword 'email-alert' in 'backend' section
> Aug 24 18:43:23 DS-11-82-R7-CLST-Node1 haproxy-systemd-wrapper[6511]:
> [ALERT] 235/184323 (6512) : Error(s) found in configuration file :
> /etc/haproxy/haproxy.cfg
> Aug 24 18:43:23 DS-11-82-R7-CLST-Node1 haproxy-systemd-wrapper[6511]:
> [ALERT] 235/184323 (6512) : Fatal errors found in configuration.
> Aug 24 18:43:23 DS-11-82-R7-CLST-Node1 haproxy-systemd-wrapper[6511]:
> haproxy-systemd-wrapper: exit, haproxy RC=256
>
> ------------------------------------------------------------------------------------------------
> Here is my config file
>
> [root@DS-11-82-R7-CLST-Node1 ~]# cat /etc/haproxy/haproxy.cfg
> #---------------------------------------------------------------------
> # Global settings
> #---------------------------------------------------------------------
> global
>     log         127.0.0.1 local2
>
>     chroot      /var/lib/haproxy
>     pidfile     /var/run/haproxy.pid
>     maxconn     4000
>     user        haproxy
>     group       haproxy
>     daemon
>
>     stats socket /var/lib/haproxy/stats
>
> #---------------------------------------------------------------------
> # common defaults that all the 'listen' and 'backend' sections will
> # use if not designated in their block
> #---------------------------------------------------------------------
> defaults
>     mode                    http
>     log                     global
>     option                  httplog
>     option                  dontlognull
> #    option log-health-checks
>     option http-server-close
>     option forwardfor       except 127.0.0.0/8 <http://127.0.0.0/8>
>     option                  redispatch
>     retries                 3
>     timeout http-request    10s
>     timeout queue           1m
>     timeout connect         10s
>     timeout client          1m
>     timeout server          1m
>     timeout http-keep-alive 10s
>     timeout check           10s
>     maxconn                 3000
>
> #---------------------------------------------------------------------
> #HAProxy Monitoring Config
> #---------------------------------------------------------------------
> listen haproxy3-monitoring
>     bind :8080                #Haproxy Monitoring run on port 8080
>     mode http
>     option forwardfor
>     option httpclose
>     stats enable
>     stats show-legends
>     stats refresh 5s
>     stats uri /stats                             #URL for HAProxy
> monitoring
>     stats realm Haproxy\ Statistics
>     stats auth root:sangbe            #User and Password for login to
> the monitoring dashboard
>     stats admin if TRUE
>     default_backend app                    #This is optionally for
> monitoring backend
>
> mailers mta
>  mailer smtp1 127.0.0.1:25 <http://127.0.0.1:25>
>
> #---------------------------------------------------------------------
> # main frontend which proxys to the backends
> #---------------------------------------------------------------------
> frontend main
>     bind :80
>     option http-server-close
>     option forwardfor
>     default_backend app
>
>
> backend app
>     balance     roundrobin
> #    option httpchk #HEAD / HTTP/1.1\r\nHost:\ localhost    #Check the
> server application is up and healty - 200 status code
>     email-alert mailers mta
> #    email-alert level alert
>     email-alert from redm...@netrovert.net <mailto:redm...@netrovert.net>
>     email-alert to rajesh.ko...@netrovert.net
> <mailto:rajesh.ko...@netrovert.net>
>     server  11-80-R7-CLST-Node1    10.10.11.80:80
> <http://10.10.11.80:80> check
>     server  DS-11-81-R7-CLST-Node2    10.10.11.81:80
> <http://10.10.11.81:80> check
> --------------------------------------------------------------------------------
>
> I am using postfix on my machine to send emails and i have configured
> postfix with gmail to send emails.
>
> Could you help on it or suggest something.
>
> On Thu, Aug 24, 2017 at 6:36 PM, Daniel Heitepriem
> <daniel.heitepr...@pribas.com <mailto:daniel.heitepr...@pribas.com>>
> wrote:
>
>     Hi Rajesh,
>
>     the community version supports mailers. Here is a working section from
>     my configuration:
>
>     mailers mymailserver
>         mailer smtp1 10.1.0.251:25 <http://10.1.0.251:25>
>
>     frontend frontend_CHANGEME
>
>         bind *:443 ssl crt /opt/etc/haproxy/haproxy-t.pem force-tlsv12
>     no-sslv3
>
>     #################################################################
>     # backend configuration
>     #################################################################
>
>     backend booking-backend
>         compression algo gzip
>         compression type text/html text/plain text/css
>         server server1-t server1-t:8443 check ssl verify none maxconn 4000
>
>     backend vakanz-backend
>         compression algo gzip
>         compression type text/html text/plain text/css application/xml
>         server server2-t server2-t:8080 check verify none force-tlsv12
>     backup
>         server server3-t server3-t:8443 check ssl verify none no-sslv3
>
>         email-alert mailers mymailserver
>         email-alert from haprox...@mydomain.com
>     <mailto:haprox...@mydomain.com>
>         email-alert to myn...@mydomain.com <mailto:myn...@mydomain.com>
>
>     I hope it helps
>
>     Regards,
>     Daniel
>
>     Am 24.08.17 um 14:35 schrieb Rajesh Kolli:
>     > Hello,
>     >
>     > I am new to HAProxy, present i am using community version of
>     haproxy,
>     > and i am trying to configure alerting in my configuration, after i
>     > configure "mailers" section and after restart of service it is
>     > throwing "unknown keyword mailers" in frontend.
>     >
>     > Now, my doubt is... will HAProxy community supports
>     mailers/alerting?
>     >
>     > Thanks in advance if you suggest something on this.
>     >
>     > Thanks and Regards
>     >
>     > Rajesh Kolli
>     >
>     >
>
>
>
>
> -- 
> *Thanks & Regards
> Rajesh Kolli
>
>
> *

Reply via email to