Closed jpobeda closed 5 years ago
Just to give me a little bit of a clue for the version... in lib/ is there a Weathermap directory, or Weathermap.class.php? How many files are in there?
Also, if you edit this file using the editor, it doesn't move around the notes (from in to out, or from in/out to a single notes item)? That would indicate an issue with ReadConfig(). It sounds like that is OK.
# ls /usr/share/cacti1x/plugins/weathermap/lib/
all.php image-functions.php WeatherMapUIBase.class.php
base-classes.php index.php WMAngledLinkGeometry.class.php
cacti10-plugin-hooks.php plugin-base-classes.php WMBoundingBox.class.php
cacti88-plugin-common.php poller-common.php WMColour.class.php
cacti88-plugin-hooks.php post WMCurvedLinkGeometry.class.php
cacti88-plugin-mgmt.php pre WMDebug.php
cacti88-plugin-user.php SimpleTemplate.class.php WMImageLoader.class.php
cacti-pick.php Weathermap.class.php WMImageUtility.php
cacti-plugin-poller.php WeatherMapConfigReader.class.php WMLine.class.php
CatmullRom.class.php WeatherMapDataItem.class.php WMLinkGeometry.class.php
constants.php WeatherMapEditor.class.php WMLinkGeometryFactory.class.php
database.php WeatherMapEditorUI.class.php WMPoint.class.php
datasources WeatherMap.functions.php WMRectangle.class.php
ds-common.php WeatherMapLink.class.php WMSpine.class.php
editor.inc.php WeathermapManager.class.php WMStats.php
exceptions.php WeatherMapNode.class.php WMTarget.class.php
fonts.php WeatherMapPoller.class.php WMUtility.class.php
geometry.php WeatherMapRuntime.class.php WMVector.class.php
globals.php WeatherMapScale.class.php
HTMLImagemap.class.php WeatherMapTextItem.class.php
ls /usr/share/cacti1x/plugins/weathermap/lib/ | wc -l
58
There is a Weathermap.class.php
It understood well, you looking to see if using web editor replaces IN with OUT or vice versa, right?
Should I run this on debug mode and see what readconfig is reading?
No, just pressing submit, or editing anything in the map is a good enough test. It reads the whole config a rewrites it every time you make a change. OK, so now you know that the problem is in the drawing/html code. That's in the Weathermap.class.php - search for overlib to find the HTML output function.
Am I on the right place?
public function calculateImagemap()
{
wm_debug("Trace: calculateImagemap()\n");
// loop through everything. Figure out along the way if it's a node or a link
$allItems = $this->buildAllItemsList();
foreach ($allItems as $mapItem) {
$type = $mapItem->my_type();
# $prefix = substr($type, 0, 1);
$dirs = array();
if ($type == 'LINK') {
$dirs = array(IN => array(0, 2), OUT => array(1, 3));
}
if ($type == 'NODE') {
$dirs = array(IN => array(0, 1, 2, 3));
}
// check to see if any of the relevant things have a value
$change = "";
foreach ($dirs as $d => $parts) {
$change .= join('', $mapItem->overliburl[$d]);
$change .= $mapItem->notestext[$d];
}
// skip all this if it's a template node
if ($mapItem->isTemplate()) {
$change = "";
}
if ($this->htmlstyle == "overlib") {
if ($change != '') {
// find the middle of the map
$center_x = $this->width / 2;
$center_y = $this->height / 2;
$type = $mapItem->my_type();
if ($type == 'NODE') {
$mid_x = $mapItem->x;
$mid_y = $mapItem->y;
}
if ($type == 'LINK') {
$a_x = $this->nodes[$mapItem->a->name]->x;
$a_y = $this->nodes[$mapItem->a->name]->y;
$b_x = $this->nodes[$mapItem->b->name]->x;
$b_y = $this->nodes[$mapItem->b->name]->y;
$mid_x = ($a_x + $b_x) / 2;
$mid_y = ($a_y + $b_y) / 2;
}
$left = "";
$above = "";
$img_extra = "";
if ($mapItem->overlibwidth != 0) {
$left = "WIDTH," . $mapItem->overlibwidth . ",";
$img_extra .= " WIDTH=$mapItem->overlibwidth";
if ($mid_x > $center_x) {
$left .= "LEFT,";
}
}
if ($mapItem->overlibheight != 0) {
$above = "HEIGHT," . $mapItem->overlibheight . ",";
$img_extra .= " HEIGHT=$mapItem->overlibheight";
if ($mid_y > $center_y) {
$above .= "ABOVE,";
}
}
foreach ($dirs as $dir => $parts) {
$caption = ($mapItem->overlibcaption[$dir] != '' ? $mapItem->overlibcaption[$dir] : $mapItem->name);
$caption = $this->ProcessString($caption, $mapItem);
$overlibhtml = "onmouseover=\"return overlib('";
$n = 0;
if (sizeof($mapItem->overliburl[$dir]) > 0) {
// print "ARRAY:".is_array($link->overliburl[$dir])."\n";
foreach ($mapItem->overliburl[$dir] as $url) {
if ($n > 0) {
$overlibhtml .= '<br />';
}
$overlibhtml .= "<img $img_extra src=" . $this->ProcessString($url, $mapItem) . ">";
$n++;
}
}
# print "Added $n for $dir\n";
if (trim($mapItem->notestext[$dir]) != '') {
# put in a linebreak if there was an image AND notes
if ($n > 0) {
$overlibhtml .= '<br />';
}
$note = $this->ProcessString($mapItem->notestext[$dir], $mapItem);
$note = htmlspecialchars($note, ENT_NOQUOTES);
$note = str_replace("'", "\\'", $note);
$note = str_replace('"', """, $note);
$overlibhtml .= $note;
}
$overlibhtml .= "',DELAY,250,${left}${above}CAPTION,'" . $caption
. "');\" onmouseout=\"return nd();\"";
foreach ($mapItem->imap_areas as $area) {
$area->extrahtml = $overlibhtml;
}
}
} // if change
} // overlib?
// now look at infourls
foreach ($dirs as $dir => $parts) {
foreach ($parts as $part) {
# $areaname = $type . ":" . $prefix . $mapItem->id . ":" . $part;
if (($this->htmlstyle != 'editor') && ($mapItem->infourl[$dir] != '')) {
foreach ($mapItem->imap_areas as $area) {
$area->href = $this->ProcessString($mapItem->infourl[$dir], $mapItem);
}
}
}
}
}
}
Yes, but that looks right too 🤔 (the important part is the $dirs=
near the top - so it definitely should be trying to get both the IN and OUT).
Oh wait... it writes the same $overlibhtml
to all the $imap_areas, just above that // overlib?
comment. That's not right - it should only write to the ones for that direction. So the last direction written (OUT) overwrites the earlier one.
And it's still like that in the current version, too. So it's a legit bug :-) I'll figure out a solution. The variables have changed name, but the current version is basically the same, so the fix will work for you, too.
oh yeahhhhhhhhhhh =D I bet you weren't expecting that hehehe
Should be fixed now in master.
Hi Howie, it's been a long time =^D
Before we start, I'm running Cacti 1.1.37 and network weathermap 0.98dev version reworked to work on 1.x (I can't even remember how/where did I get it from).
So I understand I'm
out of support
I set this link
As you see, it's all static and pretty basic. The gif below shows you that I get OUTNOTES for IN and OUT sides of the link.
Then I tried the following config (getting rid of the OUTNOTES statement)
And this gif shows you what do I get
Defaults on this map are
I don't have access to cacti 0.8.x anymore, are you able to confirm if this is working fine or if it's something that might have come out from running it with cacti 1.x ?
btw, nothing on the logs indicating errors/warnings I guess I could run it in debug mode and see if spot anything unusual when handling the notes.
Thanks