howardjones / network-weathermap

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

Weathermap poller generates backtrace as well as warning #127

Closed netniV closed 6 years ago

netniV commented 6 years ago
2018/01/31 08:15:03 - WEATHERMAP WARNING: Output directory (/usr/share/cacti/develop/plugins/weathermap/output) isn't writable (tried to create '/usr/share/cacti/develop/plugins/weathermap/output/weathermap.permissions.test'). No maps created. You probably need to make it writable by the poller process user (www-data) (like you did with the RRA directory) [WMPOLL06]
2018/01/31 08:15:03 - CMDPHP PHP ERROR WARNING Backtrace: (/poller.php: 722 api_plugin_hook)(/lib/plugins.php: 73 api_plugin_run_plugin_hook)(/lib/plugins.php: 170 weathermap_poller_bottom)(/plugins/weathermap/lib/Weathermap/Integrations/Cacti/cacti-plugin-poller.php: 176 Weathermap\Poller\runMaps)(/plugins/weathermap/lib/Weathermap/Poller/poller-common.php: 73 fopen)(CactiErrorHandler)(/lib/functions.php: 4511 cacti_debug_backtrace)
2018/01/31 08:15:03 - ERROR PHP WARNING in Plugin 'weathermap': fopen(/usr/share/cacti/develop/plugins/weathermap/output/weathermap.permissions.test): failed to open stream: Permission denied in file: /usr/share/cacti/develop/plugins/weathermap/lib/Weathermap/Poller/poller-common.php on line: 73
2018/01/31 08:15:03 - WEATHERMAP Weathermap 1.0.0dev starting - Normal logging mode. Turn on DEBUG in Cacti for more information

The above logs are generated, presumably as a result of the poller calling Weathermap's code. However, there is both a Weathermap's warning and a Cacti error being recorded each time because I hadn't created the output directory (or it's not got the right permissions).

I'm not sure why there is a log within Cacti, given that the following code generated it:

        $testfile = $outputDirectory . DIRECTORY_SEPARATOR . "weathermap.permissions.test";
        $testfd = @fopen($testfile, 'w');

Normally the @ suppresses errors so I'm a bit surprised this even happens.

howardjones commented 6 years ago

I could have sworn I fixed this one about a month ago! (in that long thread issue). I thought I replaced it with a try/catch. I definitely remember that Cacti still picks up the error even with the @. There's also a reason why I didn't use is_writable() so that isn't an alternative.

netniV commented 6 years ago

Hmm, what is the is_writable reason? Is that to do with cache because there is a function to flush the cache. Just curious because someone else had an issue that seemed to be with the is_writable function.

howardjones commented 6 years ago

I think it was that it doesn't actually check permissions. It does some tests a bit like checking the permissions, but in some situation way back when, it would say the directory was writable when it wasn't. It must be a long time though, because the first svn version (imported here) already had this check instead. In fact 0.8 (first release with Cacti plugin) already had it.

netniV commented 6 years ago

I've done some testing of other software, it isn't just your plugin. I have suggested a change to the error handler for this in https://github.com/Cacti/cacti/issues/1296

netniV commented 6 years ago

So this no longer generates the backtrace. However, I suspect I got these errors when I clicked on Create Map. Whilst I know you've been working on the Editor, I take it we can't actually create a new map yet?

howardjones commented 6 years ago

The editor should be working - anything left is a legit bug. The management UI is a lot of dummy screens at the moment. Next commit should start adding back functionality. The backtrace was from the 'check to see if output/ is writable', when you have just installed the plugin.

netniV commented 6 years ago

Yeah my output isn't writable, so I'm still getting the warning but i'm not getting anything when I use the "Create Map" option. It gives me the screen, I click create after entering details nowt happens (presume this is a dummy screen you mention)

howardjones commented 6 years ago

Yes - that's the dummy screen. 'Add Map' (existing file) and 'Create Map' (new file) are the first two I will be adding. I realised there was no particular reason to have to go into the editor to create a new map, so you will be able to do that from the management screen as well, including using another map as a template.

netniV commented 6 years ago

Gimme gimme gimme (a map after midnight... )

Is there anything I can do in the meantime to start a map so I can at least try editing one?

netniV commented 6 years ago

More importantly, when will you be adding the Star Trek Console theme? ;-)

howardjones commented 6 years ago

touch configs/empty.conf should do the trick :-)

If there's an open-source Impact-like font, I will try to make the LCARS template!