Tuesday, July 15, 2014

Using PHP Weathermap with Observium

The PHP Weathermap plugin is a very popular tool for mapping the link load of a network environment. It is usually used as a plugin to Cacti or MRTG but as Observium is gaining popularity I decided to make a quick guide for how you get the weathermap nicely integrated with Observium in a way that does not break when updating to newer versions of Observium.

This guide assumes that you have a working installation of Observium already, preferably a installation that was done using the Debian/Ubuntu-guide.

1. Download the modified version of PHP Weathermap from github github: https://github.com/ZerxXxes/weathermap-for-observium and put it in your observium/html-directory.
The easiest way to do this is using git:
cd /opt/observium/html/
git clone https://github.com/ZerxXxes/weathermap-for-observium.git weathermap
2. If you have used different paths for observium or the weathermap-plugin you will need to edit the variables in data-pick.php and map-poller.php, if you are following the installation guide then the default variables will work.

3. open the file editor.php and change the value in the beginning to:
 $ENABLED=true
As long as this value is true everyone who knows the right URL will be able to access the weathermap editor, its therefore recommended to change this value back to false as soon as you are done editing.

4. Make sure the directory configs/ is writable by your webserver, one way is to change to owner of the directory to the webserver-user: (in Ubuntu the webserver user is usually called www-data)
cd weathermap/
chown www-data:www-data configs/
5. Create a new directory called maps/ and make the webserver-user the owner
mkdir maps/
chown www-data:www-data maps/
6. Now use your webbrowser and access the editor in weathermap/editor.php (i.e. surf to observium.myurl.com/weathermap/editor.php)

7. Create a new map by writing a name and click create map. Note that the map name *must* end with .conf (i.e. networkmap.conf)
Edit your map, create nodes and draw links and then pick graphs from Observium to use with the links.
*NOTE* Under Map Properties, make sure to define Output HTML Filename to maps/<mapname>.html and Output Image Filename to <mapname>.png




8. Make the file map-poller.php executable for your system by doing:
chmod +x map-poller.php
9. Add a new line in the cronjob at /etc/cron.d/observium after the Observium polling and discovery:
*/5 * * * * root /opt/observium/html/weathermap/map-poller.php >> /dev/null 2>&1
10. Move the file navbar-custom.inc.php in the observium/html/includes/-directory. This file does not exist by default in Observium but Observium looks for this file and include the code from it if it exists, this makes it possible to add custom menus that does not break when you upgrade you Observium installation.
mv navbar-custom.inc.php /opt/observium/html/includes/navbar-custom.inc.php
*NOTE*
 If you are using the current community edition (based on revision 5229) or any revision older than 5670 you should instead use the file navbar-custom-old.inc.php and rename it.


Now that's it!
All .html-files in the maps/-directory will be linked in a sub menu in the Observium GUI like this:


Clicking on one of them will take you to the rendered weathermap where you will get a nice overview of your networks load.
Hovering the mouse over a link will show the Observium graph for that link like this:


And clicking on a link will take you to the Observium-page for that link.

Hope this guide has been helpful for you and thank you for reading!

