Problem in integration with Zabbix

Issue #2 closed
Stavros Foteinopoulos created an issue

Even though the script works after some customizations in the google account. (Disabling some restrictions). It does not work using Zabbix system. The way I am trying to use it is the following

  • copy to AlertScriptsPath, /etc/zabbix/alert.d
  • chmod 755 zabbix-alert-smtp.sh
  • Go to Zabbix web UI, Administration > Media types > Create media type
  • Enter Script name: zabbix-alert-smtp.sh
  • Save

  • Create Action through Zabbix web UI and use a specific trigger in conditions.

But getting the following results which attach on screenshots.

(Message not sent)

Is there anything wrong at my side. Could you provide more detailed instructions for the integration of your script with zabbix?

Kind Regards,

Stavros

Comments (7)

  1. Daigo Sakamoto repo owner

    If the script works with command line, It might your environment problem.

    AlertScriptsPath might be wrong.

    In my environment, a path of AlertScriptsPath is below.

    /usr/local/share/zabbix/alertscripts/

    Please check your zabbix server settings.(ex. /usr/local/etc/zabbix_server.conf)

    Reach a limitation of sending emails

    Gmail have a limitation of maximum count of sending emails via smtp.gmail.com.

    In this case, you can receive emails later.

    else

    You can find more details in zabbix documentation(https://www.zabbix.com/documentation/2.4/manual/config/notifications/media/script)

  2. Stavros Foteinopoulos reporter

    In my case (debian-like system) the configuration file is in /etc/zabbix/zabbix.conf and AlertScriptsPath in /etc/zabbix/alert.d. There is no limitation issue of Gmail and I follewed exact the same directions you post.

    My only question is that when i cloned your repository it created a directory in alert.d but I moved its' contents direct to alert.d folder. May the scripts need a folder structure or is it ok that I moved it?

    In other terms I cannot find any other thing suspicious for misconfiguration.

    PS: One more thing do you may know if there is any log about this error, cause either in system log or in zabbix log file there is not any trace about this error.

    Thanks, again.

  3. Daigo Sakamoto repo owner

    This script requires settings.py file in the same directory.

    If you add logging code into shell script like below, you'll confirm this script is called or not.

    import logging
    LOG_FILEPATH = '/log_directory/file_name_.log'
    LOG_LEVEL = logging.DEBUG
    LOG_FORMAT = '%(asctime)s [%(levelname)s] %(name)s - %(message)s'
    
    handler = logging.FileHandler(LOG_FILEPATH)
    handler.setFormatter(logging.Formatter(LOG_FORMAT))
    handler.setLevel(LOG_LEVEL)
    
    logger = logging.getLogger(__name__)
    logger.setLevel(LOG_LEVEL)
    logger.addHandler(handler)
    
    ...
    
    logger.debug('called!')
    
  4. Stavros Foteinopoulos reporter

    although i was seen the message i 've send you in the previous screenshot. It sent an alert mail when I restart my vm. So I think you can close the issue, anything from your part works fine and I really thank you for your support. If there is any problem, which i am not sure till I configure some more alerts, it is not in your useful tool.

    Regards again.

  5. Log in to comment