Details

      Description

      It would be very convenient to be add value mappings via the API. I currently have a script that does this via db insertions, but it is fragile with respect to the database schema changing.

      The script is below:

      #!/usr/bin/perl
      
      use warnings;
      use strict;
      
      my $usage = "$0 valueMapName number newvalue [number2 newvalue2 [...]]
      E.g.: 
          makevaluemap.pl 'Alarm Status' 1  ok 2  unknown 3  stale 4  problem
          makevaluemap.pl 'Aliveness' 0  dead 1 alive
      ";
      
      my $valueMapName = shift() || die "No new valuemap name";
      my @mapList = @ARGV;
      die "No mappings given. Usage: $usage\n" if scalar(@mapList) == 0;
      
      my $user = qx/whoami/;
      chomp($user);
      die "Must be run as the zabbix user" if $user ne 'zabbix';
      
      my $isEvenNumber = scalar(@mapList) % 2 == 0;
      die "Must give mapping->value pairs. Usage: $usage\n" if not $isEvenNumber;
      my %mappings = @mapList;
      
      my $newValueMapId = 1 + int(qx/psql -t -c 'select max(valuemapid) from valuemaps'/);
      my $newMappingId = 1 + int(qx/psql -t -c 'select max(mappingid) from mappings'/);
      
      eval {
          my $valueMapCmd = qq/psql -t -c "insert into valuemaps (valuemapid, name) values ('$newValueMapId', '$valueMapName');"/;
          print "$valueMapCmd\n";
          system $valueMapCmd;
          eval {
              for my $from (keys %mappings) {
                  my $to = $mappings{$from};
                  my $mappingCmd= qq/psql -t -c "insert into mappings (mappingid, valuemapid, value, newvalue) values ('$newMappingId', '$newValueMapId', '$from', '$to');"/;
                  print "$mappingCmd\n";
                  system $mappingCmd;
                  $newMappingId++;
              }
          };
          if ($@) {
              die "something went wrong inserting into mappings $@";
          }
      };
      if ($@) {
          die "something went wrong inserting into valuemaps $@";
      }
      

      Specification

        Issue Links

          Activity

          Kester Allen created issue -
          richlv made changes -
          Field Original Value New Value
          Labels valuemapping
          Oleksiy Zagorskyi made changes -
          Fix Version/s 2.0.3 [ 11312 ]
          Oleksiy Zagorskyi made changes -
          Labels valuemapping api valuemapping
          Hide
          Kester Allen added a comment - - edited

          ------

          Show
          Kester Allen added a comment - - edited ------
          Oleksiy Zagorskyi made changes -
          Link This issue is duplicated by VGL-1 [ VGL-1 ]
          Hide
          Alexei Vladishev added a comment -

          I agree, it must be supported by Zabbix out of the box.

          Show
          Alexei Vladishev added a comment - I agree, it must be supported by Zabbix out of the box.
          Alexei Vladishev made changes -
          Zabbix ID NA NMR
          Hide
          richlv added a comment -

          ZBXNEXT-1679 asks for valuemap xml import/export

          Show
          richlv added a comment - ZBXNEXT-1679 asks for valuemap xml import/export
          Hide
          Justin McNutt added a comment -

          XML import/export would be nice as well, but that also requires user interaction via the GUI (unless there's an API method like xml.import, which would be amazing). Admittedly, this would go a long way, but would not resolve all cases where API access is needed.

          API access to the value mappings is not just about configuration. In fact, XML import is likely to be a better way to accomplish configuration. However, If I query Event history for an Item that uses a value mapping, there's no good way using the API to query that mapping for proper interpretation. The extra bit of labelling that gives context to the raw data is hidden.

          I would say that the request for API access to the value mappings is much more about reading what's there and proper interpretation of the Event data than anything else. Of course, once there's a "valuemap.*" set of methods, adding .create, .update, and .delete methods is probably not too much of a stretch. But the .get method is probably the most crucial.

          In my humble opinion...

          Show
          Justin McNutt added a comment - XML import/export would be nice as well, but that also requires user interaction via the GUI (unless there's an API method like xml.import, which would be amazing ). Admittedly, this would go a long way, but would not resolve all cases where API access is needed. API access to the value mappings is not just about configuration. In fact, XML import is likely to be a better way to accomplish configuration. However, If I query Event history for an Item that uses a value mapping, there's no good way using the API to query that mapping for proper interpretation. The extra bit of labelling that gives context to the raw data is hidden. I would say that the request for API access to the value mappings is much more about reading what's there and proper interpretation of the Event data than anything else. Of course, once there's a "valuemap.*" set of methods, adding .create, .update, and .delete methods is probably not too much of a stretch. But the .get method is probably the most crucial. In my humble opinion...
          Hide
          Chuck Dand added a comment -

          I'd say that depends on massively on why your using the API in the first place. If implementing a configuration management of Zabbix using something like Puppet via the API, then the ability to create and update Value Mappings is essential, XML import just won't cut it in that circumstance.

          Show
          Chuck Dand added a comment - I'd say that depends on massively on why your using the API in the first place. If implementing a configuration management of Zabbix using something like Puppet via the API, then the ability to create and update Value Mappings is essential, XML import just won't cut it in that circumstance.
          Hide
          richlv added a comment -

          offtopic, but xml import/export via the api is possible already : https://www.zabbix.com/documentation/2.0/manual/appendix/api/configuration

          Show
          richlv added a comment - offtopic, but xml import/export via the api is possible already : https://www.zabbix.com/documentation/2.0/manual/appendix/api/configuration
          Hide
          Justin McNutt added a comment -

          The configuration.import and configuration.export methods do not allow for import/export of valuemaps. If it did, this would be a crude, but effective substitute for a set of valuemap.X methods.

          Show
          Justin McNutt added a comment - The configuration.import and configuration.export methods do not allow for import/export of valuemaps. If it did, this would be a crude, but effective substitute for a set of valuemap.X methods.
          Hide
          richlv added a comment - - edited

          oh, sure - just noted that having xml import/export would indirectly expose partial functionality over the api, too

          Show
          richlv added a comment - - edited oh, sure - just noted that having xml import/export would indirectly expose partial functionality over the api, too
          Alexander Vladishev made changes -
          Workflow ZBXNEXT workflow [ 26498 ] Zabbix workflow [ 31633 ]
          richlv made changes -
          Labels api valuemapping api missingapi valuemapping
          richlv made changes -
          Labels api missingapi valuemapping missingapi valuemapping
          Hide
          Dimitri Bellini added a comment -

          I think is also useful to have an API to query a Value Mapping for a specific Item.
          Thanks

          Show
          Dimitri Bellini added a comment - I think is also useful to have an API to query a Value Mapping for a specific Item. Thanks
          Alexei Vladishev made changes -
          Workflow Zabbix workflow [ 31633 ] Zabbix workflow - new [ 38612 ]
          Hide
          Jens Berthold added a comment -

          This request is open for 2 1/2 years - is there any plan to implement this soon?
          Sorry, but what use is an API if I cannot even modify all aspects of standard items?

          Show
          Jens Berthold added a comment - This request is open for 2 1/2 years - is there any plan to implement this soon? Sorry, but what use is an API if I cannot even modify all aspects of standard items?
          Hide
          richlv added a comment -

          unfortunately, it is not on the roadmap yet. it likely will wait for ZBXNEXT-2519

          Show
          richlv added a comment - unfortunately, it is not on the roadmap yet. it likely will wait for ZBXNEXT-2519
          richlv made changes -
          Link This issue is duplicated by ZBXNEXT-2787 [ ZBXNEXT-2787 ]
          Hide
          richlv added a comment -

          ZBXNEXT-2787 has a patch for 2.2

          Show
          richlv added a comment - ZBXNEXT-2787 has a patch for 2.2
          richlv made changes -
          Summary Zabbix API for adding new Value Mappings Zabbix API for Value Mappings
          Aleksandrs Saveljevs made changes -
          Description It would be very convenient to be add value mappings via the API. I currently have a script that does this via db insertions, but it is fragile with respect to the database schema changing.

          The script is below:

          #!/usr/bin/perl


          use warnings;
          use strict;

          my $usage = "$0 valueMapName number newvalue [number2 newvalue2 [...]]
          E.g.:
              makevaluemap.pl 'Alarm Status' 1 ok 2 unknown 3 stale 4 problem
              makevaluemap.pl 'Aliveness' 0 dead 1 alive
          ";

          my $valueMapName = shift() || die "No new valuemap name";
          my @mapList = @ARGV;
          die "No mappings given. Usage: $usage\n" if scalar(@mapList) == 0;

          my $user = qx/whoami/;
          chomp($user);
          die "Must be run as the zabbix user" if $user ne 'zabbix';

          my $isEvenNumber = scalar(@mapList) % 2 == 0;
          die "Must give mapping->value pairs. Usage: $usage\n" if not $isEvenNumber;
          my %mappings = @mapList;

          my $newValueMapId = 1 + int(qx/psql -t -c 'select max(valuemapid) from valuemaps'/);
          my $newMappingId = 1 + int(qx/psql -t -c 'select max(mappingid) from mappings'/);

          eval {
              my $valueMapCmd = qq/psql -t -c "insert into valuemaps (valuemapid, name) values ('$newValueMapId', '$valueMapName');"/;
              print "$valueMapCmd\n";
              system $valueMapCmd;
              eval {
                  for my $from (keys %mappings) {
                      my $to = $mappings{$from};
                      my $mappingCmd= qq/psql -t -c "insert into mappings (mappingid, valuemapid, value, newvalue) values ('$newMappingId', '$newValueMapId', '$from', '$to');"/;
                      print "$mappingCmd\n";
                      system $mappingCmd;
                      $newMappingId++;
                  }
              };
              if ($@) {
                  die "something went wrong inserting into mappings $@";
              }
          };
          if ($@) {
              die "something went wrong inserting into valuemaps $@";
          }
          It would be very convenient to be add value mappings via the API. I currently have a script that does this via db insertions, but it is fragile with respect to the database schema changing.

          The script is below:

          {code}
          #!/usr/bin/perl

          use warnings;
          use strict;

          my $usage = "$0 valueMapName number newvalue [number2 newvalue2 [...]]
          E.g.:
              makevaluemap.pl 'Alarm Status' 1 ok 2 unknown 3 stale 4 problem
              makevaluemap.pl 'Aliveness' 0 dead 1 alive
          ";

          my $valueMapName = shift() || die "No new valuemap name";
          my @mapList = @ARGV;
          die "No mappings given. Usage: $usage\n" if scalar(@mapList) == 0;

          my $user = qx/whoami/;
          chomp($user);
          die "Must be run as the zabbix user" if $user ne 'zabbix';

          my $isEvenNumber = scalar(@mapList) % 2 == 0;
          die "Must give mapping->value pairs. Usage: $usage\n" if not $isEvenNumber;
          my %mappings = @mapList;

          my $newValueMapId = 1 + int(qx/psql -t -c 'select max(valuemapid) from valuemaps'/);
          my $newMappingId = 1 + int(qx/psql -t -c 'select max(mappingid) from mappings'/);

          eval {
              my $valueMapCmd = qq/psql -t -c "insert into valuemaps (valuemapid, name) values ('$newValueMapId', '$valueMapName');"/;
              print "$valueMapCmd\n";
              system $valueMapCmd;
              eval {
                  for my $from (keys %mappings) {
                      my $to = $mappings{$from};
                      my $mappingCmd= qq/psql -t -c "insert into mappings (mappingid, valuemapid, value, newvalue) values ('$newMappingId', '$newValueMapId', '$from', '$to');"/;
                      print "$mappingCmd\n";
                      system $mappingCmd;
                      $newMappingId++;
                  }
              };
              if ($@) {
                  die "something went wrong inserting into mappings $@";
              }
          };
          if ($@) {
              die "something went wrong inserting into valuemaps $@";
          }
          {code}
          Damien Vargas made changes -
          Link This issue is duplicated by ZBXNEXT-2789 [ ZBXNEXT-2789 ]
          Hide
          Damien Vargas added a comment - - edited

          ZBXNEXT-2789 has a patch for 2.4

          Show
          Damien Vargas added a comment - - edited ZBXNEXT-2789 has a patch for 2.4
          Hide
          Damien Vargas added a comment -

          Frontend Class of API ValueMapping. Use README to install.

          Show
          Damien Vargas added a comment - Frontend Class of API ValueMapping. Use README to install.
          Damien Vargas made changes -
          Attachment zabbixAPIValueMapping2.2.tar.gz [ 34028 ]
          Attachment zabbixAPIValueMapping2.4.tar.gz [ 34029 ]
          Aleksandrs Saveljevs made changes -
          Labels missingapi valuemapping missingapi patch valuemapping
          Alexander Vladishev made changes -
          Assignee Alexei Vladishev [ alexei ] Ivo Kurzemnieks [ iivs ]
          Alexander Vladishev made changes -
          Status Open [ 1 ] READY TO DEVELOP [ 10006 ]
          Fix Version/s 3.0.0alpha3 (trunk) [ 13103 ]
          Alexander Vladishev made changes -
          Zabbix ID NMR
          Ivo Kurzemnieks made changes -
          Status READY TO DEVELOP [ 10006 ] In Progress [ 3 ]
          Hide
          Ivo Kurzemnieks added a comment - - edited

          (1)
          Translation strings added:

          • At least one mapping should be given for value map "%1$s".
          • Duplicate "name" value "%1$s" for value map.
          • Duplicate mapping value "%1$s" for value map "%2$s".
          • Empty new value in value map "%1$s".
          • Empty value map ID.
          • Incorrect value map ID.
          • Mapping is missing parameters: %1$s for value map "%2$s".
          • No "%1$s" given for value map.
          • Only super admins can create value maps.
          • Only super admins can delete value maps.
          • Only super admins can update value maps.
          • Value map is missing parameters: %1$s
          • Value map name cannot be empty.

          Translation strings removed:

          • Mapping value "%1$s" is not unique.
          • Value cannot be mapped to empty string.
          • Value map "%1$s" "%2$s".
          • Value map "%1$s".
          • Value map with valuemapid "%1$s" does not exist.
          • Value mapping must have at least one mapping.

          Alexander Vladishev Updated list of strings. Please check.

          Ivo Kurzemnieks CLOSED

          Show
          Ivo Kurzemnieks added a comment - - edited (1) Translation strings added: At least one mapping should be given for value map "%1$s". Duplicate "name" value "%1$s" for value map. Duplicate mapping value "%1$s" for value map "%2$s". Empty new value in value map "%1$s". Empty value map ID. Incorrect value map ID. Mapping is missing parameters: %1$s for value map "%2$s". No "%1$s" given for value map. Only super admins can create value maps. Only super admins can delete value maps. Only super admins can update value maps. Value map is missing parameters: %1$s Value map name cannot be empty. Translation strings removed: Mapping value "%1$s" is not unique. Value cannot be mapped to empty string. Value map "%1$s" "%2$s". Value map "%1$s". Value map with valuemapid "%1$s" does not exist. Value mapping must have at least one mapping. Alexander Vladishev Updated list of strings. Please check. Ivo Kurzemnieks CLOSED
          Hide
          Ivo Kurzemnieks added a comment -

          RESOLVED in svn://svn.zabbix.com/branches/dev/ZBXNEXT-1424

          Show
          Ivo Kurzemnieks added a comment - RESOLVED in svn://svn.zabbix.com/branches/dev/ZBXNEXT-1424
          Ivo Kurzemnieks made changes -
          Status In Progress [ 3 ] Resolved [ 5 ]
          Alexander Vladishev made changes -
          Status Resolved [ 5 ] IN TESTING [ 10007 ]
          Assignee Ivo Kurzemnieks [ iivs ] Alexander Vladishev [ sasha ]
          Hide
          Alexander Vladishev added a comment - - edited

          (2) it must be written easier

          if (self::$userData['type'] == USER_TYPE_SUPER_ADMIN) {
          }
          elseif ($options['editable'] === null && self::$userData['type'] == USER_TYPE_ZABBIX_ADMIN) {
          }
          elseif ($options['editable'] !== null || self::$userData['type'] != USER_TYPE_SUPER_ADMIN) {
              return [];
          }
          

          Maybe so:

          if ($options['editable'] !== null && self::$userData['type'] != USER_TYPE_SUPER_ADMIN) {
              return [];
          }
          

          Ivo Kurzemnieks Indeed so. RESOLVED in r56239

          Alexander Vladishev CLOSED

          Show
          Alexander Vladishev added a comment - - edited (2) it must be written easier if (self::$userData['type'] == USER_TYPE_SUPER_ADMIN) { } elseif ($options['editable'] === null && self::$userData['type'] == USER_TYPE_ZABBIX_ADMIN) { } elseif ($options['editable'] !== null || self::$userData['type'] != USER_TYPE_SUPER_ADMIN) { return []; } Maybe so: if ($options['editable'] !== null && self::$userData['type'] != USER_TYPE_SUPER_ADMIN) { return []; } Ivo Kurzemnieks Indeed so. RESOLVED in r56239 Alexander Vladishev CLOSED
          Alexander Vladishev made changes -
          Description It would be very convenient to be add value mappings via the API. I currently have a script that does this via db insertions, but it is fragile with respect to the database schema changing.

          The script is below:

          {code}
          #!/usr/bin/perl

          use warnings;
          use strict;

          my $usage = "$0 valueMapName number newvalue [number2 newvalue2 [...]]
          E.g.:
              makevaluemap.pl 'Alarm Status' 1 ok 2 unknown 3 stale 4 problem
              makevaluemap.pl 'Aliveness' 0 dead 1 alive
          ";

          my $valueMapName = shift() || die "No new valuemap name";
          my @mapList = @ARGV;
          die "No mappings given. Usage: $usage\n" if scalar(@mapList) == 0;

          my $user = qx/whoami/;
          chomp($user);
          die "Must be run as the zabbix user" if $user ne 'zabbix';

          my $isEvenNumber = scalar(@mapList) % 2 == 0;
          die "Must give mapping->value pairs. Usage: $usage\n" if not $isEvenNumber;
          my %mappings = @mapList;

          my $newValueMapId = 1 + int(qx/psql -t -c 'select max(valuemapid) from valuemaps'/);
          my $newMappingId = 1 + int(qx/psql -t -c 'select max(mappingid) from mappings'/);

          eval {
              my $valueMapCmd = qq/psql -t -c "insert into valuemaps (valuemapid, name) values ('$newValueMapId', '$valueMapName');"/;
              print "$valueMapCmd\n";
              system $valueMapCmd;
              eval {
                  for my $from (keys %mappings) {
                      my $to = $mappings{$from};
                      my $mappingCmd= qq/psql -t -c "insert into mappings (mappingid, valuemapid, value, newvalue) values ('$newMappingId', '$newValueMapId', '$from', '$to');"/;
                      print "$mappingCmd\n";
                      system $mappingCmd;
                      $newMappingId++;
                  }
              };
              if ($@) {
                  die "something went wrong inserting into mappings $@";
              }
          };
          if ($@) {
              die "something went wrong inserting into valuemaps $@";
          }
          {code}
          It would be very convenient to be add value mappings via the API. I currently have a script that does this via db insertions, but it is fragile with respect to the database schema changing.

          The script is below:

          {code}
          #!/usr/bin/perl

          use warnings;
          use strict;

          my $usage = "$0 valueMapName number newvalue [number2 newvalue2 [...]]
          E.g.:
              makevaluemap.pl 'Alarm Status' 1 ok 2 unknown 3 stale 4 problem
              makevaluemap.pl 'Aliveness' 0 dead 1 alive
          ";

          my $valueMapName = shift() || die "No new valuemap name";
          my @mapList = @ARGV;
          die "No mappings given. Usage: $usage\n" if scalar(@mapList) == 0;

          my $user = qx/whoami/;
          chomp($user);
          die "Must be run as the zabbix user" if $user ne 'zabbix';

          my $isEvenNumber = scalar(@mapList) % 2 == 0;
          die "Must give mapping->value pairs. Usage: $usage\n" if not $isEvenNumber;
          my %mappings = @mapList;

          my $newValueMapId = 1 + int(qx/psql -t -c 'select max(valuemapid) from valuemaps'/);
          my $newMappingId = 1 + int(qx/psql -t -c 'select max(mappingid) from mappings'/);

          eval {
              my $valueMapCmd = qq/psql -t -c "insert into valuemaps (valuemapid, name) values ('$newValueMapId', '$valueMapName');"/;
              print "$valueMapCmd\n";
              system $valueMapCmd;
              eval {
                  for my $from (keys %mappings) {
                      my $to = $mappings{$from};
                      my $mappingCmd= qq/psql -t -c "insert into mappings (mappingid, valuemapid, value, newvalue) values ('$newMappingId', '$newValueMapId', '$from', '$to');"/;
                      print "$mappingCmd\n";
                      system $mappingCmd;
                      $newMappingId++;
                  }
              };
              if ($@) {
                  die "something went wrong inserting into mappings $@";
              }
          };
          if ($@) {
              die "something went wrong inserting into valuemaps $@";
          }
          {code}

          [Specification|https://www.zabbix.org/wiki/Docs/specs/ZBXNEXT-1424]
          Hide
          Alexander Vladishev added a comment - - edited

          (3) Take a look at my minor changes in r56131, r56132, r56141, r56142.

          Ivo Kurzemnieks CLOSED

          Show
          Alexander Vladishev added a comment - - edited (3) Take a look at my minor changes in r56131, r56132, r56141, r56142. Ivo Kurzemnieks CLOSED
          Hide
          Alexander Vladishev added a comment - - edited

          (4) check for the duplicated names in validateCreate() is not effective

          Alexander Vladishev RESOLVED in r56143

          Ivo Kurzemnieks Thanks!
          CLOSED

          Show
          Alexander Vladishev added a comment - - edited (4) check for the duplicated names in validateCreate() is not effective Alexander Vladishev RESOLVED in r56143 Ivo Kurzemnieks Thanks! CLOSED
          Hide
          Alexander Vladishev added a comment - - edited

          (5) SQL request must be removed from valuemap.create().

          Alexander Vladishev RESOLVED in r56145

          Ivo Kurzemnieks Thanks!
          CLOSED

          Show
          Alexander Vladishev added a comment - - edited (5) SQL request must be removed from valuemap.create(). Alexander Vladishev RESOLVED in r56145 Ivo Kurzemnieks Thanks! CLOSED
          Hide
          Alexander Vladishev added a comment - - edited

          (6) check for the duplicated names in validateUpdate() is not effective

          Alexander Vladishev RESOLVED in r56156

          Ivo Kurzemnieks Thanks!
          CLOSED

          Show
          Alexander Vladishev added a comment - - edited (6) check for the duplicated names in validateUpdate() is not effective Alexander Vladishev RESOLVED in r56156 Ivo Kurzemnieks Thanks! CLOSED
          Hide
          Alexander Vladishev added a comment - - edited

          (7) selectMappings option must support "count"

          Ivo Kurzemnieks RESOLVED in r56236

          Alexander Vladishev Custom SQL request should be created in this case:

          SELECT valuemapid,COUNT(*) AS cnt FROM mappings GROUP BY valuemapid

          REOPENED

          Ivo Kurzemnieks RESOLVED in r56264

          Alexander Vladishev Good! But take a look at my changes in r56269.

          Ivo Kurzemnieks Thanks!
          CLOSED

          Show
          Alexander Vladishev added a comment - - edited (7) selectMappings option must support "count" Ivo Kurzemnieks RESOLVED in r56236 Alexander Vladishev Custom SQL request should be created in this case: SELECT valuemapid,COUNT(*) AS cnt FROM mappings GROUP BY valuemapid REOPENED Ivo Kurzemnieks RESOLVED in r56264 Alexander Vladishev Good! But take a look at my changes in r56269. Ivo Kurzemnieks Thanks! CLOSED
          Hide
          Alexander Vladishev added a comment - - edited

          (8) Too many SQL requests with selectMappings option.

          SELECT t.mappingid,t.valuemapid FROM mappings t WHERE t.valuemapid IN ('24','25','26','27')
          SELECT m.* FROM mappings m WHERE m.mappingid BETWEEN '180' AND '187'
          

          Only one request will be enough to get mappings.

          SELECT m.* FROM mappings m WHERE m.valuemapid IN ('24','25','26','27')
          

          Ivo Kurzemnieks RESOLVED in r56235

          Alexander Vladishev Using of array_key_exists() in the filter options is useless. 'valuemapids' is always present in $options array.

          'filter' => array_key_exists('valuemapids', $options)
              ? ...
              : ...
          

          REOPENED

          Ivo Kurzemnieks RESOLVED in r56264

          Alexander Vladishev CLOSED

          Show
          Alexander Vladishev added a comment - - edited (8) Too many SQL requests with selectMappings option. SELECT t.mappingid,t.valuemapid FROM mappings t WHERE t.valuemapid IN ('24','25','26','27') SELECT m.* FROM mappings m WHERE m.mappingid BETWEEN '180' AND '187' Only one request will be enough to get mappings. SELECT m.* FROM mappings m WHERE m.valuemapid IN ('24','25','26','27') Ivo Kurzemnieks RESOLVED in r56235 Alexander Vladishev Using of array_key_exists() in the filter options is useless. 'valuemapids' is always present in $options array. 'filter' => array_key_exists('valuemapids', $options) ? ... : ... REOPENED Ivo Kurzemnieks RESOLVED in r56264 Alexander Vladishev CLOSED
          Hide
          Alexander Vladishev added a comment - - edited

          (9) valuemap.get() returns an empty array instead of number of the valuemaps for non super-admins

          • Request
            {
                "countOutput" : true,
                "editable" : true
            }
            
          • Response
            Logged as superadmin:
            {
                "jsonrpc": "2.0",
                "result": "27",
                "id": 7
            }
            
            Logged as admin or regular user:
            {
                "jsonrpc": "2.0",
                "result": [],
                "id": 9
            }
            

          Ivo Kurzemnieks For me this happened only for regular users. RESOLVED in r56239

          Alexander Vladishev Still reproducible. REOPENED

          Ivo Kurzemnieks RESOLVED in r56268

          Alexander Vladishev CLOSED

          Show
          Alexander Vladishev added a comment - - edited (9) valuemap.get() returns an empty array instead of number of the valuemaps for non super-admins Request { "countOutput" : true , "editable" : true } Response Logged as superadmin: { "jsonrpc" : "2.0" , "result" : "27" , "id" : 7 } Logged as admin or regular user: { "jsonrpc" : "2.0" , "result" : [], "id" : 9 } Ivo Kurzemnieks For me this happened only for regular users. RESOLVED in r56239 Alexander Vladishev Still reproducible. REOPENED Ivo Kurzemnieks RESOLVED in r56268 Alexander Vladishev CLOSED
          Hide
          Alexander Vladishev added a comment - - edited

          (10) Possible "Undefined index" in valuemap.update()

          • Request:
            {
                {
                    "valuemapid" => 24,
                    "name" => "test"
                },
                {
                    "valuemapid" => 25
                }
            }
            
          Undefined index: name [CFrontendApiWrapper->update() → CApiWrapper->__call() → CFrontendApiWrapper->callMethod() → CApiWrapper->callMethod() → CFrontendApiWrapper->callClientMethod() → CLocalApiClient->callMethod() → call_user_func_array() → CValueMap->update() in include/classes/api/services/CValueMap.php:196]
          

          Alexander Vladishev RESOLVED in r56184

          Ivo Kurzemnieks Possibly fixed and then broken again. Found it again and fixed.
          RESOLVED in r56226

          Alexander Vladishev Thanks! Take a look at my changes in r56256.

          Ivo Kurzemnieks CLOSED

          Show
          Alexander Vladishev added a comment - - edited (10) Possible "Undefined index" in valuemap.update() Request: { { "valuemapid" => 24, "name" => "test" }, { "valuemapid" => 25 } } Undefined index: name [CFrontendApiWrapper->update() → CApiWrapper->__call() → CFrontendApiWrapper->callMethod() → CApiWrapper->callMethod() → CFrontendApiWrapper->callClientMethod() → CLocalApiClient->callMethod() → call_user_func_array() → CValueMap->update() in include/classes/api/services/CValueMap.php:196] Alexander Vladishev RESOLVED in r56184 Ivo Kurzemnieks Possibly fixed and then broken again. Found it again and fixed. RESOLVED in r56226 Alexander Vladishev Thanks! Take a look at my changes in r56256. Ivo Kurzemnieks CLOSED
          Hide
          Alexander Vladishev added a comment - - edited

          (11) valuemap.update() can be work faster

          Alexander Vladishev RESOLVED in r56184

          Ivo Kurzemnieks Thanks!
          CLOSED

          Show
          Alexander Vladishev added a comment - - edited (11) valuemap.update() can be work faster Alexander Vladishev RESOLVED in r56184 Ivo Kurzemnieks Thanks! CLOSED
          Hide
          Alexander Vladishev added a comment - - edited

          (12) valuemap.delete() can be work faster

          Alexander Vladishev RESOLVED in r56186

          Ivo Kurzemnieks Thanks!
          CLOSED

          Show
          Alexander Vladishev added a comment - - edited (12) valuemap.delete() can be work faster Alexander Vladishev RESOLVED in r56186 Ivo Kurzemnieks Thanks! CLOSED
          Hide
          Alexander Vladishev added a comment - - edited

          (13) caching in function getMappedValue() is not effective

          getMappedValue('100', 17);

          SELECT  vm.valuemapid FROM valuemaps vm WHERE vm.valuemapid='17'
          SELECT  t.mappingid,t.valuemapid FROM mappings t WHERE t.valuemapid='17'
          SELECT m.mappingid,m.value,m.newvalue FROM mappings m WHERE m.mappingid BETWEEN '89' AND '165'          <= here we can cache all mappings
          

          getMappedValue('101', 17);

          SELECT  vm.valuemapid FROM valuemaps vm WHERE vm.valuemapid='17'
          SELECT  t.mappingid,t.valuemapid FROM mappings t WHERE t.valuemapid='17'
          SELECT m.mappingid,m.value,m.newvalue FROM mappings m WHERE m.mappingid BETWEEN '89' AND '165'
          

          Alexander Vladishev RESOLVED in r56190.

          Ivo Kurzemnieks Thanks!
          CLOSED

          Show
          Alexander Vladishev added a comment - - edited (13) caching in function getMappedValue() is not effective getMappedValue('100', 17); SELECT vm.valuemapid FROM valuemaps vm WHERE vm.valuemapid='17' SELECT t.mappingid,t.valuemapid FROM mappings t WHERE t.valuemapid='17' SELECT m.mappingid,m.value,m.newvalue FROM mappings m WHERE m.mappingid BETWEEN '89' AND '165' <= here we can cache all mappings getMappedValue('101', 17); SELECT vm.valuemapid FROM valuemaps vm WHERE vm.valuemapid='17' SELECT t.mappingid,t.valuemapid FROM mappings t WHERE t.valuemapid='17' SELECT m.mappingid,m.value,m.newvalue FROM mappings m WHERE m.mappingid BETWEEN '89' AND '165' Alexander Vladishev RESOLVED in r56190. Ivo Kurzemnieks Thanks! CLOSED
          Alexander Vladishev made changes -
          Fix Version/s 3.0.0alpha4 (trunk) [ 13200 ]
          Fix Version/s 3.0.0alpha3 [ 13103 ]
          Hide
          Alexander Vladishev added a comment - - edited

          (14) Confirmation messages must be located in the view

          frontends/php/adm.valuemapping.php:124:133

          if ($valuemap_count['cnt'] == 0) {
              $data['confirmMessage'] = _('Delete selected value mapping?');
          }
          else {
              $data['confirmMessage'] = _n(
                  'Delete selected value mapping? It is used for %d item!',
                  'Delete selected value mapping? It is used for %d items!',
                  $valuemap_count['cnt']
              );
          }
          

          Ivo Kurzemnieks RESOLVED in r56240

          Alexander Vladishev CLOSED

          Show
          Alexander Vladishev added a comment - - edited (14) Confirmation messages must be located in the view frontends/php/adm.valuemapping.php:124:133 if ($valuemap_count['cnt'] == 0) { $data['confirmMessage'] = _('Delete selected value mapping?'); } else { $data['confirmMessage'] = _n( 'Delete selected value mapping? It is used for %d item!', 'Delete selected value mapping? It is used for %d items!', $valuemap_count['cnt'] ); } Ivo Kurzemnieks RESOLVED in r56240 Alexander Vladishev CLOSED
          Hide
          Alexander Vladishev added a comment - - edited

          (15) nonexistent fields are used in the API calls

          frontends/php/adm.valuemapping.php:107,136 'selectMappings' => ['mappingid', 'value', 'newvalue']

          Alexander Vladishev RESOLVED in r56253

          Ivo Kurzemnieks Thanks!
          CLOSED

          Show
          Alexander Vladishev added a comment - - edited (15) nonexistent fields are used in the API calls frontends/php/adm.valuemapping.php:107,136 'selectMappings' => [ 'mappingid', 'value', 'newvalue'] Alexander Vladishev RESOLVED in r56253 Ivo Kurzemnieks Thanks! CLOSED
          Hide
          Alexander Vladishev added a comment - - edited

          (16) Direct SQL requests must be replaced by API calls.

          frontends/php/adm.valuemapping.php:120

          Alexander Vladishev RESOLVED in r56255

          Ivo Kurzemnieks Thanks!
          CLOSED

          Show
          Alexander Vladishev added a comment - - edited (16) Direct SQL requests must be replaced by API calls. frontends/php/adm.valuemapping.php:120 Alexander Vladishev RESOLVED in r56255 Ivo Kurzemnieks Thanks! CLOSED
          Hide
          Alexander Vladishev added a comment - - edited

          (17) Templates must be written by using our html classes

          Alexander Vladishev RESOLVED in r56260.

          Ivo Kurzemnieks Minor coding style fix in r56266, please review.

          Alexander Vladishev CLOSED

          Show
          Alexander Vladishev added a comment - - edited (17) Templates must be written by using our html classes Alexander Vladishev RESOLVED in r56260. Ivo Kurzemnieks Minor coding style fix in r56266, please review. Alexander Vladishev CLOSED
          Hide
          Alexander Vladishev added a comment - - edited

          (18) Added [Clone] button for value mappings. It will be more consistent with other forms.

          Alexander Vladishev RESOLVED in r56261.

          Ivo Kurzemnieks Thanks! jQuery code simplified in r56267, please review.

          Alexander Vladishev Thanks! CLOSED

          Show
          Alexander Vladishev added a comment - - edited (18) Added [Clone] button for value mappings. It will be more consistent with other forms. Alexander Vladishev RESOLVED in r56261. Ivo Kurzemnieks Thanks! jQuery code simplified in r56267, please review. Alexander Vladishev Thanks! CLOSED
          Hide
          Alexander Vladishev added a comment - - edited

          (19) Unused form name "valuemap_form"; unused class "row_mappings"

          Alexander Vladishev RESOLVED in r56262.

          Ivo Kurzemnieks

          Undefined variable: tab [adm.valuemapping.php:152 → CView->render() → include() in include\views\administration.general.valuemapping.edit.php:109]

          RESOLVED in r56265

          Alexander Vladishev Many thanks! CLOSED

          Show
          Alexander Vladishev added a comment - - edited (19) Unused form name "valuemap_form"; unused class "row_mappings" Alexander Vladishev RESOLVED in r56262. Ivo Kurzemnieks Undefined variable: tab [adm.valuemapping.php:152 → CView->render() → include() in include\views\administration.general.valuemapping.edit.php:109] RESOLVED in r56265 Alexander Vladishev Many thanks! CLOSED
          Alexander Vladishev made changes -
          Status IN TESTING [ 10007 ] READY TO DEVELOP [ 10006 ]
          Assignee Alexander Vladishev [ sasha ] Ivo Kurzemnieks [ iivs ]
          Ivo Kurzemnieks made changes -
          Status READY TO DEVELOP [ 10006 ] In Progress [ 3 ]
          Hide
          Alexander Vladishev added a comment - - edited

          (20) "sortfield" argument must support "name". Specification is updated accordingly.

          Ivo Kurzemnieks RESOLVED in r56263

          Alexander Vladishev CLOSED

          Show
          Alexander Vladishev added a comment - - edited (20) "sortfield" argument must support "name". Specification is updated accordingly. Ivo Kurzemnieks RESOLVED in r56263 Alexander Vladishev CLOSED
          Ivo Kurzemnieks made changes -
          Status In Progress [ 3 ] Resolved [ 5 ]
          Assignee Ivo Kurzemnieks [ iivs ] Alexander Vladishev [ sasha ]
          Alexander Vladishev made changes -
          Status Resolved [ 5 ] IN TESTING [ 10007 ]
          Alexander Vladishev made changes -
          Status IN TESTING [ 10007 ] Tested [ 10002 ]
          Assignee Alexander Vladishev [ sasha ] Ivo Kurzemnieks [ iivs ]
          Hide
          Ivo Kurzemnieks added a comment -

          Implemented in pre-3.0.0alpha4 (trunk) r56276

          Show
          Ivo Kurzemnieks added a comment - Implemented in pre-3.0.0alpha4 (trunk) r56276
          Ivo Kurzemnieks made changes -
          Assignee Ivo Kurzemnieks [ iivs ]
          Status Tested [ 10002 ] Needs documenting [ 10004 ]
          Show
          Ivo Kurzemnieks added a comment - - edited (21) API documentation updated: https://www.zabbix.com/documentation/3.0/manual/api/changes_2.4_-_3.0 https://www.zabbix.com/documentation/3.0/manual/api/reference/valuemap https://www.zabbix.com/documentation/3.0/manual/api/reference/valuemap/object https://www.zabbix.com/documentation/3.0/manual/api/reference/valuemap/create https://www.zabbix.com/documentation/3.0/manual/api/reference/valuemap/get https://www.zabbix.com/documentation/3.0/manual/api/reference/valuemap/update Alexander Vladishev Very good! But, "mappings" property is not described on > Value map object REOPENED Ivo Kurzemnieks RESOLVED Alexander Vladishev Many thanks! CLOSED
          Hide
          Alexander Vladishev added a comment - - edited

          (22) User documentation:

          Alexander Vladishev

          Martins Valkovskis Reviewed. looks good.

          Martins Valkovskis

          Alexander Vladishev Looks good. CLOSED

          Show
          Alexander Vladishev added a comment - - edited (22) User documentation: What's new in Zabbix 3.0.0 #API improvements Value mapping : screenshot with [Clone] button Alexander Vladishev What's new in Zabbix 3.0.0 #API improvements RESOLVED Martins Valkovskis Reviewed. looks good. Martins Valkovskis Value mapping : screenshot with [Clone] button RESOLVED Alexander Vladishev Looks good. CLOSED
          Alexander Vladishev made changes -
          Assignee Ivo Kurzemnieks [ iivs ]
          Ivo Kurzemnieks made changes -
          Assignee Ivo Kurzemnieks [ iivs ] Martins Valkovskis [ martins-v ]
          Martins Valkovskis made changes -
          Status Needs documenting [ 10004 ] IN DOCUMENTING [ 10008 ]
          Martins Valkovskis made changes -
          Status IN DOCUMENTING [ 10008 ] Documented [ 10005 ]
          Martins Valkovskis made changes -
          Assignee Martins Valkovskis [ martins-v ] Alexander Vladishev [ sasha ]
          Alexander Vladishev made changes -
          Assignee Alexander Vladishev [ sasha ]
          Status Documented [ 10005 ] Done [ 10003 ]
          Alexander Vladishev made changes -
          Status Done [ 10003 ] Closed [ 6 ]
          Resolution Fixed [ 1 ]
          Alexander Vladishev made changes -
          Workflow Zabbix workflow - new [ 38612 ] Copy of Zabbix workflow - new [ 73670 ]
          Alexander Vladishev made changes -
          Workflow Copy of Zabbix workflow - new [ 73670 ] Zabbix workflow - new [ 88955 ]
          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open READY TO DEVELOP READY TO DEVELOP
          1111d 18h 4m 1 Alexander Vladishev 2015 Sep 30 17:07
          IN TESTING IN TESTING READY TO DEVELOP READY TO DEVELOP
          6d 2h 39m 1 Alexander Vladishev 2015 Oct 19 16:31
          READY TO DEVELOP READY TO DEVELOP In Progress In Progress
          40m 40s 2 Ivo Kurzemnieks 2015 Oct 19 17:07
          In Progress In Progress Resolved Resolved
          1h 31m 2 Ivo Kurzemnieks 2015 Oct 19 18:39
          Resolved Resolved IN TESTING IN TESTING
          12d 21h 48m 2 Alexander Vladishev 2015 Oct 19 19:47
          IN TESTING IN TESTING Merging Merging
          3h 59m 1 Alexander Vladishev 2015 Oct 19 23:47
          Merging Merging Needs documenting Needs documenting
          13h 57m 1 Ivo Kurzemnieks 2015 Oct 20 13:44
          Needs documenting Needs documenting IN DOCUMENTING IN DOCUMENTING
          1d 1h 13m 1 Martins Valkovskis 2015 Oct 21 14:58
          IN DOCUMENTING IN DOCUMENTING Doc. sign-off Doc. sign-off
          11s 1 Martins Valkovskis 2015 Oct 21 14:58
          Doc. sign-off Doc. sign-off Done Done
          2h 30m 1 Alexander Vladishev 2015 Oct 21 17:28
          Done Done Closed Closed
          4s 1 Alexander Vladishev 2015 Oct 21 17:28

            People

            • Assignee:
              Unassigned
              Reporter:
              Kester Allen
            • Votes:
              25 Vote for this issue
              Watchers:
              20 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: