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

Slow Function errorMessage in CUserMacroParser.php

XMLWordPrintable

    • Sprint 66 (Jul 2020)
    • 0.5

      Slow funtion errorMessage in CUserMacroParser.php when using trigger.get API.

      trigger.get JSON:
      
      {
       "jsonrpc": "2.0",
       "method": "trigger.get",
       "params": {
       "group": "XXXXXXXXXXXXXXXXXX",
       "filter": {
       "state": 0,
       "status": 0,
       "description": ["XXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXX"]
       },
       "monitored": true,
       "expandDescription": true,
       "skipDependent": true,
       "selectHosts": ["name", "host_id"],
       "output": [
       "description",
       "priority",
       "value"
       ]
       },
       "auth": "XXXXXXXXXXXXXXXXXXXXXXXXX",
       "id": 1
      }
      

      Changing function as below reduced 500ms on API call.

      private function errorMessage($source, $pos) {
       if (!isset($source[$pos])) {
       return ($pos == 0) ? _('macro is empty') : _('unexpected end of macro');
       }
      
      /*for ($p = $pos, $chunk = '', $maxChunkSize = 50; isset($source[$p]); $p++) {
       if (0x80 != (0xc0 & ord($source[$p])) && $maxChunkSize-- == 0) {
       break;
       }
       $chunk .= $source[$p];
       }
      
      if (isset($source[$p])) {
       $chunk .= ' ...';
       }*/
      
      return 'incorrect syntax...';
       }
      

       

            vmurzins Valdis Murzins
            stammer Diego Henrique Stammerjohann
            Team B
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: