Ad Widget

Collapse

variables in email generated by Actions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • forlinuxsupport
    Member
    • Oct 2005
    • 39

    #1

    variables in email generated by Actions

    Hi

    Is it possible to get the hostgroup of a trigger to have it included in the email sent by an "Action".

    e.g. If the host is in a group called "Xen" - I want that hostgroup wording in the email.

    This on the Configuration -> Actions page

    I would guess it might relate to the MACRO page - http://www.zabbix.com/documentation/.../config/macros

    I'm using Zabbix 1.8.5.

    Regards
  • untergeek
    Senior Member
    Zabbix Certified Specialist
    • Jun 2009
    • 512

    #2
    You could extend it with a php script that parses it out. If you look at my lone blog post I have created a solution that does something like that. We don't get the host group for display, but it could do so with minimal alteration.

    Comment

    • Davidus
      Senior Member
      • Dec 2010
      • 281

      #3
      Personally I, when cant do something with mcros, am using {TRIGGER.COMMENT}

      Comment

      • hopetrunks
        Junior Member
        • Jun 2013
        • 8

        #4
        Can't find the way to do it. Even if your blog (maybe cause i'm french and my english is not perfect).

        I wanna do exactly the same thing than asked before.

        Add the hostgroup of the host (because in my company, one hostgroup = one customer) in the mail body of the notification.

        Apparently we can do that with a script ...

        (I don't know why it's not a native implementation in zabbix ..)

        Comment

        • hopetrunks
          Junior Member
          • Jun 2013
          • 8

          #5
          Nobody know ? Cause the only way i find for do it is to create one action for each hostgroup, but it's not perfect ...

          Comment

          • steveboyson
            Senior Member
            • Jul 2013
            • 582

            #6
            Originally posted by hopetrunks
            Nobody know ? Cause the only way i find for do it is to create one action for each hostgroup, but it's not perfect ...
            You may want to use an external handler rather than the builtin email function of zabbix. That means, you define the required parameters in your triger definition and then pass these vars to a self-written script.

            The script could utilize something like that:
            (follwoing is mysql code, change it according your needs)

            select g.name from groups g, hosts h, hosts_groups hg where g.groupid = hg.groupid and h.hostid = hg.hostid and h.host like "$YOUR_HOST_NAME";

            This piece of SQL code would give you the names of the hostgroups the host "YOUR_HOST_NAME" is in. Take care if it is member of more than one hostgroup.

            So, format your notification message accordingly and the send the output to sendmail/postfix/whatever or use a higher level mail engine as Perl's Net::SMTP

            Good luck!

            Comment

            • hopetrunks
              Junior Member
              • Jun 2013
              • 8

              #7
              What ? Use an external handler ... That's seem a little to complicate for just what i want.

              More, i'm in an internship, and i don't think i'll have the time for that ...

              Comment

              Working...