howardjones / network-weathermap

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

Undefined index: 'direction' #154

Closed pautiina closed 5 years ago

pautiina commented 5 years ago

https://github.com/howardjones/network-weathermap/blob/d081cc176e291c73dcfecd8f8c064d0d30fbacb2/lib/Weathermap/Core/Map.php#L1270

2018/09/14 10:32:09 - CMDPHP PHP ERROR NOTICE Backtrace: (/poller.php[676]:api_plugin_hook(), /lib/plugins.php[74]:api_plugin_run_plugin_hook(), /lib/plugins.php[177]: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[85]:Weathermap\Poller\MapRuntime->run(), /plugins/weathermap/lib/Weathermap/Poller/MapRuntime.php[178]:Weathermap\Poller\MapRuntime->writeHTMLFile(), /plugins/weathermap/lib/Weathermap/Poller/MapRuntime.php[261]:Weathermap\Core\Map->makeHTML(), /plugins/weathermap/lib/Weathermap/Core/Map.php[1210]:Weathermap\Core\Map->calculateImagemap(), /plugins/weathermap/lib/Weathermap/Core/Map.php[1270]:CactiErrorHandler())
--
2018/09/14 10:32:09 - ERROR PHP NOTICE in Plugin 'weathermap': Undefined index: direction in file: /var/www/cacti/plugins/weathermap/lib/Weathermap/Core/Map.php on line: 1270
netniV commented 5 years ago

Yes, it would seem that this commit https://github.com/howardjones/network-weathermap/commit/8a466469a87278b5a6dec77ddd7bfea8977257ac introduced the $info as an array but never defines any elements. As such, there is no key 'direction'. Changing the array() to array('direction'=>'') would resolve your issue temporarily, but I presume Howie just forgot to prime the direction when creating the object.

netniV commented 5 years ago

I presume he needs to add direction as a parameter when creating the HTMLimagemapArea object or to the addArea function of HTMLimagemap object.

pautiina commented 5 years ago

I also think that he simply forgot. Created a issue to see it.

howardjones commented 5 years ago

Hmm, it worked in my tests... I will investigate shortly. It should only be looking for 'direction' on things where it has been set (the link drawing code sets it).

howardjones commented 5 years ago

Is there anything unusual about your map, @pautiina? (like one-way links etc)

pautiina commented 5 years ago

No, I have all the usual parameters. Until the last commit everything worked well.

Approximately everything looks like this:

# Automatically generated by php-weathermap v1.0.0dev

TITLE ISTEC NETWORK
WIDTH 1900
HEIGHT 1800
HTMLSTYLE overlib
KEYFONT 3

KEYTEXTCOLOR 0 0 0
KEYOUTLINECOLOR 0 0 0
KEYBGCOLOR 255 255 255
BGCOLOR 255 255 255
TITLECOLOR 0 0 0
TIMECOLOR 0 0 0

# All settings for scale DEFAULT
        SCALE DEFAULT 0    0      32 32 32
        SCALE DEFAULT 0    10     255 255 255  0 0 255
        SCALE DEFAULT 10   40     0 0 255  0 255 0
        SCALE DEFAULT 40   55     0 255 0  255 255 0
        SCALE DEFAULT 55   100    240 240 0  255 0 0
        SCALE DEFAULT 100  110    255 0 0  139 0 0

# All settings for legend DEFAULT
        KEYPOS DEFAULT 0 0 Traffic
        KEYSTYLE DEFAULT horizontal 400

# All settings for scale cactiupdown
        SCALE cactiupdown 0    0.5    192 192 192
        SCALE cactiupdown 0.5  1.5    255 0 0
        SCALE cactiupdown 1.5  2.5    0 0 255
        SCALE cactiupdown 2.5  3.5    0 255 0

# All settings for scale IFSTATUS
        SCALE IFSTATUS 0    1.5    0 255 0   Up
        SCALE IFSTATUS 1.5  2.5    255 0 0   Down

SET key_hidezero_DEFAULT 1

# End of global section

# TEMPLATE-only NODEs:
NODE DEFAULT
        LABELFONT 2
        USESCALE cactiupdown in percent
        MAXVALUE 100

# regular NODEs:
NODE IST_2
        LABEL IST_2
        OVERLIBGRAPH /cacti/graph_image.php?rra_id=0&graph_nolegend=true&graph_height=100&graph_width=300&local_graph_id=257
        ICON images/Host.png
        TARGET cactihost:4
        POSITION 200 350

NODE SWITCH
        LABEL SWITCH
        ICON images/PAD.png
        TARGET cactihost:527
        POSITION 850 270

NODE GATE
        LABEL GATE
        OVERLIBGRAPH /cacti/graph_image.php?rra_id=0&graph_nolegend=true&graph_height=50&graph_width=150&local_graph_id=3728 /cacti/graph_image.php?rra_id=0&graph_nolegend=true&graph_height=50&graph_width=150&local_graph_id=3729 /cacti/graph_image.php?rra_id=0&graph_nolegend=true&graph_height=50&graph_width=150&local_graph_id=3730 /cacti/graph_image.php?rra_id=0&graph_nolegend=true&graph_height=50&graph_width=150&local_graph_id=3731 /cacti/graph_image.php?rra_id=0&graph_nolegend=true&graph_height=50&graph_width=150&local_graph_id=3732 /cacti/graph_image.php?rra_id=0&graph_nolegend=true&graph_height=50&graph_width=150&local_graph_id=3733 /cacti/graph_image.php?rra_id=0&graph_nolegend=true&graph_height=50&graph_width=150&local_graph_id=3734 /cacti/graph_image.php?rra_id=0&graph_nolegend=true&graph_height=50&graph_width=150&local_graph_id=3735 /cacti/graph_image.php?rra_id=0&graph_nolegend=true&graph_height=50&graph_width=150&local_graph_id=3736 /cacti/graph_image.php?rra_id=0&graph_nolegend=true&graph_height=50&graph_width=150&local_graph_id=3737 /cacti/graph_image.php?rra_id=0&graph_nolegend=true&graph_height=50&graph_width=150&local_graph_id=3738 /cacti/graph_image.php?rra_id=0&graph_nolegend=true&graph_height=50&graph_width=150&local_graph_id=3739
        ICON images/Router.png
        TARGET cactihost:751
        POSITION 650 200

# TEMPLATE-only LINKs:
LINK DEFAULT
        ARROWSTYLE compact
        BWFONT 1
        BWLABELPOS 65 35
        BANDWIDTH 1000M

LINK GATE-CORE-SWITCH
        WIDTH 4
        INFOURL /cacti/graph.php?rra_id=all&local_graph_id=3743
        OVERLIBGRAPH /cacti/graph_image.php?rra_id=0&graph_nolegend=true&graph_height=100&graph_width=300&local_graph_id=3743
        TARGET /var/www/cacti/rra/751/3741.rrd
        NODES GATE CORE-SWITCH
        BANDWIDTH 10000M
howardjones commented 5 years ago

It was simpler than that - I only committed half of the change! Should be working now. There are also now tests to check for the original issue (INNOTES being ignored).

netniV commented 5 years ago

I did wonder, as I've done that so many times!

pautiina commented 5 years ago

The problem is not solved, as before, this error jumps out.

howardjones commented 5 years ago

It doesn't for me... I'll make a fresh install and retest.

On Mon, 17 Sep 2018, 08:51 Alex, notifications@github.com wrote:

The problem is not solved, as before, this error jumps out.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/howardjones/network-weathermap/issues/154#issuecomment-421918422, or mute the thread https://github.com/notifications/unsubscribe-auth/AA3sJRpzI9ssBCSwCFvX20jlhvBo0b9Mks5ub1RwgaJpZM4Wow3O .

pautiina commented 5 years ago

While I did this way: if (isset($area->info['direction']) and $area->info['direction'] == $dir) {

howardjones commented 5 years ago

And do your NOTES/OVERLIBGRAPH all actually work if you do that? The fact that the info entry is missing makes me think that they won't. Anything which has overlib stuff attached should have the direction.

pautiina commented 5 years ago

OVERLIBGRAPH - does not work

pautiina commented 5 years ago

@netniV can you test this bug on you system?

netniV commented 5 years ago

I haven’t setup weather maps yet on my test systems, guess I should do. I’ll try over the weekend.

pautiina commented 5 years ago

Thanks

pautiina commented 5 years ago

Fixed on some latest commit but NOTES/OVERLIBGRAPH not working

howardjones commented 5 years ago

How about now? I've just spent a couple of hours going through the imagemap code...

pautiina commented 5 years ago

image on last commit I have forbiden

pautiina commented 5 years ago

I commented all the lines in the file: output / .htaccess and now it works. OVERLIBGRAPH also working: image

howardjones commented 5 years ago

OK - so the new map display thing shouldn't be fetching files directly from the output/ directory. That needs to be fixed.

howardjones commented 5 years ago

Opened #163 to track that.

pautiina commented 5 years ago

This issue fixed