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

CheckStatistics#assembleBody(): avoid divisions by 0 #908

Merged
merged 2 commits into from
Oct 13, 2023
Merged

CheckStatistics#assembleBody(): avoid divisions by 0 #908

merged 2 commits into from
Oct 13, 2023

Conversation

Al2Klimov
Copy link
Member

A too small check interval can let the last and next check appear to be at the same time due to rounding to milliseconds. Their difference is 0 which shall not be used for division.

object Host "656" {
    check_command = "dummy"
    vars.dummy_state = 2
    check_interval = 1ms
    retry_interval = 1ms
    max_check_attempts = 1000
}

Before

Division by zero

#0 /usr/share/icingaweb2/modules/icingadb/library/Icingadb/Widget/Detail/CheckStatistics.php(126): Icinga\Application\ApplicationBootstrap->Icinga\Application\{closure}()
#1 /usr/share/icinga-php/ipl/vendor/ipl/web/src/Common/Card.php(24): Icinga\Module\Icingadb\Widget\Detail\CheckStatistics->assembleBody()
#2 /usr/share/icinga-php/ipl/vendor/ipl/web/src/Common/Card.php(55): ipl\Web\Common\Card->createBody()
#3 /usr/share/icingaweb2/modules/icingadb/library/Icingadb/Widget/Detail/CheckStatistics.php(362): ipl\Web\Common\Card->assemble()
#4 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(344): Icinga\Module\Icingadb\Widget\Detail\CheckStatistics->assemble()
#5 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(566): ipl\Html\HtmlDocument->ensureAssembled()
#6 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(390): ipl\Html\HtmlDocument->render()
#7 /usr/share/icinga-php/ipl/vendor/ipl/html/src/BaseHtmlElement.php(297): ipl\Html\HtmlDocument->renderUnwrapped()
#8 /usr/share/icinga-php/ipl/vendor/ipl/html/src/BaseHtmlElement.php(365): ipl\Html\BaseHtmlElement->renderContent()
#9 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(568): ipl\Html\BaseHtmlElement->renderUnwrapped()
#10 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(390): ipl\Html\HtmlDocument->render()
#11 /usr/share/icinga-php/ipl/vendor/ipl/html/src/BaseHtmlElement.php(297): ipl\Html\HtmlDocument->renderUnwrapped()
#12 /usr/share/icinga-php/ipl/vendor/ipl/html/src/BaseHtmlElement.php(365): ipl\Html\BaseHtmlElement->renderContent()
#13 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(568): ipl\Html\BaseHtmlElement->renderUnwrapped()
#14 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(390): ipl\Html\HtmlDocument->render()
#15 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(568): ipl\Html\HtmlDocument->renderUnwrapped()
#16 /usr/share/icinga-php/ipl/vendor/ipl/web/src/Compat/ViewRenderer.php(56): ipl\Html\HtmlDocument->render()
#17 /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Controller/Action/Helper/ViewRenderer.php(970): ipl\Web\Compat\ViewRenderer->render()
#18 /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Controller/Action/HelperBroker.php(277): Zend_Controller_Action_Helper_ViewRenderer->postDispatch()
#19 /usr/share/icingaweb2/modules/icingadb/library/Icingadb/Web/Controller.php(480): Zend_Controller_Action_HelperBroker->notifyPostDispatch()
#20 /usr/share/icingaweb2/library/Icinga/Web/Controller/Dispatcher.php(76): Icinga\Module\Icingadb\Web\Controller->dispatch()
#21 /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Controller/Front.php(954): Icinga\Web\Controller\Dispatcher->dispatch()
#22 /usr/share/icingaweb2/library/Icinga/Application/Web.php(294): Zend_Controller_Front->dispatch()
#23 /usr/share/icingaweb2/library/Icinga/Application/webrouter.php(105): Icinga\Application\Web->dispatch()
#24 /usr/share/icingaweb2/public/index.php(4): require_once(String)
#25 {main}
Division by zero

