Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datastores: Division by zero #149

Closed
netzwerkgoettin opened this issue Jan 28, 2020 · 3 comments
Closed

Datastores: Division by zero #149

netzwerkgoettin opened this issue Jan 28, 2020 · 3 comments
Labels
Milestone

Comments

@netzwerkgoettin
Copy link

Hi,

Expected Behavior

I added to the existing first VMware vCenter Server a second VMware ESXi.
Then I expected the "Datastores" to show up.

Current Behavior

Oops, an error occurred!
Division by zero (DatastoreUsage.php:145)
#0 /usr/share/icingaweb2/modules/vspheredb/library/Vspheredb/Web/Widget/DatastoreUsage.php(145): Icinga\Application\ApplicationBootstrap->Icinga\Application\{closure}(2, 'Division by zer...', '/usr/share/icin...', 145, Array)
#1 /usr/share/icingaweb2/modules/vspheredb/library/Vspheredb/Web/Table/Objects/DatastoreTable.php(82): Icinga\Module\Vspheredb\Web\Widget\DatastoreUsage->addFreeDatastoreSpace()
#2 /usr/share/icingaweb2/modules/vspheredb/library/Vspheredb/Web/Table/TableColumn.php(115): Icinga\Module\Vspheredb\Web\Table\Objects\DatastoreTable->Icinga\Module\Vspheredb\Web\Table\Objects\{closure}(Object(stdClass))
#3 /usr/share/icingaweb2/modules/vspheredb/library/Vspheredb/Web/Table/BaseTable.php(201): Icinga\Module\Vspheredb\Web\Table\TableColumn->renderRow(Object(stdClass))
#4 /usr/share/icingaweb2/modules/incubator/vendor/gipfl/icingaweb2/src/Table/QueryBasedTable.php(177): Icinga\Module\Vspheredb\Web\Table\BaseTable->renderRow(Object(stdClass))
#5 /usr/share/icingaweb2/modules/incubator/vendor/gipfl/icingaweb2/src/Table/QueryBasedTable.php(112): gipfl\IcingaWeb2\Table\QueryBasedTable->fetchRows()
#6 /usr/share/icingaweb2/modules/ipl/vendor/ipl/html/src/BaseHtmlElement.php(213): gipfl\IcingaWeb2\Table\QueryBasedTable->renderContent()
#7 /usr/share/icingaweb2/modules/ipl/vendor/ipl/html/src/HtmlDocument.php(211): ipl\Html\BaseHtmlElement->renderUnwrapped()
#8 /usr/share/icingaweb2/modules/ipl/vendor/ipl/html/src/HtmlDocument.php(273): ipl\Html\HtmlDocument->render()
#9 /usr/share/icingaweb2/modules/ipl/vendor/ipl/html/src/BaseHtmlElement.php(175): ipl\Html\HtmlDocument->renderUnwrapped()
#10 /usr/share/icingaweb2/modules/ipl/vendor/ipl/html/src/BaseHtmlElement.php(213): ipl\Html\BaseHtmlElement->renderContent()
#11 /usr/share/icingaweb2/modules/ipl/vendor/ipl/html/src/HtmlDocument.php(211): ipl\Html\BaseHtmlElement->renderUnwrapped()
#12 /usr/share/icingaweb2/modules/ipl/vendor/ipl/html/src/HtmlDocument.php(285): ipl\Html\HtmlDocument->render()
#13 /usr/share/icingaweb2/modules/incubator/vendor/gipfl/icingaweb2/src/Zf1/SimpleViewRenderer.php(65): ipl\Html\HtmlDocument->__toString()
#14 /usr/share/icingaweb2/modules/incubator/vendor/gipfl/icingaweb2/src/Zf1/SimpleViewRenderer.php(104): gipfl\IcingaWeb2\Zf1\SimpleViewRenderer->render()
#15 /usr/share/icingaweb2/library/vendor/Zend/Controller/Action/HelperBroker.php(272): gipfl\IcingaWeb2\Zf1\SimpleViewRenderer->postDispatch()
#16 /usr/share/icingaweb2/library/vendor/Zend/Controller/Action.php(518): Zend_Controller_Action_HelperBroker->notifyPostDispatch()
#17 /usr/share/php/Icinga/Web/Controller/Dispatcher.php(76): Zend_Controller_Action->dispatch('indexAction')
#18 /usr/share/icingaweb2/library/vendor/Zend/Controller/Front.php(937): Icinga\Web\Controller\Dispatcher->dispatch(Object(Icinga\Web\Request), Object(Icinga\Web\Response))
#19 /usr/share/php/Icinga/Application/Web.php(300): Zend_Controller_Front->dispatch(Object(Icinga\Web\Request), Object(Icinga\Web\Response))
#20 /usr/share/php/Icinga/Application/webrouter.php(99): Icinga\Application\Web->dispatch()
#21 /usr/share/icingaweb2/public/index.php(4): require_once('/usr/share/php/...')
#22 {main}

Even in debug mode, there's no further information, no error messages, it simply does not work.

Possible Solution

In fact, one of the datastores sends a 0 as value. @ttb1913 already mentioned a possible solution in #75: I can confirm $this->capacity is interpreted as a string. Putting it in quotes at least makes it work.

126     public function addFreeDatastoreSpace()                                                                                                                                      
127     {                                                                                                                                                                            
128         print_r($this->capacity);                                                                                                                                                
129         echo ("\n");                                                                                                                                                             
130                                                                                                                                                                                  
131         if ($this->capacity === "0" || $this->capacity === null) {                                                                                                               
132             return $this;                                                                                                                                                        
133         }

Was unsure how to deal with that. It's a known bug, but it's included in release, that's why I made an issue again.

Cheers,
Marianne

Your Environment

  • VMware vCenter®/ESXi™-Version: 6.5.0 build-6765664/ VMware ESXi 6.5.0 build-9298722/ VMware ESXi 6.7.0 build-14320388
  • Version/GIT-Hash of this module: release-1.1.0
  • Icinga Web 2 version: 2.7.3
  • Operating System and version: Ubuntu 18.04 LTS
  • Webserver, PHP versions: apache2, php-7.2
@Thomas-Gelf
Copy link
Contributor

I missed the hint with mentioning the string/int mismatch in the other issue, thanks for pointing this out! Could you please give this patch a try:

--- a/library/Vspheredb/Web/Widget/DatastoreUsage.php
+++ b/library/Vspheredb/Web/Widget/DatastoreUsage.php
@@ -45,8 +45,8 @@ class DatastoreUsage extends BaseHtmlElement
     {
         $this->datastore   = $datastore;
         $this->uuid        = $datastore->get('uuid');
-        $this->capacity    = $datastore->get('capacity');
-        $this->uncommitted = $datastore->get('uncommitted');
+        $this->capacity    = (int) $datastore->get('capacity');
+        $this->uncommitted = (int) $datastore->get('uncommitted');
         $this->db = $datastore->getDb();
     }
 

@netzwerkgoettin
Copy link
Author

Hi Tom,

sorry for the late answer, I wasn't available for a few days.
I just patched and it seems to solve the issue, so I'll close this issue.
Thanks for taking care of this so quickly!

Cheers,
Marianne

Thomas-Gelf added a commit that referenced this issue Feb 3, 2020
@Thomas-Gelf Thomas-Gelf added this to the v1.2.0 milestone Feb 3, 2020
@Thomas-Gelf
Copy link
Contributor

Fixed in current master, thanks for testing the patch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants