howardjones / network-weathermap

Network Weathermap draws diagrams from data
http://www.network-weathermap.com/
MIT License
425 stars 94 forks source link

Plugin 'weathermap': Division by zero DB-Refactor Branch under Cact 1.1.10 #110

Closed ikorzha closed 6 years ago

ikorzha commented 7 years ago

Getting the following errors in Cacti Log... Errors in logs occurred when I was re-assigning devices from main poller to a remote poller. Hope that info helps.

2017/06/08 21:49:03 - CMDPHP PHP ERROR WARNING Backtrace: (/poller.php: 533 process_poller_output)(/lib/poller.php: 492 api_plugin_hook_function)(/lib/plugins.php: 105 api_plugin_run_plugin_hook_function)(/lib/plugins.php: 206 weathermap_poller_output)(/plugins/weathermap/lib/cacti-plugin-poller.php: 99 CactiErrorHandler)(/lib/functions.php: 4361 cacti_debug_backtrace) 2017/06/08 21:49:03 - ERROR PHP WARNING in Plugin 'weathermap': Division by zero in file: /var/www/html/plugins/weathermap/lib/cacti-plugin-poller.php on line: 99 2017/06/08 21:49:03 - CMDPHP PHP ERROR WARNING Backtrace: (/poller.php: 533 process_poller_output)(/lib/poller.php: 492 api_plugin_hook_function)(/lib/plugins.php: 105 api_plugin_run_plugin_hook_function)(/lib/plugins.php: 206 weathermap_poller_output)(/plugins/weathermap/lib/cacti-plugin-poller.php: 99 CactiErrorHandler)(/lib/functions.php: 4361 cacti_debug_backtrace) 2017/06/08 21:49:03 - ERROR PHP WARNING in Plugin 'weathermap': Division by zero in file: /var/www/html/plugins/weathermap/lib/cacti-plugin-poller.php on line: 99 2017/06/08 21:49:03 - CMDPHP PHP ERROR WARNING Backtrace: (/poller.php: 533 process_poller_output)(/lib/poller.php: 492 api_plugin_hook_function)(/lib/plugins.php: 105 api_plugin_run_plugin_hook_function)(/lib/plugins.php: 206 weathermap_poller_output)(/plugins/weathermap/lib/cacti-plugin-poller.php: 99 CactiErrorHandler)(/lib/functions.php: 4361 cacti_debug_backtrace) 2017/06/08 21:49:03 - ERROR PHP WARNING in Plugin 'weathermap': Division by zero in file: /var/www/html/plugins/weathermap/lib/cacti-plugin-poller.php on line: 99 2017/06/08 21:49:03 - CMDPHP PHP ERROR WARNING Backtrace: (/poller.php: 533 process_poller_output)(/lib/poller.php: 492 api_plugin_hook_function)(/lib/plugins.php: 105 api_plugin_run_plugin_hook_function)(/lib/plugins.php: 206 weathermap_poller_output)(/plugins/weathermap/lib/cacti-plugin-poller.php: 99 CactiErrorHandler)(/lib/functions.php: 4361 cacti_debug_backtrace) 2017/06/08 21:49:03 - ERROR PHP WARNING in Plugin 'weathermap': Division by zero in file: /var/www/html/plugins/weathermap/lib/cacti-plugin-poller.php on line: 99

errors

howardjones commented 7 years ago

So just to be clear - are you also using poller_output ("boost") mode in your maps?

I haven't actually tried multiple pollers at all...

ikorzha commented 7 years ago

All of my maps use "SET rrd_use_poller_output 1". In fact cacti documentation states that enabling boost is a requirement in multi poller environments in Cacti 1.x. I'm not in production yet with muti poller setup so far I'm just testing concept, functionality and working thru bug that I identify in a testing process. THis installation where errors occurred, doesn't even have any maps, Just a weathermap plugin installed and enabled.

howardjones commented 7 years ago

OK, so if I'm following the flow of my own code properly - you have no maps now, but you did have, and there are still items in weathermap_data that the poller is looking for. delete from weathermap_data should resolve that.

I'll add in some more checking here - it seems that in some situations new data arrives without a timestamp, which will be a problem for weathermap.

ikorzha commented 7 years ago

Yes, you are absolutely right, no maps now but it used to have them... I went and explored the weathermap_data table, and you are absolutely right it does have "some old data" weathermap-data

howardjones commented 7 years ago

I have not yet figured out an efficient way to decide if the data in weathermap_data is still required by any maps. So if you remove a map, the data that it used to use is still collected by the poller_output handler.

The answer is probably some kind of batch job, but I wanted to avoid having to do a SQL update (on a 'last_read' field) every time a value is used. Maybe the performance hit wouldn't be so bad.

But in the meantime, the quick fix is to truncate that table.

I will investigate some more with multi-server cacti, once single-server cacti is back to normal :-)

ikorzha commented 6 years ago

Closing as too old, will test in new version.