Ad Widget

Collapse

Zabbix server, SMTP config

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nerfux
    Junior Member
    • Jan 2011
    • 19

    #1

    Zabbix server, SMTP config

    Okey, first of all I wanna say,
    a smtp server should be a part of the zabbix server, incase of connection losses the server will still be able to send out alerts.

    But anyway, i have been trying for a week now to get my server to send email notification, i have tryed to run a script action (sendEmail)
    HTML Code:
    http://www.zabbix.com/forum/showthread.php?t=1323&highlight=smtp
    heres my script:
    #!/bin/sh

    export smtpemailfrom=zabbix@*mydomain.com*
    export zabbixmailto="$1"
    export zabbixsubject="$2"
    export zabbixbody="$3"
    export smtpserver=*mymailserver*
    export smtpdomain=*mydomain.com*
    #evt passord
    #export smtplogin=
    #export smtppass=

    echo "From: \"Zabbix Monitor\" <$smtpemailfrom>" > /tmp/mymailinput
    echo "To: $zabbixemailto" >> /tmp/mymailinput
    echo "Subject: $zabbixsubject" >> /tmp/mymailinput
    echo "" >> /tmp/mymailinput
    echo "This is an automated alert from Zabbix Network Monitoring. The mess
    age is $zabbixbody" >> /tmp/mymailinput

    /usr/bin/sendemail -f $smtpemailfrom -t $zabbixmailto -u $zabbixsubject -m $zabbixbody -s $smtpserver:1285 -l /tmp/mymailinput -v -v
    # -xu $smtplogin -xp $smtppass


    well, i cant see any happending in the logs, and i get no email, but if I do this command, it works perfect: ./zabbix_sendmail eparken@"mydomain.com" test okei

    Under administration-> audit, it says that, my script action, has been completed /Successful.... but it dossent send out mail....

    Can any1 tell me why my zabbixserver cant run this script? are my variables right? where do i check my variables?

    Or do any1 know a good guide how to setup a mailserver and config it right so it will work on and with my zabbix server ?

    BTW we have zabbix_server 1.8.4 & Ubuntu 10.04
  • JuAnChO
    Junior Member
    • Jan 2011
    • 2

    #2
    I had the same issue, and the solution is the location of the script files and permissions of it...

    1.- Create the next folder

    /home/zabbix/bin/

    2.- Put the script in this folder (here's mine) (zabbix_sendmail)

    Code:
    #!/bin/sh
    
    export smtpemailfrom=EMAIL
    export zabbixemailto="$1"
    export zabbixsubject="$2"
    export zabbixbody="$3"
    export smtpserver=SMPTPSERVER
    export smtplogin=EMAIL
    export smtppass=PASSWORD
    
    /usr/bin/sendEmail -f $smtpemailfrom -t $zabbixemailto -u $zabbixsubject -m $zabbixbody -s $smtpserver:25 -xu $smtplogin -xp $smtppass
    3.- CHMOD the file

    chmod 755 zabbix_sendmail

    And that's it for the file part... in Zabbix...

    1.- Administration -> Media Type and edit Mail... make it

    Type: Script
    Script name: zabbix_sendmail


    And that's it, hope it works for you too =)

    Comment

    • Nerfux
      Junior Member
      • Jan 2011
      • 19

      #3
      Hi yes i found out, after giving up and I installed postfix on the server but tnx, i think many will find good help in this, because many of the articals in the wiki is old and difficult to understand right, tnx again =)

      Comment

      • miovel
        Junior Member
        • Feb 2011
        • 9

        #4
        Hi,
        i have also some troubles with configuring email notification via Zabbix.
        With Zabbix email media i have no success. So i have decided use script from JuAnChO and with this i can send email notification.
        One little problem is that i can use only recipient as variable "$1". If i try use "$2" for email subject or "$3" email body email notification doesnt work. If i use static text string it work fine but i need to see in the message whats happened

        Does it have any solution?

        Ohh and i use Zabbix 1.8.4 on Ubuntu 10.x

        Thanks
        Last edited by miovel; 25-02-2011, 14:46.

        Comment

        • thiagolmelo
          Junior Member
          Zabbix Certified Trainer
          Zabbix Certified Specialist
          • Dec 2009
          • 27

          #5
          Hello,

          let me try to help you. I had a problem like that. The solution was set the right permission to user receive the mail.

          Did you check the permission of user that you are setting to receive the alerts?

          Best Regards
          __________________
          --
          Thiago Melo
          [url]www.zabbix.com.br[/url]
          [url]www.uniredeinfo.com.br[/url]
          Porto Alegre - RS - Brasil

          Comment

          • miovel
            Junior Member
            • Feb 2011
            • 9

            #6
            Hello,
            i tried send the message to admin, so i guess this is not permission issue. Or what did you think?
            Anyway thank you for try.
            Last edited by miovel; 28-02-2011, 12:46.

            Comment

            • miovel
              Junior Member
              • Feb 2011
              • 9

              #7
              Originally posted by thiagolmelo
              Hello,

              let me try to help you. I had a problem like that. The solution was set the right permission to user receive the mail.

              Did you check the permission of user that you are setting to receive the alerts?

              Best Regards
              Could you be more specific what should i check? Are you sure this could be my problem even if i send the message to admin user?

              Comment

              • miovel
                Junior Member
                • Feb 2011
                • 9

                #8
                Hi,
                i have made more investigation and i have find out that i can use this
                Code:
                export zabbixemailto=[COLOR="red"]"$1"[/COLOR]
                export zabbixsubject=[COLOR="red"]"$2"[/COLOR]
                export zabbixbody=[COLOR="red"]"$3"[/COLOR]
                but only if i use static text in "Action operations". If i use any variable like trigger name "{TRIGGER.NAME}" i didnt receive the email notification. For better explanation i have attached two pictures, first with working example second with not working example.
                Could anyone explain me why it cant resolve the variables? If i cant solve this issue i cant use Zabbix with good productivity.

                Thanks much for any advice
                Attached Files

                Comment

                Working...