Ad Widget

Collapse

Email Notifications.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jluvs2ride
    Member
    • Jul 2015
    • 85

    #1

    Email Notifications.

    This is a critical part of my ZABBIX project but I'm just not having any success.

    I need to configure ZABBIX to send email alerts on certain triggers. I'm using a gmail address and a script called zabbix-alert-smtp.py. The script got good reviews so evidently some were having success with it. Just not me.

    I can test it in a terminal session using python zabbix-alert-smtp.py [email protected] Test Test. And I get the appropriate email. I have a media type set up as script and zabbix-alert-smtp.py. Notifications are enabled and I have an action to send email to Zabbix Administrators.

    If however I force the trigger into an error condition, the error shows on the Monitor Page and tells me that emails are in progress. Unfortunately after a period of time it switches to email not sent and I do not get any emails.

    I thought it might be a permissions issue and I added zabbix to the root group since it worked from the command line when I was sshed in as root.

    I'm running 2.0.14 on Debian Wheezy. Is this addressed in a later version of ZABBIX? Is there a better way to do this?

    I understand that this is nearly a duplicate thread, but my original thread on this topic got zero response so I thought a different title might help.
  • jamesNJ
    Senior Member
    • Jun 2015
    • 103

    #2
    I can only comment on zabbix 2.4.5, hopefully the same applies to your setup.

    Check the zabbix_agentd.conf file and make sure EnableRemoteCommands is enabled.

    Also, I believe zabbix relies on sudo to execute various commands as root. Check that sudoers file includes the zabbix user. On CentOS the package install includes /etc/sudoers.d/zabbix_sudoers with necessary permissions for running programs. There is a Cmnd_Alias line that enables access to various programs, you may need to add your program there.

    But, at least in 2.4.5, there is built-in media type for e-mail. The setup is easy and only requires that you define an SMTP host to connect to. I don't do any script processing for mail delivery, I have zabbix to is all through media types defined for my users.

    Comment

    • jamesNJ
      Senior Member
      • Jun 2015
      • 103

      #3
      I'm sorry I was thinking about this wrong ... I think sudoers is only used for programs you can invoke from the GUI.

      But I think the question remains as to why you need a script to e-mail when the media type can be configured as SMTP and zabbix sends the mail itself.

      Comment

      • jluvs2ride
        Member
        • Jul 2015
        • 85

        #4
        Hey, thanks for the response. I am in the process of upgrading to 2.45, however the issue with gmail is the authentication. Thus the need for the script.

        It looks like 3.0 has expanded options for configuring email.

        Comment

        • jamesNJ
          Senior Member
          • Jun 2015
          • 103

          #5
          I see. Well in 2.4.5 there is no login configuration in the email media type, so a script would still be necessary.

          AlertScriptsPath is defined in the zabbix_server.conf. Make sure the path is accessible by the zabbix user and program is executable. On my server I gave zabbix user a shell so that I can login/su to it to check various permissions, etc.

          I don't know about Debian ... on CentOS selinux seems to be a problem with just about anything you want to do. You could also sanity check by seeing if some similar system/application security option is at play and disabling it.

          Comment

          • jluvs2ride
            Member
            • Jul 2015
            • 85

            #6
            I am realizing that I don't fully understand the email set up for the user's accounts.

            It appears that each user needs their own specific media type with the SMTP info and their own email address, but then when you link it to the user's account you specify the user's email address again?

            Can someone clarify this? I believe I have a media type setup that will work for the sender, but setting the user's email to receive the notifications is where I get lost.

            Thanks.

            Comment

            • jluvs2ride
              Member
              • Jul 2015
              • 85

              #7
              OK, I think I sorted out all my confusion about setting up email notification for the user.

              However, I still cannot get email notifications to work. I have installed MSMTP and configured a zext_msmtp.sh as recommended. A test from the console works fine but triggering an alert fails to send and email. When I look at the action log, it says;

              /usr/lib/zabbix/alertscripts/zext_msmtp.sh: [13] Permission denied

              So I am obviously up against a permissions issue.

              It appears that the situation is that the zabbix user has insufficient rights to execute the script. Again, this is an unfamiliar topic for me.

              Comment

              • jluvs2ride
                Member
                • Jul 2015
                • 85

                #8
                OK, ran this;

                chown zabbix.zabbix /usr/lib/zabbix/alertscripts/*

                ls -l /usr/lib/zabbix/alertscripts/*
                -rwxr-xr-x 1 zabbix zabbix 1551 Jul 28 13:00 /usr/lib/zabbix/alertscripts/zabbix-alert-smtp.py

                -rw-r--r-- 1 zabbix zabbix 834 Aug 8 11:29 /usr/lib/zabbix/alertscripts/zext_msmtp.sh

                I still get the;

                /usr/lib/zabbix/alertscripts/zext_msmtp.sh: [13] Permission denied

                Comment

                • jluvs2ride
                  Member
                  • Jul 2015
                  • 85

                  #9
                  Progress?

                  OK, this combination seems to have eliminated the permission denied error;

                  chown zabbix.zabbix /usr/lib/zabbix/alertscripts
                  chmod u+srwx,g+xr-w,o+xr-w /usr/lib/zabbix/alertscripts/*

                  The Audit now says an email was sent but I never receive one.

                  Comment

                  • jluvs2ride
                    Member
                    • Jul 2015
                    • 85

                    #10
                    Well, if I send an email from the command line it works. An email arrives in my inbox and there is a corresponding entry in the msmtp log file. However if I trigger an alert, the audit says an email was sent but no email arrives and no entry in the msmtp log file.

                    So, now I am wondering if zabbix is being denied permissions to access msmtp itself.

                    Comment

                    • jluvs2ride
                      Member
                      • Jul 2015
                      • 85

                      #11
                      OK, turned on debugging in zext_msmtp and found a minor discrepancy in the log file. Fixed it and now emails are working perfectly.

                      Comment

                      Working...