73 comments:

  1. Thanks for this, great addition to Observium!

    ReplyDelete
    Replies
    1. Thanks mate, worked as described in your blog!

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Thanks for the tutorial, I really like this! How did you add the Traffic Load legend? Also, are you actively working on this?

    ReplyDelete
    Replies
    1. I'm not working on the PHP Weathermap or editor itself, its a whole different project which I have no part in found here: http://www.network-weathermap.com/
      I only did some coding for having the gui in observium work with the weathermap.

      Delete
  4. Disregard my "Traffic Load legend" question, turns out it was simple enough :P

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. map-poller.php is not generating any html file. When I run it from CLI; go the following output:

    PHP Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /usr/share/php/Console/Getopt.php on line 109
    PHP Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /usr/share/php/Console/Getopt.php on line 154
    PHP Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /usr/share/php/Console/Getopt.php on line 154
    PHP Strict Standards: Non-static method PEAR::isError() should not be called statically in /opt/observium/html/weathermap/weathermap on line 60
    WARNING: configs//networkmap.conf: OVERLIBGRAPH is used, but HTMLSTYLE is static. This is probably wrong. [WMWARN41]

    Any clue?

    ReplyDelete
    Replies
    1. Hi,

      Did you ever figure out what the issue is by any chance. I am getting almost the exact error when I run it from cli and it doesn't generate any maps.

      Thank you in advance.

      Delete
    2. you need to add a @ in the php files before the PEAR - meaning @PEAR::isError instead of PEAR::isError

      Delete
  7. Getting "This editor is not finished!" and won't create a new map, any ideas where to start here? Cheers

    ReplyDelete
  8. Everything's working for me except I don't get graphs when I hover over links. What might I be missing from the configuration, please? I can _click_ on a link and it takes me to that link's graph, but there's nothing on mouseover...

    ReplyDelete
    Replies
    1. OK, I figured this one out. I needed to manually edit each of the .conf files to include the line "HTMLSTYLE overlib" somewhere near the top.

      Delete
  9. Hey, I re-installed with git and grabbed the latest files and now my map-poller.php doesn't generate any maps! Also, when I run it I don't get any sort of output what so ever. Even when running with the "-d" option. Anybody seen this before? Any help would be greatly appreciated. Thanks

    ReplyDelete
  10. FYI I'm at the new CE Rev 6000 for Observium. I tried reverting to older code for weathermap but no dice. The map-poller.php just doesn't do anything :(. Heads up if anyone is upgrading to rev 6000.

    ReplyDelete
  11. Was anyone able to figure out the issue with graphs not being created? I am not getting any errors, see below.

    [root@observe weathermap]# /opt/observium/html/weathermap/map-poller.php -d
    DEBUG!
    Conf dir: configs/
    Opened directory configs/
    File to be run is lab.conf
    Running php ./weathermap --config configs//lab.conf --base-href /weathermap/

    ReplyDelete
  12. Dear All,

    I configured weathermap using the link

    http://blog.best-practice.se/2014/07/using-php-weathermap-with-observium.html?m=1

    But when I get to the observium GUI, I get the weathermap link under the
    Overview but I don't get to see any graphs.

    ReplyDelete
    Replies
    1. Hello,
      did you create new maps from scratch or did you copy existing ones?
      If you copied them from cacti make sure to modify them according to step 7.

      Delete
    2. I'm having the same issue, and I created a new map.

      Delete
  13. In latest observium community edition (11.6000) html creation is not working..
    You have to comment out:

    include("../../includes/functions.php"); in map-poller.php

    replace PEAR::isError with @PEAR::isError in /usr/share/php/Console/Getopt.php

    then the html files is generated..

    Turn on debugging :
    $weathermap_debugging=TRUE;
    in /opt/observium/html/weathermap/weathermap
    and run
    php ./weathermap --config configs/networkmap.conf --base-href /weathermap/

    //Magnus

    ReplyDelete
    Replies
    1. I'm still getting errors with this. I have Weathermap in the Observium dropdown, however there are no maps to click on. When I run the last command you mention I get the following errors:

      root@server:/opt/observium/html/weathermap# php ./weathermap --config configs/networkmap.conf --base-href /weathermap/

      PHP Warning: fopen(configs/networkmap.conf): failed to open stream: No such file or directory in /opt/observium/html/weathermap/lib/Weathermap.class.php on line 1789

      PHP Warning: file_get_contents(configs/networkmap.conf): failed to open stream: No such file or directory in /opt/observium/html/weathermap/lib/Weathermap.class.php on line 3080

      Delete
  14. Hi Best Practice

    I know nothing about PHP development management so i was wondering if you tell me how to display my maps in observium home page where the google maps appear with out going to a new page.

    its bit tedious having to go back the whole time to view a new map?

    i hope the above makes sense.

    ReplyDelete
  15. navbar-custom-old.inc.php

    Someone can share the link of this file?

    ReplyDelete
    Replies
    1. http://best-practice.se/dump/navbar-custom-old.inc.php.txt

      Delete
    2. Thanks best-practice for that file. I have created the file navbar-custom.php in the directory /opt/observium/html/includes/ and the sub-menu Weathermap appears now on observium web page

      Delete
  16. This comment has been removed by the author.

    ReplyDelete
  17. I was attempting to follow along when I noticed that the repository was no longer being hosted by Neil. I searched through his similar repositories and it only applies to his new project.

    Does anyone have the original repository cloned/forked so that I can grab a copy of it?

    ReplyDelete
    Replies
    1. Found this dump that someone did and don't see any issues: (Does this have changes listed above?)
      https://github.com/nicolasvion/weathermap-for-observium/

      Delete
    2. This version is working (and safe) as of commit "49bd19a".

      I am however having the issue with graphs not appearing on hovering over links. I've set "HTMLSTYLE overlib" in the config but it doesn't seem to be resolving the issue. Any thoughts?

      Delete
    3. This comment has been removed by the author.

      Delete
    4. I needed to move overlib.js down a directory into /opt/observium/html/

      After, I needed to fix the map-poller.php line about rrdcached as Magnus had above.

      Delete
  18. This comment has been removed by a blog administrator.

    ReplyDelete
  19. Hello,

    Very good article. Thanks a lot.

    I was able to fully integrate weathermap with observium into a raspberry pi3
    But i am wondering if it is possible to integrate the network weathermap plugin in observium in a way that is showed in the frontpage instead of the geomap

    Thank you !

    ReplyDelete
  20. Hello,

    Very good article. Thanks a lot.

    I was able to fully integrate weathermap with observium into a raspberry pi3
    But i am wondering if it is possible to integrate the network weathermap plugin in observium in a way that is showed in the frontpage instead of the geomap

    Thank you !

    ReplyDelete
    Replies
    1. Hi, I'd like to have the Weathermap on the frontpage instead too. I think this should be possible as you can configure the frontpage elements etc, but not sure if it works with a plugin.

      Delete
  21. not working on Observium CE 0.16.1.7533

    ReplyDelete
  22. Still working on 0.16.5.7863 (rolling). I installed it way back when I had the CE from the beginning of 2015.

    ReplyDelete
    Replies
    1. maybe it works if you upgraded from earlier versions, but try to edit maps. On CE i'm trying a fresh install.

      Delete
  23. Is your project still available on GitHub? I'm getting an error when trying to pull it into the HTML directory.

    ReplyDelete
  24. /opt/observium/html/weathermap# ./map-poller.php
    PHP Fatal error: require_once(): Failed opening required '/includes/db.inc.php' (include_path='.:/usr/share/php') in /opt/observium/includes/definitions.inc.php on line 438

    ReplyDelete
  25. I found a few alternatives to the non-working GIT respository in the doc: https://github.com/search?utf8=%E2%9C%93&q=observium+weathermap&type=Repositories&ref=searchresults
    please let the community know your successes & failures...

    ReplyDelete
  26. /opt/observium/html/weathermap# ./map-poller.php
    PHP Fatal error: require_once(): Failed opening required '/includes/db.inc.php' (include_path='.:/usr/share/php') in /opt/observium/includes/definitions.inc.php

    ReplyDelete
  27. can you help with this issue please ?

    ReplyDelete
  28. Did someone know how to put the Maximum Bandwidth legend on the map?

    ReplyDelete
  29. I have the weathermap installed and see it listed under the dropdown menu but when i create a new map with the editor and save it to maps/network.html there is nothing in the maps directory or nothing to view under weathermaps. If i manually create a .html file in the maps directory i see it listed when i select weather maps menu. Any ideas?

    ReplyDelete
  30. Hi!
    Late in the Game, but i wonder if you got some tip why nothing responds (error 500) when klicking the link object (the one that let you choose interface data-pck thingy) I got the Observium in the default setup but maybe i need to change a path somewhere or a userright on some folder!

    ReplyDelete
    Replies
    1. Hi, its because php weathermap does not support PHP7 so if you run that you need to edit a file. There is a diff found here: http://pastebin.com/tT0KzMdt on what you need to edit. However its reversed so you need to add everything that begins with -.
      Basically you need to replace all mysql_ functions with mysqli_

      Delete
  31. Dude, this is great which you have developed. But i am not able to find the repository in github...could you please help me here.

    ReplyDelete
    Replies
    1. This worked for me, GIT repository changed since document was posted:

      git clone https://github.com/tobzsc/weathermap-for-observium.git weathermap

      Delete
  32. I could see the weathermaps and weather editor on the page, after I created the test.conf, it doesn't create the output files even I tried output file name "test.jpg" and output HTML filename "maps/test.html" with www-data write permission on "maps" folder. Any ideas?

    ReplyDelete
  33. hi, i installed everything correctly (i think), but i get an error while using map-poller.php

    PHP Fatal error: require_once(): Failed opening required '/includes/db.inc.php' (include_path='.:/usr/share/php') in /opt/observium/includes/definitions.inc.php on line 475

    is there someting i need to change?

    ReplyDelete
  34. After installing weathermap, i then tried to create a node and pick from observium. However, nothing is listed which obviously there should be something in the list but it says No results. Is it something that is missing from my config? Any help is highly appreciated.
    Thank you.

    ReplyDelete
  35. not working in turnkey linux ver 8128 the editor can be opened but weathermap bar not showing the maps and config

    ReplyDelete
  36. Since updating to r9294 my maps are no longer updating....

    ReplyDelete
  37. How to upgrade observium weathermap from 9.7 to 9.8?

    ReplyDelete
  38. However, they also understand the fact that a function can be manipulated quickly by passing references instead of values. They can further avoid adding extra overheads by passing references to the function instead of values.plakatΕ³ spausdinimas

    ReplyDelete
  39. Sports big news provide is a all type sports contents. In This portal is a sports all type content, For ex. Cricket, cwc19, UEFA, football, Copa America 2019 etc.

    Cricket
    Cricket World Cup 2019
    Live Streaming
    World Cup 2019 Final
    IPL 2020 Live Streaming
    Copa America 2019 Venues
    Tennis
    Copa America 2019
    Cricket World Cup Live
    Football

    ReplyDelete
  40. This comment has been removed by the author.

    ReplyDelete
  41. Just followed the steps but when create nodes or links option pick from observium is not a clickable link. Is there any way to fix it?

    ReplyDelete
  42. Hello,
    It doesn't open the maps page when i click on it.. it just reload the observium page.
    Any help ?

    ReplyDelete
  43. Is this guide still valid with Observium CE 19.8.10000 ?

    ReplyDelete
  44. Hi, When I add a new node and click on it nothing happens. I should see a list with all our devices and select the correct one. Any idea please

    ReplyDelete
  45. This comment has been removed by the author.

    ReplyDelete
  46. Hiya, friend! πŸ€— Your post is simply fantastic! πŸ‘ Beautifully written and covering all the important bases. πŸ“‹ It's a real masterpiece! 🎨 Bookmarking your site and subscribing to the feeds pronto! πŸ“° Can't wait to devour more content like this! 🍽️ Let's concoct more strategies together. πŸ’­ Thanks a ton for sharing! 🌈 Saudi Arabia Introduces Expo 2030 Visa, facilitating travel for the global event. The visa aims to boost tourism and participation in the expo, fostering international engagement and collaboration.

    ReplyDelete
  47. 🌟 What a thrill to have finally discovered what I've been searching for! You've successfully concluded my four-day quest. Bless you, my friend! Wishing you an amazing day ahead. This blog is outstanding! Your articles are so engaging. Keep up the wonderful work! Countless individuals are searching for this information, and your expertise could greatly benefit them. Turkish Visa for Algerian citizens streamlines travel with an easy online application process. It enhances accessibility and convenience, facilitating smoother entry into Turkey for Algerian travelers.


    ReplyDelete
  48. Your dedication to delivering a superior experience is evident, and you consistently push the boundaries of excellence. Through cutting-edge features, captivating content, and unparalleled customer service, you relentlessly seek to elevate the satisfaction of your audience. Azerbaijan visa uk/a>,
    Before traveling to Azerbaijan, UK citizens must secure an eVisa. Introduced by the Azerbaijani government, the eVisa system aims to simplify visa applications and boost tourism. It offers a smooth and swift application process, enabling travelers to acquire their visas online promptly, avoiding any unnecessary delays.



    ReplyDelete
  49. Your dedication to delivering a superior experience is evident, and you consistently push the boundaries of excellence. Through cutting-edge features, captivating content, and unparalleled customer service, you relentlessly seek to elevate the satisfaction of your audience. Azerbaijan visa uk, Before traveling to Azerbaijan, UK citizens must secure an eVisa. Introduced by the Azerbaijani government, the eVisa system aims to simplify visa applications and boost tourism. It offers a smooth and swift application process, enabling travelers to acquire their visas online promptly, avoiding any unnecessary delays.

    ReplyDelete
  50. I must say, this article really struck a chord with me! Your insights are like a breath of fresh air in a sea of generic content. I truly appreciate how you've managed to break down complex concepts, making them easily understandable for someone like me who's new to this topic. Do i need a transit visa for Benin Whether you need a transit Visa for Benin depends on your nationality and the length of your layover. Some travelers may require a transit visa if their layover exceeds a certain duration. It's advisable to check with Benin's immigration authorities for specific requirements.

    ReplyDelete
  51. I'm getting errors with this. I have Weathermap in the Observium dropdown, however there are no maps to click on. When I run the Debug command ( opt/observium/html/weathermap/map-poller.php -d)
    following errors:

    [root@localhost weathermap]# /opt/observium/html/weathermap/map-poller.php -d
    DEBUG!
    PHP Fatal error: require_once(): Failed opening required '/includes/common.inc.php' (include_path='.:/usr/share/pear:/usr/share/php') in /opt/observium/includes/functions.inc.php on line 15

    Fatal error: require_once(): Failed opening required '/includes/common.inc.php' (include_path='.:/usr/share/pear:/usr/share/php') in /opt/observium/includes/functions.inc.php on line 15

    ReplyDelete
  52. I am getting fatel error in path on line 15 - /opt/observium/includes/functions.inc.php
    [root@localhost weathermap]# cat -n /opt/observium/includes/functions.inc.php
    1 <?php
    2 /**
    3 * Observium
    4 *
    5 * This file is part of Observium.
    6 *
    7 * @package observium
    8 * @subpackage functions
    9 * @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2024 Observium Limited
    10 *
    11 */
    12
    13 // Observium Includes
    14
    15 require_once($config['install_dir'] . "/includes/common.inc.php"); // already included in observium.inc.php before definitions
    16 include_once($config['install_dir'] . "/includes/http.inc.php");
    17 include_once($config['install_dir'] . "/includes/encrypt.inc.php");
    18 include_once($config['install_dir'] . "/includes/rrdtool.inc.php");
    19 include_once($config['install_dir'] . "/includes/influx.inc.php");
    20 include_once($config['install_dir'] . "/includes/syslog.inc.php");
    21 include_once($config['install_dir'] . "/includes/rewrites.inc.php");
    22 include_once($config['install_dir'] . "/includes/templates.inc.php");
    23 include_once($config['install_dir'] . "/includes/snmp.inc.php");
    24 include_once($config['install_dir'] . "/includes/entities.inc.php");
    25 include_once($config['install_dir'] . "/includes/geolocation.inc.php");
    26 include_once($config['install_dir'] . "/includes/alerts.inc.php");

    ReplyDelete