#0 /usr/share/icingaweb2/modules/icingadb/library/Icingadb/Widget/Detail/CheckStatistics.php(139): Icinga\Application\ApplicationBootstrap->Icinga\Application\{closure}()
#1 /usr/share/icinga-php/ipl/vendor/ipl/web/src/Common/Card.php(24): Icinga\Module\Icingadb\Widget\Detail\CheckStatistics->assembleBody()
#2 /usr/share/icinga-php/ipl/vendor/ipl/web/src/Common/Card.php(55): ipl\Web\Common\Card->createBody()
#3 /usr/share/icingaweb2/modules/icingadb/library/Icingadb/Widget/Detail/CheckStatistics.php(364): ipl\Web\Common\Card->assemble()
#4 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(344): Icinga\Module\Icingadb\Widget\Detail\CheckStatistics->assemble()
#5 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(566): ipl\Html\HtmlDocument->ensureAssembled()
#6 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(390): ipl\Html\HtmlDocument->render()
#7 /usr/share/icinga-php/ipl/vendor/ipl/html/src/BaseHtmlElement.php(297): ipl\Html\HtmlDocument->renderUnwrapped()
#8 /usr/share/icinga-php/ipl/vendor/ipl/html/src/BaseHtmlElement.php(365): ipl\Html\BaseHtmlElement->renderContent()
#9 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(568): ipl\Html\BaseHtmlElement->renderUnwrapped()
#10 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(390): ipl\Html\HtmlDocument->render()
#11 /usr/share/icinga-php/ipl/vendor/ipl/html/src/BaseHtmlElement.php(297): ipl\Html\HtmlDocument->renderUnwrapped()
#12 /usr/share/icinga-php/ipl/vendor/ipl/html/src/BaseHtmlElement.php(365): ipl\Html\BaseHtmlElement->renderContent()
#13 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(568): ipl\Html\BaseHtmlElement->renderUnwrapped()
#14 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(390): ipl\Html\HtmlDocument->render()
#15 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(568): ipl\Html\HtmlDocument->renderUnwrapped()
#16 /usr/share/icinga-php/ipl/vendor/ipl/web/src/Compat/ViewRenderer.php(56): ipl\Html\HtmlDocument->render()
#17 /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Controller/Action/Helper/ViewRenderer.php(970): ipl\Web\Compat\ViewRenderer->render()
#18 /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Controller/Action/HelperBroker.php(277): Zend_Controller_Action_Helper_ViewRenderer->postDispatch()
#19 /usr/share/icingaweb2/modules/icingadb/library/Icingadb/Web/Controller.php(480): Zend_Controller_Action_HelperBroker->notifyPostDispatch()
#20 /usr/share/icingaweb2/library/Icinga/Web/Controller/Dispatcher.php(76): Icinga\Module\Icingadb\Web\Controller->dispatch()
#21 /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Controller/Front.php(954): Icinga\Web\Controller\Dispatcher->dispatch()
#22 /usr/share/icingaweb2/library/Icinga/Application/Web.php(294): Zend_Controller_Front->dispatch()
#23 /usr/share/icingaweb2/library/Icinga/Application/webrouter.php(105): Icinga\Application\Web->dispatch()
#24 /usr/share/icingaweb2/public/index.php(4): require_once(String)
#25 {main}

After

Detail view, as we like it.

@cla-bot cla-bot bot added the cla/signed CLA is signed by all contributors of a PR label Oct 10, 2023
@nilmerg
Copy link
Member

nilmerg commented Oct 10, 2023

Please create an issue.

@Al2Klimov Al2Klimov linked an issue Oct 10, 2023 that may be closed by this pull request
@nilmerg nilmerg added bug Something isn't working area/view Affects an entire view labels Oct 13, 2023
@nilmerg nilmerg added this to the 1.1.1 milestone Oct 13, 2023
A too small check interval can let the last and next check appear to be at
the same time due to rounding to milliseconds. Their difference is 0 which
shall not be used for division.
nilmerg
nilmerg previously approved these changes Oct 13, 2023
@nilmerg nilmerg merged commit c1f1d68 into main Oct 13, 2023
13 checks passed
@nilmerg nilmerg deleted the div-by0 branch October 13, 2023 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/view Affects an entire view bug Something isn't working cla/signed CLA is signed by all contributors of a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Detail view says "Division by zero" on too small check interval
2 participants