Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-19752

Multiple media types creation with services message templates fails

XMLWordPrintable

    • Sprint 79 (Aug 2021)
    • 0.5

      When you make an API call mediatype.create for 3 and more types creation with services message templates, API returns an error.

      Steps to reproduce:

      1. Make API call for mediatype.create
      2. Create multiple mediatypes(3 and more) with Service, Service Recovery, Service update Message templates

      Expected result: All 3 and more media types should be created successfully.
      Actual result: API returns execution failed error.
      Error

      
          "jsonrpc": "2.0",
          "error": {
              "code": -32500,
              "message": "Application error.",
              "data": "SQL statement execution has failed \"INSERT INTO media_type_message (mediatypeid,eventsource,recovery,subject,message,mediatype_messageid) VALUES ('109','4','0','Service \\\"{SERVICE.NAME}\\\" problem: {EVENT.NAME}','<b>Service problem started</b> at {EVENT.TIME} on {EVENT.DATE}<br><b>Service problem name:</b> {EVENT.NAME}<br><b>Service:</b> {SERVICE.NAME}<br><b>Severity:</b> {EVENT.SEVERITY}<br><b>Original problem ID:</b> {EVENT.ID}<br><br>{SERVICE.ROOTCAUSE}','162'),('109','4','1','Service \\\"{SERVICE.NAME}\\\" resolved in {EVENT.DURATION}: {EVENT.NAME}','<b>Service \\\"{SERVICE.NAME}\\\" has been resolved</b> at {EVENT.RECOVERY.TIME} on {EVENT.RECOVERY.DATE}<br><b>Problem name:</b> {EVENT.NAME}<br><b>Problem duration:</b> {EVENT.DURATION}<br><b>Severity:</b> {EVENT.SEVERITY}<br><b>Original problem ID:</b> {EVENT.ID}','163'),('109','4','2','Changed \\\"{SERVICE.NAME}\\\" service status to {EVENT.UPDATE.SEVERITY} in {EVENT.AGE}','<b>Changed \\\"{SERVICE.NAME}\\\" service status</b> to {EVENT.UPDATE.SEVERITY} at {EVENT.UPDATE.DATE} {EVENT.UPDATE.TIME}.<br><b>Current problem age</b> is {EVENT.AGE}.<br><br>{SERVICE.ROOTCAUSE}','164'),('110','4','0','Service \\\"{SERVICE.NAME}\\\" problem: {EVENT.NAME}','<b>Service problem started</b> at {EVENT.TIME} on {EVENT.DATE}<br><b>Service problem name:</b> {EVENT.NAME}<br><b>Service:</b> {SERVICE.NAME}<br><b>Severity:</b> {EVENT.SEVERITY}<br><b>Original problem ID:</b> {EVENT.ID}<br><br>{SERVICE.ROOTCAUSE}','165'),('110','4','1','Service \\\"{SERVICE.NAME}\\\" resolved in {EVENT.DURATION}: {EVENT.NAME}','<b>Service \\\"{SERVICE.NAME}\\\" has been resolved</b> at {EVENT.RECOVERY.TIME} on {EVENT.RECOVERY.DATE}<br><b>Problem name:</b> {EVENT.NAME}<br><b>Problem duration:</b> {EVENT.DURATION}<br><b>Severity:</b> {EVENT.SEVERITY}<br><b>Original problem ID:</b> {EVENT.ID}','166'),('110','4','2','Changed \\\"{SERVICE.NAME}\\\" service status to {EVENT.UPDATE.SEVERITY} in {EVENT.AGE}','<b>Changed \\\"{SERVICE.NAME}\\\" service status</b> to {EVENT.UPDATE.SEVERITY} at {EVENT.UPDATE.DATE} {EVENT.UPDATE.TIME}.<br><b>Current problem age</b> is {EVENT.AGE}.<br><br>{SERVICE.ROOTCAUSE}','167'),('111','4','0','{EVENT.NAME}\\n{EVENT.DATE} {EVENT.TIME}','168'),('111','4','1','{EVENT.NAME}\\n{EVENT.DATE} {EVENT.TIME}','169'),('111','4','2','{EVENT.NAME}\\n{EVENT.DATE} {EVENT.TIME}','170')\"."
          },
          "id": 1
      }
      }
      

      API call

      {
          "jsonrpc": "2.0",
          "method": "mediatype.create",
          "params": [
              {
                  "name": "Email (HTML) Service",
                  "type": 0,
                  "smtp_server": "[email protected]",
                  "smtp_helo": "zabbix.com",
                  "smtp_email": "[email protected]",
                  "message_templates" : [
                                  {
                                      "eventsource" : 0,
                                      "recovery" : 0,
                                      "subject" : "Service \"{SERVICE.NAME}\" problem: {EVENT.NAME}",
                                      "message" : "<b>Service problem started</b> at {EVENT.TIME} on {EVENT.DATE}<br><b>Service problem name:</b> {EVENT.NAME}<br><b>Service:</b> {SERVICE.NAME}<br><b>Severity:</b> {EVENT.SEVERITY}<br><b>Original problem ID:</b> {EVENT.ID}<br><br>{SERVICE.ROOTCAUSE}"
                                  },
                                  {
                                      "eventsource" : 0,
                                      "recovery" : 1,
                                      "subject" : "Service \"{SERVICE.NAME}\" resolved in {EVENT.DURATION}: {EVENT.NAME}",
                                      "message" : "<b>Service \"{SERVICE.NAME}\" has been resolved</b> at {EVENT.RECOVERY.TIME} on {EVENT.RECOVERY.DATE}<br><b>Problem name:</b> {EVENT.NAME}<br><b>Problem duration:</b> {EVENT.DURATION}<br><b>Severity:</b> {EVENT.SEVERITY}<br><b>Original problem ID:</b> {EVENT.ID}"
                                  },
                                  {
                                      "eventsource" : 0,
                                      "recovery" : 2,
                                      "subject" : "Changed \"{SERVICE.NAME}\" service status to {EVENT.UPDATE.SEVERITY} in {EVENT.AGE}",
                                      "message" : "<b>Changed \"{SERVICE.NAME}\" service status</b> to {EVENT.UPDATE.SEVERITY} at {EVENT.UPDATE.DATE} {EVENT.UPDATE.TIME}.<br><b>Current problem age</b> is {EVENT.AGE}.<br><br>{SERVICE.ROOTCAUSE}"
                                  }
                              ]
              },
              {                
                  "name": "Email Service",
                  "type": 0,
                  "smtp_server": "[email protected]",
                  "smtp_helo": "zabbix.com",
                  "smtp_email": "[email protected]",
                  "message_templates" : [
                                  {
                                      "eventsource" : 0,
                                      "recovery" : 0,
                                      "subject" : "Service \"{SERVICE.NAME}\" problem: {EVENT.NAME}",
                                      "message" : "<b>Service problem started</b> at {EVENT.TIME} on {EVENT.DATE}<br><b>Service problem name:</b> {EVENT.NAME}<br><b>Service:</b> {SERVICE.NAME}<br><b>Severity:</b> {EVENT.SEVERITY}<br><b>Original problem ID:</b> {EVENT.ID}<br><br>{SERVICE.ROOTCAUSE}"
                                  },
                                  {
                                      "eventsource" : 0,
                                      "recovery" : 1,
                                      "subject" : "Service \"{SERVICE.NAME}\" resolved in {EVENT.DURATION}: {EVENT.NAME}",
                                      "message" : "<b>Service \"{SERVICE.NAME}\" has been resolved</b> at {EVENT.RECOVERY.TIME} on {EVENT.RECOVERY.DATE}<br><b>Problem name:</b> {EVENT.NAME}<br><b>Problem duration:</b> {EVENT.DURATION}<br><b>Severity:</b> {EVENT.SEVERITY}<br><b>Original problem ID:</b> {EVENT.ID}"
                                  },
                                  {
                                      "eventsource" : 0,
                                      "recovery" : 2,
                                      "subject" : "Changed \"{SERVICE.NAME}\" service status to {EVENT.UPDATE.SEVERITY} in {EVENT.AGE}",
                                      "message" : "<b>Changed \"{SERVICE.NAME}\" service status</b> to {EVENT.UPDATE.SEVERITY} at {EVENT.UPDATE.DATE} {EVENT.UPDATE.TIME}.<br><b>Current problem age</b> is {EVENT.AGE}.<br><br>{SERVICE.ROOTCAUSE}"
                                  }
                              ]
              },
              {
                  "name": "SMS Service",
                  "type": 2,
                  "gsm_modem": "test",
                  "message_templates" : [
                      {
                          "eventsource" : 0,
                          "recovery" : 0,
                          "message": "{EVENT.NAME}\n{EVENT.DATE} {EVENT.TIME}"
                      },
                                      {
                          "eventsource" : 0,
                          "recovery" : 1,
                          "message": "{EVENT.NAME}\n{EVENT.DATE} {EVENT.TIME}"
                      },
                                      {
                          "eventsource" : 0,
                          "recovery" : 2,
                          "message": "{EVENT.NAME}\n{EVENT.DATE} {EVENT.TIME}"
                      }
                  ]
              }                                                         
          ],
          "auth": "c6624e7083b5ebbb3f5063c80f1b8971",
          "id": 1
      }
      

            gcalenko Gregory Chalenko
            rkalinins Rolands Kalinins (Inactive)
            Team C
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: