Ad Widget

Collapse

Zabbix API send mail

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • crillus
    Junior Member
    • Jun 2013
    • 20

    #1

    Zabbix API send mail

    Hello guys,

    Here is my new expression.

    I'm trying to automate the creation of a send mail action corresponding to several conditions (inclusing a maintenance mode). I've tried the "ZAPIX" webfront to help me troubleshooting my JSON but I just have the standard "parameter error"

    HTML Code:
    {
        "name": "Send mail to user a group",
        "status": 0,
        "esc_period": 3600,
        "def_shortdata": "{TRIGGER.STATUS}: {TRIGGER.NAME}",
        "def_longdata": "my great mail",
        "filter": {
            "evaltype": 3,
            "formula": "A and (B or C) and D and E",
            "conditions": [
                {
                    "conditiontype": 16,
                    "operator": 7,
                    "formulaid": "A"
                },
                {
                    "conditiontype": 13,
                    "operator": 1,
                    "value": 10107,
                    "formulaid": "B"
                },
                {
                    "conditiontype": 13,
                    "operator": 1,
                    "value": 10108,
                    "formulaid": "C"
                },
                {
                    "conditiontype": 4,
                    "operator": 1,
                    "value": 3,
                    "formulaid": "D"
                },
                {
                    "conditiontype": 5,
                    "operator": 0,
                    "value": 1,
                    "formulaid": "E"
                }
            ]
        },
        "operations": [
            {
                "operationtype": 0,
                "esc_period": 0,
                "esc_step_from": 1,
                "esc_step_to": 2,
                "evaltype": 0,
                "opmessage_grp": [
                    {
                        "usrgrpid": 37
                    }
                ],
                "opmessage": {
                    "default_msg": 1,
                    "mediatypeid": "1"
                }
            }
        ]
    }

    Do you see where the error can come from ?

    Thank you by advance
    Last edited by crillus; 19-12-2016, 21:01.
  • jan.garaj
    Senior Member
    Zabbix Certified Specialist
    • Jan 2010
    • 506

    #2
    Try reverse engineering: use Zabbix UI, create desired action and then use action.get to see how it looks -> probably some parameters are missing (eventsource).

    BTW: great feature of Zapix is copy&paste of Zapix URL to publish your query: http://monitoringartist.github.io/za...20%20%20%20%7D
    Devops Monitoring Expert advice: Dockerize/automate/monitor all the things.
    My DevOps stack: Docker / Kubernetes / Mesos / ECS / Terraform / Elasticsearch / Zabbix / Grafana / Puppet / Ansible / Vagrant

    Comment

    • crillus
      Junior Member
      • Jun 2013
      • 20

      #3
      Hello,

      Sorry for the delay I was away for Christmas.

      Thank you for your help, I tried action.get but I didn't found the way to have a full JSON description of an action made by GUI (with all operation, condition...)

      But thanks to you I've been able to correct my JSON !


      Yes there was an eventsource problem

      Code:
      ...
                                              "esc_period":3600,
                                              "eventsource":0,
                                              "def_shortdata":'{TRIGGER.STATUS}: {TRIGGER.NAME}',
      ...
      And there was another error in my conditions :

      The manual say that if you want to define a condition not in maintenance mode, a value is useless so there was no value in my json, actually an empty value was expected :

      Code:
      {
                                                                      "conditiontype":16,
                                                                      "operator":7,
                                                                      "formulaid": "A",
                                                                      "value":''
                                                              }
      And now it works ! thank you !

      Comment

      Working...