Ad Widget

Collapse

Host inventory as it should be (cpuz integration)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Toinho
    Junior Member
    • Jan 2016
    • 2

    #61
    Hello again, just an atualization.
    Now I am implementing Zabbix and your complete inventory script in my real net. I had a problem testing on my computer, a Windows 10. It worked perfect, but could not get the software and the hardware. I tested in a Windows 8 and, after getting some erros trying to run from the command prompt, i deleted some "ifs" from the zabbix_inv_inventory.vbs in the Agent, then I got the software and hardware info. I tested on a lot of Windows 7 computers and it did worked too. But my Windows 10 can't get anything. He don't even give me errors when I try to run it from the command prompt.
    Does anybody have an idea of what could be wrong?
    Thanks a lot!

    Comment

    • drucej31
      Junior Member
      • Aug 2014
      • 15

      #62
      Fix on 3.0.1

      Nice one that worked a treat...

      Comment

      • yanda.a
        Junior Member
        • Jan 2016
        • 11

        #63
        Originally posted by Jason
        Just managed to get this working on our 2.4.7 install.

        The only php I needed to edit was the include/classes/html/CTag.php file and on the addItem function around line 110 then comment out the $this->encode line


        The table format isn't as pretty as it could be, but at least it's all readable. Oh, and we're using original blue theme.
        This not exactly correct solution, because this may generate incorrect markdown in other pages.

        IMHO, need disable tag encode only in inventory tab. For this need edit some files.

        In file include/classes/html/CTag.php
        Add constant:
        Code:
                /**
                 * Don't encode value
                 */
                const ENC_NOENC = 0;
        Function encode(), add passthrough if strategy is ENC_NOENC.
        Code:
                        protected function encode($value, $strategy = self::ENC_NOAMP) {
                        if ( $strategy == self::ENC_NOENC )
                        {
                            return $value;
                        }
        		elseif ($strategy == self::ENC_NOAMP) {
        			$value = str_replace(array('<', '>', '"'), array('&lt;', '&gt;', '&quot;'), $value);
        		}
        		else {
        			$value = CHtml::encode($value);
        		}
        
        		return $value;
        	}
        File include/classes/html/CSpan.php because encoding in inventory tab called from CSpan object. Need add additional parameter in __construnct function.
        Before:
        Code:
        public function __construct($items = null, $class = null, $id = null
        After:
        Code:
        public function __construct($items = null, $class = null, $id = null, $strategy = self::ENC_NOAMP)
        And must add call setEncStrategy() method before addItem():
        Code:
        ...
                        $this->setEncStrategy($strategy);
        		$this->addItem($items);
        ...
        And finally must edit include/views/inventory.host.view.php. Search line #273 and add two parameters to CSpan constructor (use CTag::ENC_NOENC):
        Before:
        Code:
        array(new CDiv(new CSpan(zbx_str2links($value), 'inventory-text-field'), 'inventory-text-field-wrap'))
        After:
        Code:
        array(new CDiv(new CSpan(zbx_str2links($value), 'inventory-text-field', null, CTag::ENC_NOENC), 'inventory-text-field-wrap'))

        After this steps we have correct markup on all pages and disabled tag encoding in inventory tab.

        For disable tag encoding in overview tab (I do not know why it may be necessary), need change ./hostinventoriesoverview.php in line #141 (add two arguments to object constructor):
        Before:
        Code:
        new CSpan(zbx_str2links($rep['inventory_field']), 'pre'),
        After:
        Code:
        new CSpan(zbx_str2links($rep['inventory_field']), 'pre', null, CTag::ENC_NOENC),
        PS: sorry for my english.
        Last edited by yanda.a; 17-05-2016, 10:43.

        Comment

        • Jason
          Senior Member
          • Nov 2007
          • 430

          #64
          Yes, that seems a better way of doing it. I just got it working quickly for here and haven't delved too deeply into the code yet.

          Comment

          • yanda.a
            Junior Member
            • Jan 2016
            • 11

            #65
            Patch with similar changes for zabbix gui version 3.0.5
            Code:
            patch -d /usr/share/zabbix -p1 < zbx30_inventory.patch
            Attached Files

            Comment

            Working...