Ad Widget

Collapse

Zabbix Alerts via Gmail...getting close!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zoroastr
    Junior Member
    • Jan 2014
    • 6

    #1

    Zabbix Alerts via Gmail...getting close!

    +++++++++++++
    SOLVED!!!
    +++++++++++++
    I finally gave up on the email notification route and went with a seperate alert script. Even this failed a bunch of times before I stumbled over a VERY useful clickpath in the UI: Monitoring ==> Events. I have no idea why the manual points you to the "audit" option, since there's absolutely NO useful troubleshooting information there. I was watching zabbix-server.log for clues to root cause for the failed sends, but my failure was happening at a deeper level. Once I found the event logs, I could see that there was an errant char in the config that I either fat-fingered or just missed somehow.
    Sugestion to the Zabbix dox maintaniners: PLEASE point people to the event logs early. This is the best way to t-shoot problems. Thanks!
    ====================

    OK, I decided to follow the advice suggested by user alledm in the thread linked below, and I think I'm almost there. This is the idea of using stunnel to connect to Google smtp. My stunnel.conf is OK afaik because the service starts up no problem, and I can telnet to G-smtp no problem (heh...I'm actually using the same cert I use for connecting to my nntp server). Not sure why there's an initial "conn refused" in the telnet spew--maybe that's a clue to why Zabby can't mail out. That seems unlikely, though, since the stunnel connection to G-smtp on port 25 succeeds:

    Code:
    $ telnet localhost 25
    Trying ::1...
    Connection failed: Connection refused
    Trying 127.0.0.1...
    Connected to localhost.
    Escape character is '^]'.
    220 mx.google.com ESMTP vf7sm9370940pbc.5 - gsmtp
    OK, now...when I trigger an alarm event in Zabbix and tail the zabbix server log, I can see the server is trying to mail out but getting blocked:

    Code:
    7279:20140129:090128.618 executing housekeeper
    7279:20140129:090128.653 housekeeper [deleted 361 hist/trends, 0 items, 0 events, 0 sessions, 0 alarms, 0 audit items in 0.034218 sec, idle 1 hour(s)]
    7278:20140129:100058.849 cannot connect to SMTP server [localhost]: cannot connect to [[localhost]:25]: [111] Connection refused
    7278:20140129:100058.864 cannot connect to SMTP server [localhost]: cannot connect to [[localhost]:25]: [111] Connection refused
    7279:20140129:100128.653 executing housekeeper
    7279:20140129:100128.868 housekeeper [deleted 361 hist/trends, 0 items, 0 events, 0 sessions, 0 alarms, 0 audit items in 0.214758 sec, idle 1 hour(s)]
    7278:20140129:100128.882 cannot connect to SMTP server [localhost]: cannot connect to [[localhost]:25]: [111] Connection refused
    7278:20140129:100128.912 cannot connect to SMTP server [localhost]: cannot connect to [[localhost]:25]: [111] Connection refused
    7278:20140129:100158.931 cannot connect to SMTP server [localhost]: cannot connect to [[localhost]:25]: [111] Connection refused
    7278:20140129:100158.946 cannot connect to SMTP server [localhost]: cannot connect to [[localhost]:25]: [111] Connection refused
    So, it seems that Zabbix is configured OK, and stunnel is doing it's bit, so the blockage must be something like....ooh. I just had an idea: let me test this with iptables down. Be right back...

    original thread:
    Last edited by zoroastr; 06-02-2014, 00:24.
  • zoroastr
    Junior Member
    • Jan 2014
    • 6

    #2
    Drat! Blockage confirmed at point of send attempt for alarm and recovery...any ideas greatly appreciated.

    Code:
    7278:20140129:103029.001 cannot connect to SMTP server [localhost]: cannot connect to [[localhost]:25]: [111] Connection refused
    7278:20140129:103059.018 cannot connect to SMTP server [localhost]: cannot connect to [[localhost]:25]: [111] Connection refused
    7278:20140129:103059.033 cannot connect to SMTP server [localhost]: cannot connect to [[localhost]:25]: [111] Connection refused
    7278:20140129:103129.050 cannot connect to SMTP server [localhost]: cannot connect to [[localhost]:25]: [111] Connection refused
    7278:20140129:103129.065 cannot connect to SMTP server [localhost]: cannot connect to [[localhost]:25]: [111] Connection refused
    ...adding stunnel.conf details:

    Code:
    ; *****************************************************************************
    ; * Global Options                                                            *
    ; *****************************************************************************
    pid = /stunnel.pid
    output = /tmp/stunnel.log
    
    key = /etc/stunnel/stunnel.pem
    
    ; My client mode Services
    
    [gmail-smtp]
    client = yes
    accept = 127.0.0.1:25
    connect = smtp.gmail.com:465
    
    [nntp]
    client = yes
    accept = localhost:119
    connect = <my nntp server, blah..>
    ...btw: here's an interesting detail: alledm did not actually include the 'accept' line in his stunnel.conf's [gmail-smtp] block, but i found that I had to include it in order to start the service.


    UPDATE:
    I got rid of the "::1" entry in /etc/hosts, and now the connection to gsmtp goes straight through. Now I have to somehow figure out how to auto-pass my creds, because when I triggered a zabbix alert/recover cycle, each mail request is met with:

    7278:20140129:155859.743 wrong answer on MAIL FROM [530 5.5.1 http://support.google.com/mail/bin/a...y?answer=14257 pe3sm11028826pbc.23 - gsmtp

    I'm going over the answer page now...stay tuned for another update.

    ANOTHER UPDATE:
    ==============
    OK, abandon ship! This is clearly not going to work, since I have no idea what Google's SMTP regards as an acceptable 'helo' line. It barfs on everything I feed it.
    So, I'm taking a much more promising path: the AlertScript option.
    A script called "zext_msmtp.sh" looks very promising--see link below. It's a custom alert script you edit then place in a directory specified in the zabbix server conf. the script itself is well documented and pre-configured to work with gmail accts.
    It uses msmtp: "a very simple and easy to use smtp client with excellent sendmail compatibility. " found it in the Arch Linux repos for my distro, but it should be everywhere.
    I installed, configured and received mail in the target gmail acct using a local ssl cert. So, the rest should be fairly straightforward...
    Hint: If you also go this route, be aware that the SSL cert favored by Google is:
    /etc/ssl/certs/ca-certificates.crt
    ...at least, this is the one that worked for me. Final update soon...

    BTW: I'm only adding these updates in the hope that other ordinary users like me who want to get mail from Zabby to Gmail won't have to spend three days at it...

    Potentially useful linx:
    aperto.fr est disponible à la vente, contactez-nous aujourd'hui pour un devis gratuit.Remplissez le formulaire ci-dessous et recevez un devis gratuit.

    Last edited by zoroastr; 30-01-2014, 07:08.

    Comment

    Working...