PHP Network Weathermap 0.8 (now 0.9)

Support questions about the Network Weather Map plugin

Moderators: Developers, Moderators

Post Reply
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

_JPL_ wrote:I don't see maps at all after the poller runs. I chmod 777 the output folder to make sure there were sufficient perms (will undo once I get it working). I have the conf file in the configs folder.

In the poller at the very end I see the error:
PHP Fatal error: Cannot redeclare class html_imagemap_area_polygon in /usr/share/pear/HTML_ImageMap.class.php on line 140

Which version of PHP, and which platform is this? I haven't seen this one before...

[please don't crosspost the same query...]
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
tadavis
Posts: 16
Joined: Thu Apr 06, 2006 1:38 pm

Using this with no authentication..

Post by tadavis »

The webserver where I run cacti on already has a user account/password setup in front of it, so having to login in twice to get to Cacti was being a PITA.

Turning off authentication in Cacti (see cacti/settings.php?tab=authentication, or the Authentication Tab in Configuration/Settings) means the weathermap would emit some weird messages and not work.

I found two files so far that needed to be fixed to make it work with no Cacti authentication

weathermap-cacti-plugin.php

Code: Select all

weathermap # diff -u weathermap-cacti-plugin.php /var/srv/www/cacti/plugins/weathermap/weathermap-cacti-plugin.php
--- weathermap-cacti-plugin.php 2006-06-27 14:51:47.273243112 -0700
+++ /var/srv/www/cacti/plugins/weathermap/weathermap-cacti-plugin.php   2006-06-27 12:29:04.178031456 -0700
@@ -74,7 +74,12 @@
   $confdir = dirname(__FILE__).'/configs/';

   # $map = db_fetch_assoc("select * from weathermap_maps where id=".$mapid);
-  $map = db_fetch_assoc("select weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and (userid=".$_SESSION["sess_user_id"]." or userid=0) and weathermap_maps.id=".$mapid);
+
+  if (read_config_option("global_auth") == "on") {
+     $map = db_fetch_assoc("select weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and (userid=".$_SESSION["sess_user_id"]." or userid=0) and weathermap_maps.id=".$mapid);
+   } else {
+      $map = db_fetch_assoc("select weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and weathermap_maps.id=".$mapid);
+   }

     if(sizeof($map))
     {
@@ -118,8 +123,8 @@

         if (isset($user_auth_realm_filenames['weathermap-cacti-plugin-mgmt.php'])) {
                 $realm_id2 = $user_auth_realm_filenames['weathermap-cacti-plugin-mgmt.php'];
-        }
-        if ((db_fetch_assoc("select user_auth_realm.realm_id from user_auth_realm where user_auth_realm.user_id='" . $_SESSION["sess_user_id"] . "' and user_auth_realm.realm_id='$realm_id2'")) || (empty($realm_id2))) {
+        }
+        if ((read_config_option("global_auth") == "off") || (db_fetch_assoc("select user_auth_realm.realm_id from user_auth_realm where user_auth_realm.user_id='" . $_SESSION["sess_user_id"] . "' and user_auth_realm.realm_id='$realm_id2'")) || (empty($realm_id2))) {

                 print '<a href="' . $config['url_path'] . 'plugins/weathermap/weathermap-cacti-plugin-mgmt.php">Manage Maps</a>';
         }
@@ -129,7 +134,12 @@
 {
   global $colors;

- $maplist = db_fetch_assoc( "select distinct weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and (userid=".$_SESSION["sess_user_id"]." or userid=0) order by sortorder, id");
+
+  if (read_config_option("global_auth") == "on") {
+     $maplist = db_fetch_assoc( "select distinct weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and (userid=".$_SESSION["sess_user_id"]." or userid=0) order by sortorder, id");
+  } else {
+     $maplist = db_fetch_assoc( "select distinct weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' order by sortorder, id");
+  }


   if(sizeof($maplist) == 1)
@@ -204,7 +214,11 @@

   $_SESSION['custom']=false;

-  $maplist = db_fetch_assoc( "select distinct weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and (userid=".$_SESSION["sess_user_id"]." or userid=0) order by sortorder, id");
+  if (read_config_option("global_auth") == "on") {
+     $maplist = db_fetch_assoc( "select distinct weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and (userid=".$_SESSION["sess_user_id"]." or userid=0) order by sortorder, id");
+  } else {
+     $maplist = db_fetch_assoc( "select distinct weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and order by sortorder, id");
+  }
   html_graph_start_box(2,true);

   if(sizeof($maplist) == 1)
setup.php, function weathermap_show_tab()

Code: Select all

function weathermap_show_tab () {
        global $config, $user_auth_realms, $user_auth_realm_filenames;
        $realm_id2 = 0;

        if (isset($user_auth_realm_filenames[basename('weathermap-cacti-plugin.php')])) {
                $realm_id2 = $user_auth_realm_filenames[basename('weathermap-cacti-plugin.php')];
        }

         if (read_config_option("global_auth") == "on") {
                if ((db_fetch_assoc("select user_auth_realm.realm_id from user_auth_realm where user_auth_realm.user_id='" . $_SESSION["sess_user_id"] . "' and user_auth_realm.realm_id='$realm_id2'")) || (empty($realm_id2))) {

                        print '<a href="' . $config['url_path'] . 'plugins/weathermap/weathermap-cacti-plugin.php"><img src="' . $config['url_path'] . 'plugins/weathermap/images/tab_weathermap.png" alt="Weathermap" align="absmiddle" border="0"></a>';

                }
        } else {
                        print '<a href="' . $config['url_path'] . 'plugins/weathermap/weathermap-cacti-plugin.php"><img src="' . $config['url_path'] . 'plugins/weathermap/images/tab_weathermap.png" alt="Weathermap" align="absmiddle" border="0"></a>';
        }

basically, where-ever sess_user_id is used, if the config_option global_auth is off we just ignore any userid and pull all information.

I also had to change cacti/include/top_graph_header.php:

Code: Select all

diff -u top_graph_header.php /var/srv/www/cacti/include/top_graph_header.php
--- top_graph_header.php        2006-06-27 14:34:55.012130192 -0700
+++ /var/srv/www/cacti/include/top_graph_header.php     2006-06-27 15:07:22.573055928 -0700
@@ -41,6 +41,8 @@
        if (sizeof(db_fetch_assoc("select realm_id from user_auth_realm where realm_id=8 and user_id=" . $_SESSION["sess_user_id"])) == 0) {
                $show_console_tab = false;
        }
+} else {
+       $current_user = db_fetch_row("select * from user_auth where id='admin'");
 }

 /* use cached url if available and applicable */

These changes do give full admin access to everything; that is the way we currently run Cacti (everyone is trusted who has access to the server)
_JPL_
Cacti User
Posts: 67
Joined: Mon Nov 29, 2004 11:34 am

Post by _JPL_ »

Howie wrote:
_JPL_ wrote:I don't see maps at all after the poller runs. I chmod 777 the output folder to make sure there were sufficient perms (will undo once I get it working). I have the conf file in the configs folder.

In the poller at the very end I see the error:
PHP Fatal error: Cannot redeclare class html_imagemap_area_polygon in /usr/share/pear/HTML_ImageMap.class.php on line 140

Which version of PHP, and which platform is this? I haven't seen this one before...

[please don't crosspost the same query...]
PHP 5.0.4 on Fedora Core 4, apache 2.0.54, cacti 0.8.6h
andrew2
Cacti User
Posts: 64
Joined: Mon Jul 26, 2004 2:50 pm
Location: Cincinnati, OH
Contact:

Weathermap doesn't seem to work out of cron

Post by andrew2 »

Odd problem here. If I run poller.php from the commandline, weathermap executes and runs properly. When I let poller.php run as a cron job, I get this:

06/29/2006 04:35:13 PM - WEATHERMAP: Poller[0] Weathermap 0.82 in da house
06/29/2006 04:35:13 PM - WEATHERMAP: Poller[0] Engaging Weathermap DEBUG mode
06/29/2006 04:35:13 PM - WEATHERMAP: Poller[0] Iterating all maps.
06/29/2006 04:35:13 PM - WEATHERMAP: Poller[0] Map: /root/cacti-0.8.5/plugins/weathermap/configs/weathermap.conf -> /root/cacti-0.8.5/plugins/weathermap/output/weathermap_1.html & /root/cacti-0.8.5/plugins/weathermap/output/weathermap_1.png
06/29/2006 04:35:13 PM - WEATHERMAP: Poller[0] Adding default map colour set.
06/29/2006 04:35:13 PM - WEATHERMAP: Poller[0] Saving Node: node1
06/29/2006 04:35:13 PM - WEATHERMAP: Poller[0] Saving Node: node2
06/29/2006 04:35:13 PM - WEATHERMAP: Poller[0] Setting bandwidth (155M, 155M)

For what it's worth, I'm using cactid 0.8.6e with Cacti 0.8.6f

I'm running poller.php from the commandline as the same user with poller.php in its crontab, so permissions/paths/etc. should all be the same.

Any thoughts?

Thanks,

Andrew
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Re: Weathermap doesn't seem to work out of cron

Post by Howie »

andrew2 wrote:Odd problem here. If I run poller.php from the commandline, weathermap executes and runs properly. When I let poller.php run as a cron job, I get this:

06/29/2006 04:35:13 PM - WEATHERMAP: Poller[0] Weathermap 0.82 in da house
06/29/2006 04:35:13 PM - WEATHERMAP: Poller[0] Engaging Weathermap DEBUG mode
06/29/2006 04:35:13 PM - WEATHERMAP: Poller[0] Iterating all maps.
06/29/2006 04:35:13 PM - WEATHERMAP: Poller[0] Map: /root/cacti-0.8.5/plugins/weathermap/configs/weathermap.conf -> /root/cacti-0.8.5/plugins/weathermap/output/weathermap_1.html & /root/cacti-0.8.5/plugins/weathermap/output/weathermap_1.png
06/29/2006 04:35:13 PM - WEATHERMAP: Poller[0] Adding default map colour set.
06/29/2006 04:35:13 PM - WEATHERMAP: Poller[0] Saving Node: node1
06/29/2006 04:35:13 PM - WEATHERMAP: Poller[0] Saving Node: node2
06/29/2006 04:35:13 PM - WEATHERMAP: Poller[0] Setting bandwidth (155M, 155M)

For what it's worth, I'm using cactid 0.8.6e with Cacti 0.8.6f

I'm running poller.php from the commandline as the same user with poller.php in its crontab, so permissions/paths/etc. should all be the same.

Any thoughts?

Thanks,

Andrew
Ummmm. I don't see any error. That's exactly what you should get, assuming that DEBUG is on, and there is some more after that in the logs, too...
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
andrew2
Cacti User
Posts: 64
Joined: Mon Jul 26, 2004 2:50 pm
Location: Cincinnati, OH
Contact:

Re: Weathermap doesn't seem to work out of cron

Post by andrew2 »

Howie wrote: Ummmm. I don't see any error. That's exactly what you should get, assuming that DEBUG is on, and there is some more after that in the logs, too...
Well, that's the problem. :D DEBUG is on, and that's the last line in the log.

Andrew
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

_JPL_ wrote:
Howie wrote:
_JPL_ wrote:I don't see maps at all after the poller runs. I chmod 777 the output folder to make sure there were sufficient perms (will undo once I get it working). I have the conf file in the configs folder.

In the poller at the very end I see the error:
PHP Fatal error: Cannot redeclare class html_imagemap_area_polygon in /usr/share/pear/HTML_ImageMap.class.php on line 140

Which version of PHP, and which platform is this? I haven't seen this one before...

[please don't crosspost the same query...]
PHP 5.0.4 on Fedora Core 4, apache 2.0.54, cacti 0.8.6h
Aaah.. I see the problem now. It looks like someone else has written an HTML_ImageMap class, and submitted it to PEAR. If you don't need it for anything else, then the quick fix would be to uninstall the PEAR HTML_Imagemap class:

Code: Select all

pear uninstall HTML_ImageMap
I'll have to change that classname in a new version, I guess.

Either that, or did you copy that class file from the weathermap folder in your /usr/share/pear? I don't actually see HTML_ImageMap on the PEAR site...
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Re: Weathermap doesn't seem to work out of cron

Post by Howie »

andrew2 wrote:I'm running poller.php from the commandline as the same user with poller.php in its crontab, so permissions/paths/etc. should all be the same.
That's not always true. On my FreeBSD systems, cron runs with a more restricted path than the regular shell. I think that's fairly common, too - man 5 crontab will confirm for you.

That said, there's only one external program that weathermap uses, and that's rrdtool, for which it gets the full path from Cacti.
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
_JPL_
Cacti User
Posts: 67
Joined: Mon Nov 29, 2004 11:34 am

Post by _JPL_ »

Howie wrote:
_JPL_ wrote:
Howie wrote:
Which version of PHP, and which platform is this? I haven't seen this one before...

[please don't crosspost the same query...]
PHP 5.0.4 on Fedora Core 4, apache 2.0.54, cacti 0.8.6h
Aaah.. I see the problem now. It looks like someone else has written an HTML_ImageMap class, and submitted it to PEAR. If you don't need it for anything else, then the quick fix would be to uninstall the PEAR HTML_Imagemap class:

Code: Select all

pear uninstall HTML_ImageMap
I'll have to change that classname in a new version, I guess.

Either that, or did you copy that class file from the weathermap folder in your /usr/share/pear? I don't actually see HTML_ImageMap on the PEAR site...
Once I noticed the error I copied the weathermap HTML_Imagemap class over the pear one but still error for some reason. There are no other weathermap references in a debug run of the cacti log either for some reason. I'll try moving the pear file and see what happens.

EDIT: That was the problem. I removed the class file from the pear folder and it works now. Thanks.
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

_JPL_ wrote: EDIT: That was the problem. I removed the class file from the pear folder and it works now. Thanks.
I think the reason is that in some parts of Weathermap it uses require_once to load a class file only once. However, in some places (in the cacti-specific files) it uses the full path to the classes, but in others it uses the class name only, which would choose the PEAR copy. At that stage PHP can't tell that the two 'different' files should be treated as one for the require_once process.
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
jga
Posts: 29
Joined: Mon Jul 01, 2002 3:41 pm
Location: Santiago de Chile

problems with weathermap v 0.82

Post by jga »

problems with weathermap v 0.82

Hi
I have installed Weathermap 0.82 , first the number associated with "Configure Weathermap" in setup.php, crashes with other plugin, I
jga
Posts: 29
Joined: Mon Jul 01, 2002 3:41 pm
Location: Santiago de Chile

problems with weathermap v 0.82

Post by jga »

"problems with weathermap v 0.82

Hi
I have installed Weathermap 0.82 , first the number associated with "Configure Weathermap" in setup.php, crashes with other plugin, I
stelaras1
Cacti User
Posts: 57
Joined: Wed Nov 03, 2004 10:11 am

unable to read data from rrd

Post by stelaras1 »

Hello!
I have installed 0.82 version and seems to run smoothly.
The only problem i have is that link status does not change.
Maybe it can't read from the corresponding rrd file.

Here is the output of debug in cacti.log file.

ReadData for Link node1152168863-node1152110831:
07/06/2006 02:57:03 PM - WEATHERMAP: Poller[0] New Target: /www/htdocs/cacti/rra/2118.rrd (/www/htdocs/cacti/rra/2118.rrd)
07/06/2006 02:57:03 PM - WEATHERMAP: Poller[0] ReadData: Updating link node1152168863-node1152110831 from RRD Target /www/htdocs/cacti/rra/2118.rrd
07/06/2006 02:57:03 PM - WEATHERMAP: Poller[0] ReadFromRRD: Target DS names are traffic_in and traffic_out
07/06/2006 02:57:03 PM - WEATHERMAP: Poller[0] ReadFromRRD: Running: /usr/local/rrdtool/bin/rrdtool fetch /www/htdocs/cacti/rra/2118.rrd AVERAGE --star
t now-800
07/06/2006 02:57:03 PM - WEATHERMAP: Poller[0] > 1152186000: 0.0000000000e+00 8.3074505917e+03
07/06/2006 02:57:03 PM - WEATHERMAP: Poller[0] > 1152186300: 0.0000000000e+00 8.5968652777e+03
07/06/2006 02:57:03 PM - WEATHERMAP: Poller[0] > 1152186600: 0.0000000000e+00 8.4315453866e+03
07/06/2006 02:57:03 PM - WEATHERMAP: Poller[0] > 1152186900: 0.0000000000e+00 8.5097513333e+03
07/06/2006 02:57:03 PM - WEATHERMAP: Poller[0] > 1152187200: NaN NaN
07/06/2006 02:57:03 PM - WEATHERMAP: Poller[0] >
07/06/2006 02:57:03 PM - WEATHERMAP: Poller[0] --
07/06/2006 02:57:03 PM - WEATHERMAP: Poller[0] --1152187200: NaN NaN
07/06/2006 02:57:03 PM - WEATHERMAP: Poller[0] ReadFromRRD: 1: This isn't a number: [NaN]
07/06/2006 02:57:03 PM - WEATHERMAP: Poller[0] ReadFromRRD: 2: This isn't a number: [NaN]
07/06/2006 02:57:03 PM - WEATHERMAP: Poller[0] --1152186900: 0.0000000000e+00 8.5097513333e+03
07/06/2006 02:57:03 PM - WEATHERMAP: Poller[0] ReadFromRRD: Found a good line: 1152186900: 0.0000000000e+00 8.5097513333e+03
(timestamp out in
)
07/06/2006 02:57:03 PM - WEATHERMAP: Poller[0] --1152186600: 0.0000000000e+00 8.4315453866e+03
07/06/2006 02:57:03 PM - WEATHERMAP: Poller[0] --1152186300: 0.0000000000e+00 8.5968652777e+03
07/06/2006 02:57:03 PM - WEATHERMAP: Poller[0] --1152186000: 0.0000000000e+00 8.3074505917e+03
07/06/2006 02:57:03 PM - WEATHERMAP: Poller[0] ReadFromRRD: Our line is 1152186900: 0.0000000000e+00 8.5097513333e+03
07/06/2006 02:57:03 PM - WEATHERMAP: Poller[0] ReadFromRRD: Returning (0,0)
07/06/2006 02:57:03 PM - WEATHERMAP: Poller[0] ReadData: Setting 0,0
07/06/2006 02:57:03 PM - WEATHERMAP: Poller[0]
ReadData Completed.

Can you please help me with this issue?

THanks in advance.
User avatar
adrianmarsh
Cacti User
Posts: 437
Joined: Wed Aug 17, 2005 8:51 am
Location: UK

Post by adrianmarsh »

stelaras1,

NaN means that the information from those datasources isn't being read correctly by cacti. Verify that you can view the actual graphs for those items first, from the normal Graphs view in Cacti.
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

adrianmarsh wrote:stelaras1,

NaN means that the information from those datasources isn't being read correctly by cacti. Verify that you can view the actual graphs for those items first, from the normal Graphs view in Cacti.
That's true, but it also says

Code: Select all

07/06/2006 02:57:03 PM - WEATHERMAP: Poller[0] ReadFromRRD: Our line is 1152186900: 0.0000000000e+00 8.5097513333e+03 
which is means it should be returning (0,8.5K), not (0,0)

It's not that unusual to have the last line be a NaN, if the poller takes a long time to run, which is why it searches backwards for non-NaN lines.

That said, is it possible that your RRD uses DS names other than 'traffic_in' and 'traffic_out', stelaras1? It seems that your DS names are 'in' and 'out'. If they are, you'll need to change your TARGET line to TARGET blah.rrd:in:out.

There's already a fix in 0.9 to make this type of problem more obvious.
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests