change WM backgroundcolor when a host is down

Support questions about the Network Weather Map plugin

Moderators: Developers, Moderators

Post Reply
mgb
Cacti User
Posts: 124
Joined: Mon Jun 21, 2004 4:06 am
Location: North of the Netherlands

change WM backgroundcolor when a host is down

Post by mgb »

Is it possible or an idea to make it possible to change the background of the weathermap to a different color or choose a different background according to the status of one of the hosts in a weathermap.

The idea is that we can see from the thumbnails background that one of the devices can't be reached anymore.

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

Post by Howie »

Only if you never want to use the editor again on that map.

At the moment, the background image filename can't contain {} tokens, but it could. However then the editor will always fail because there would be an [UNKNOWN] in the middle of the filename, since data isn't read when running the editor.

But the way you would do it is to create a single node that has a huge aggregate target of all the other nodes on the map, and a special scale to look for non-100% values and set the scaletag to the background filename. Put that node off-screen and then use {node:hiddennode:label} or similar in the background image filename, once you have changed the code to allow tokens in the filename (one line change).
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!)
mgb
Cacti User
Posts: 124
Joined: Mon Jun 21, 2004 4:06 am
Location: North of the Netherlands

Post by mgb »

Well, we've resolved the issue ourselves and found the following solution.

In this case we have 3 NODES already defined and now we add 3 extra nodes.

Further we created 4 background images. up, recovering and disabled are transparant and down is an colored (orange) background image. All the images have the size of the complete picture (in this example 1230x1100).

The idea is that the background pictures are overlapping but since they are transparant you will only see a background picture from the down nodes. We don't care if several down devices overlap. This way the background of the Weathermap changes color if there is a device where you have a second "background" node for. So you have control and a changing background.

Code: Select all

NODE background-Node1
	TARGET cactihost:37
	ZORDER 1
	ICON images/background_{node:this:state}.png
	POSITION 615 550

NODE background-Node2
	TARGET cactihost:4
	ZORDER 1
	ICON images/background_{node:this:state}.png
	POSITION 615 550

NODE background-Node3
	TARGET cactihost:38
	ZORDER 1
	ICON images/background_{node:this:state}.png
	POSITION 615 550

For some reason we couldn't use a template for this.

Thought i would share this.

Know we only need to solve the issue of a master map changing color if the child maps have problems.

Michael :wink: [/code]
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

Hehe. Yeah, that would do it. Forgot about zorder :-) It does mean doubling up on nodes though. You could reduce it to a single extra node, by combining our two approaches:

Code: Select all

SCALE bg 0 99.9 255 0 0
SCALE bg 99.9 100 none

NODE statenode
  ZORDER 1
   POSITION 615 550 
  MAXVALUE 9
  TARGET cactihost:1 cactihost:2 cactihost:3
  USESCALE bg in
then update MAXVALUE to n*3 and keep adding the host ids to the TARGET line. You can use an image instead by adding the filename onto the end of the scale lines. A scale colour of 'none' requires weathermap 0.96, but then so does zorder.
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!)
mgb
Cacti User
Posts: 124
Joined: Mon Jun 21, 2004 4:06 am
Location: North of the Netherlands

Post by mgb »

A lot more elegant than my solution but what if I disable a node? I think the map will change color. :-?

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

Post by Howie »

mgb wrote:A lot more elegant than my solution but what if I disable a node? I think the map will change color. :-?

Michael
Yes, it would.
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!)
Leathon
Posts: 9
Joined: Wed Nov 11, 2009 7:31 am
Location: The Netherlands

Post by Leathon »

Howie wrote:Hehe. Yeah, that would do it. Forgot about zorder :-) It does mean doubling up on nodes though. You could reduce it to a single extra node, by combining our two approaches:

Code: Select all

SCALE bg 0 99.9 255 0 0
SCALE bg 99.9 100 none

NODE statenode
  ZORDER 1
   POSITION 615 550 
  MAXVALUE 9
  TARGET cactihost:1 cactihost:2 cactihost:3
  USESCALE bg in
then update MAXVALUE to n*3 and keep adding the host ids to the TARGET line. You can use an image instead by adding the filename onto the end of the scale lines. A scale colour of 'none' requires weathermap 0.96, but then so does zorder.
Heya,
Im a colleague of Michael, and i am working on the same weathermap.

I have tried your method of changing the background, but i cant get it to work.

Only if i add a LABEL to the node can i get something to change color, which is just the background of the label. Without it, it wont change anything to the map when triggered.

Also, i tried to use the background image instead of the color cose, but that didnt work and produced these errors:

11/11/2009 03:27:17 PM - WEATHERMAP: Poller[0] WARNING: [Map 24] test.conf: NewColourFromPercent: Scale bg doesn't include 90% while drawing item statenode [WMWARN29]
11/11/2009 03:27:17 PM - WEATHERMAP: Poller[0] WARNING: [Map 24] test.conf: NewColourFromPercent: Scale bg doesn't include 90% while drawing item statenode [WMWARN29]
11/11/2009 03:27:15 PM - WEATHERMAP: Poller[0] WARNING: [Map 24] test.conf: Unrecognised config on line 37: SCALE bg 0 99.9 images/background_down.png

I tried it by switching the color codes for the location of the image file.
If u have any comments or fixes for this, id be very thankful.


Thnx in advance,

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

Post by Howie »

Leathon wrote:
Howie wrote:Hehe. Yeah, that would do it. Forgot about zorder :-) It does mean doubling up on nodes though. You could reduce it to a single extra node, by combining our two approaches:

Code: Select all

SCALE bg 0 99.9 255 0 0
SCALE bg 99.9 100 none

NODE statenode
  ZORDER 1
   POSITION 615 550 
  MAXVALUE 9
  TARGET cactihost:1 cactihost:2 cactihost:3
  USESCALE bg in
then update MAXVALUE to n*3 and keep adding the host ids to the TARGET line. You can use an image instead by adding the filename onto the end of the scale lines. A scale colour of 'none' requires weathermap 0.96, but then so does zorder.
Heya,
Im a colleague of Michael, and i am working on the same weathermap.

I have tried your method of changing the background, but i cant get it to work.

Only if i add a LABEL to the node can i get something to change color, which is just the background of the label. Without it, it wont change anything to the map when triggered.

Also, i tried to use the background image instead of the color cose, but that didnt work and produced these errors:

11/11/2009 03:27:17 PM - WEATHERMAP: Poller[0] WARNING: [Map 24] test.conf: NewColourFromPercent: Scale bg doesn't include 90% while drawing item statenode [WMWARN29]
11/11/2009 03:27:17 PM - WEATHERMAP: Poller[0] WARNING: [Map 24] test.conf: NewColourFromPercent: Scale bg doesn't include 90% while drawing item statenode [WMWARN29]
11/11/2009 03:27:15 PM - WEATHERMAP: Poller[0] WARNING: [Map 24] test.conf: Unrecognised config on line 37: SCALE bg 0 99.9 images/background_down.png

I tried it by switching the color codes for the location of the image file.
If u have any comments or fixes for this, id be very thankful.


Thnx in advance,

Tom
My brain wasn't fully switched on :oops:

You would need to use the 'artificial icons' stuff in 0.96+:

ICON 1230 1100 box
AICONOUTLINECOLOR none
LABELOUTLINECOLOR none
AICONFILLCOLOR copy
LABELOFFSET C

So that makes a 1230x1100 box for the node with no outline, and copies the boxes colour from the label's colour. Then hide the label outline so there's no line.

The other thing, with the scale: you still need to have a colour in the SCALE line:
SCALE bg 0 99.9 0 0 0 images/background_down.png
or
SCALE bg 0 99.9 none images/background_down.png
should both work.
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!)
Leathon
Posts: 9
Joined: Wed Nov 11, 2009 7:31 am
Location: The Netherlands

Post by Leathon »

Heya Howie,

Thanks alot for your fix, its working now.


Still have 2 things though,

1. It wont use the background when i use: SCALE bg 0 99.9 255 0 0 /images/background_down.png

2. It wont use: AICONOUTLINECOLOR none, its a Unrecognised config in the error logs.

Id like to thank you again for making it work (NICE, Michael will be happy :D) so u dont need to hurry with fixing these last problems, because we dont really need a fix for those (but would be nice for later improvements of our weathermap)


This is my working config:

Code: Select all

SCALE bg 0 99.9 255 180 0 
SCALE bg 99.9 100 none 

NODE statenode 
  ZORDER 1 
   USESCALE bg in 
  ICON 1230 1100 box 
  AICONOUTLINECOLOR none 
  LABELOUTLINECOLOR none 
  AICONFILLCOLOR copy 
  LABELOFFSET C 
  POSITION 615 550
  TARGET cactihost:2 cactihost:3 cactihost:13 
  MAXVALUE 9

So thnx for the quick replies, and ill inform Michael of the fixes.

Tom
Leathon
Posts: 9
Joined: Wed Nov 11, 2009 7:31 am
Location: The Netherlands

Post by Leathon »

Heya,

As a reply to my last post here about the AICONOUTLINECOLOR not working:

When u set "none" as a color it will not work and give an error, but when u set 255 255 255 as a color , it will make the line white and no longer give an error. (U can use any other color code, and it will no longer give the error)

Thought u might wanna know,

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

Post by Howie »

Leathon wrote:Heya,

As a reply to my last post here about the AICONOUTLINECOLOR not working:

When u set "none" as a color it will not work and give an error, but when u set 255 255 255 as a color , it will make the line white and no longer give an error. (U can use any other color code, and it will no longer give the error)

Thought u might wanna know,

Tom
This is now fixed in 0.97 - if you would like to try it before then, it's a one-line change:

Look for the line in ReadConfig in Weathermap.class.php that looks like (should be around line 2240):

Code: Select all

if($val == 'none' && ($matches[1]=='LABELFONTSHADOW' || $matches[1]=='LABELBG' || $matches[1]=='LABELOUTLINE')
and change it to:

Code: Select all

if($val == 'none' && ($matches[1]=='LABELFONTSHADOW' || $matches[1]=='LABELBG' || $matches[1]=='LABELOUTLINE' || $matches[1]=='AICONOUTLINE'))
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!)
Leathon
Posts: 9
Joined: Wed Nov 11, 2009 7:31 am
Location: The Netherlands

Post by Leathon »

Heya Howie,

Thanks for the quick replies.
Applying your change get rid of the error, so thats all working now.


Greetz,
Tom
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests