Ad Widget

Collapse

Too small UserMacro Value Length issue (255 characters)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neiromc
    Member
    • Sep 2010
    • 58

    #1

    Too small UserMacro Value Length issue (255 characters)

    Hi all!

    Today i have some issue with value length field in host macro section.
    Field "value" length is quoted by 255 (varchar type) chars.

    I make a patch which consists of sql patch (change value type in db from "varchar" to "text") and php files of zabbix-frontend where zabbix check string length and update db fields.

    As Is! Enjoy!

    MEGA provides free cloud storage with convenient and powerful always-on privacy. Claim your free 50GB now!
  • StevenBrs
    Junior Member
    • Sep 2015
    • 11

    #2
    File no longer available, but I just did something similar myself. Maybe this info can come in handy for someone else.
    This was on Zabbix 4.0.12, so line numbers can differ in other versions

    MariaDB:
    alter table hostmacro change column value value varchar(25000);

    /usr/share/zabbix/include/schema.inc.php:
    - Line 3339 : 'length' => 255,
    + Line 3339 : 'length' => 25000,

    /usr/share/zabbix/include/views/hostmacros.php:
    - Line 80 : $value_input = (new CTextBox('macros['.$i.'][value]', $macro['value'], false, 255))
    + Line 80 : $value_input = (new CTextBox('macros['.$i.'][value]', $macro['value'], false, 25000))

    Comment


    • soumya
      soumya commented
      Editing a comment
      this will not help as there are other files where one need to update to make this work.

      /usr/share/zabbix/include/schema.inc.php
      /usr/share/zabbix/include/views/hostmacros.php
      /usr/share/zabbix/include/views/administration.general.macros.edit.php
      /usr/share/zabbix/include/views/js/administration.general.macros.edit.js.php
      /usr/share/zabbix/include/views/js/hostmacros.js.php
  • soumya
    Junior Member
    • Nov 2013
    • 21

    #3
    this solution will not work on 5 & above as files are not available & also structure seems changed as well.

    below workaround will work on V5 & above

    /usr/share/zabbix/include/schema.inc.php




    PHP Code:
                             'hostmacro' => [
                                                 
    'key' => 'hostmacroid',
                                                 
    'fields' => [
                                                  ],
                                                 
    'value' => [
                                                 
    'null' => false,
                                                 
    'type' => DB::FIELD_TYPE_CHAR,
    3498 -                                   'length' => 255,
    3498 +                                  'length' => 1024,
                                                 
    'default' => 

    ',

    /usr/share/zabbix/include/classes/html/CTextAreaFlexible.php



    PHP Code:
     const ZBX_STYLE_CLASS 'textarea-flexible';

                                                     
    /**
                                                      * An options array.
                                                      *
                                                      * @var array
                                                      */
                                                      
    protected $options = [
                                                      
    'add_post_js' => true,
    35 -                                            'maxlength' => 255,
    35 +                                           'maxlength' => 1024,
                                                      
    'readonly' => false,
                                                      
    'rows' => 1
                                                      
    ]; 

    Last edited by soumya; 19-10-2021, 10:09.

    Comment

    Working...