{"action":"closed","issue":{"url":"https://api.github.com/repos/voxpupuli/puppetboard/issues/240","repository_url":"https://api.github.com/repos/voxpupuli/puppetboard","labels_url":"https://api.github.com/repos/voxpupuli/puppetboard/issues/240/labels{/name}","comments_url":"https://api.github.com/repos/voxpupuli/puppetboard/issues/240/comments","events_url":"https://api.github.com/repos/voxpupuli/puppetboard/issues/240/events","html_url":"https://github.com/voxpupuli/puppetboard/issues/240","id":154555125,"number":240,"title":"Divide by zero in aggregate metrics['avg_resources_node'] calculation","user":{"login":"ryno75","id":4763328,"avatar_url":"https://avatars.githubusercontent.com/u/4763328?v=3","gravatar_id":"","url":"https://api.github.com/users/ryno75","html_url":"https://github.com/ryno75","followers_url":"https://api.github.com/users/ryno75/followers","following_url":"https://api.github.com/users/ryno75/following{/other_user}","gists_url":"https://api.github.com/users/ryno75/gists{/gist_id}","starred_url":"https://api.github.com/users/ryno75/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryno75/subscriptions","organizations_url":"https://api.github.com/users/ryno75/orgs","repos_url":"https://api.github.com/users/ryno75/repos","events_url":"https://api.github.com/users/ryno75/events{/privacy}","received_events_url":"https://api.github.com/users/ryno75/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-05-12T18:52:57Z","updated_at":"2016-05-12T18:54:23Z","closed_at":"2016-05-12T18:54:23Z","body":"Found a corner case where if an environment has zero nodes in it app.py will try to divide by zero and 500 with this:\r\n\r\n```\r\n[Thu May 12 18:07:08 2016] [error] ERROR:puppetboard.app:Exception on /dev/ [GET]\r\n[Thu May 12 18:07:08 2016] [error] Traceback (most recent call last):\r\n[Thu May 12 18:07:08 2016] [error]   File \"/srv/puppetboard/virtenv-puppetboard/lib/python2.7/site-packages/flask/app.py\", line 1817, in wsgi_app\r\n[Thu May 12 18:07:08 2016] [error]     response = self.full_dispatch_request()\r\n[Thu May 12 18:07:08 2016] [error]   File \"/srv/puppetboard/virtenv-puppetboard/lib/python2.7/site-packages/flask/app.py\", line 1477, in full_dispatch_request\r\n[Thu May 12 18:07:08 2016] [error]     rv = self.handle_user_exception(e)\r\n[Thu May 12 18:07:08 2016] [error]   File \"/srv/puppetboard/virtenv-puppetboard/lib/python2.7/site-packages/flask/app.py\", line 1381, in handle_user_exception\r\n[Thu May 12 18:07:08 2016] [error]     reraise(exc_type, exc_value, tb)\r\n[Thu May 12 18:07:08 2016] [error]   File \"/srv/puppetboard/virtenv-puppetboard/lib/python2.7/site-packages/flask/app.py\", line 1475, in full_dispatch_request\r\n[Thu May 12 18:07:08 2016] [error]     rv = self.dispatch_request()\r\n[Thu May 12 18:07:08 2016] [error]   File \"/srv/puppetboard/virtenv-puppetboard/lib/python2.7/site-packages/flask/app.py\", line 1461, in dispatch_request\r\n[Thu May 12 18:07:08 2016] [error]     return self.view_functions[rule.endpoint](**req.view_args)\r\n[Thu May 12 18:07:08 2016] [error]   File \"/srv/puppetboard/puppetboard/puppetboard/app.py\", line 178, in index\r\n[Thu May 12 18:07:08 2016] [error]     (num_resources[0]['count'] / num_nodes[0]['count']))\r\n[Thu May 12 18:07:08 2016] [error] ZeroDivisionError: integer division or modulo by zero\r\n```\r\n\r\nJust adding a check for a zero denominator and setting the metrics[avg_resources_node'] to zero will skirt the issue.  Pull request coming..."}}