Ad Widget

Collapse

Email Alerts - From INVENTORY POC EMAIL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fxm73
    Junior Member
    • Nov 2014
    • 5

    #1

    Email Alerts - From INVENTORY POC EMAIL

    Zabbix release: 2.4.1

    I've been running Zabbix for a while as a migration from Nagios, and am having some issues understanding how to email an alert using the field from the host:
    • {INVENTORY.POC.PRIMARY.EMAIL<1-9>} (I'm wanting to use #1 for this example)


    I can create a trigger that actions an action after 20 minutes of a host being unresponsive.

    However the action can only be created by having a static user assigned to the action. Where the user is created under Administration > Users.

    This works reliably and as expected, however what I am attempting to do is to create an action that uses the {INVENTORY.POC.PRIMARY.EMAIL<1-9>} field to email the assigned person for that host. Without the need to create 3000+ users which then need to be managed individually, and then have 3000+ actions created and then manually assigned to each host.

    I'm wondering if anyone could enlighten me on how I can accomplish this.
  • evertonco
    Member
    • Aug 2014
    • 75

    #2
    It's very uncommon, but... You could create a custom script that takes one parameter (the {INVENTORY.POC.PRIMARY.EMAIL<1-9>} macro) and, in the action, use remote command operation with Zabbix server as Execute on option.

    That way, you don't need configure user to send.

    This script must send an e-mail to parameter received by remote command.

    Comment

    • fxm73
      Junior Member
      • Nov 2014
      • 5

      #3
      evertonco thanks for that. I've actually completed that now and have both email, and sms working with a script when the services now go offline.

      I placed the scripts in /usr/lib/zabbix/externalscripts/

      email.sh
      Code:
      #!/bin/sh
      
      export [email protected]
      export zabbixemailto=$1
      export zabbixsubject="$2"
      export zabbixbody="$3"
      export smtpserver=xXxXxXxXx.X.X
      export [email protected]
      
      /usr/bin/sendemail -f $smtpemailfrom -t $zabbixemailto -u $zabbixsubject -m $zabbixbody -s $smtpserver:25 -bcc $bcc
      sms.sh

      Code:
      #!/bin/sh
      export smsfrom=XxXxXxXxXx
      export smsusername=XxXxXxXxXx
      export smspassword=XxXxXxXxXx
      export zabbixsmsto=$1
      export zabbixbody="$2"
      
      curl -X POST -d "username='$smsusername'&password='$smspassword'&from='$smsfrom'&to=$zabbixsmsto&message='$zabbixbody'" http://api.smsbroadcast.com.au/api.php

      Comment


      • alpa
        alpa commented
        Editing a comment
        Hello,

        can you explain me bcc=....

        please ?
    Working...