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

Bad disk space calc due to type conversion in Linux by SNMP

XMLWordPrintable

    • 1

      For Preprocessing on Item Prototypes Space: Available, Total,  Used and Used in % if the value returned from JSON is large enough, Javascript doesn't handle the type conversion properly and the returned value ends up being in ZB instead of TB.  Parsing the values as Int and Float seems to resolve the issue:
       
       

      var portionHigh = 4294967296; 
      
      var obj = JSON.parse(value); 
      
      var dskTotalHigh = parseInt(obj['dskTotalHigh'], 10), 
          dskTotalLow = parseFloat(obj['dskTotalLow']);   
      
      return (dskTotalHigh * portionHigh + dskTotalLow) * 1024;

       
       
      I suspect it would be good to do explicit type conversions on all of the objects returned from JSON anywhere we do math.
       
      Example JSON for "value" above:
       

      {#SNMPINDEX}":"30","dskEntry":"30","dskPercentNode":"0","dskTotalLow":"1763059968","dskTotalHigh":"3","dskAvailLow":"360840500","dskAvailHigh":"1","dskUsedLow":"1402219468","dskUsedHigh":"2"}

       
      Space: Total without parsing: 1.3194139533492538e+23 (incorrect)
      Space: Total with parsing: 14999512940544  (correct)
       

            drasikhov Denis Rasikhov
            dcskinner Dennis Skinner
            Team INT
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: