Dynamic Label color for nodes (based on CPU usage)

Support questions about the Network Weather Map plugin

Moderators: Developers, Moderators

ben_2007
Posts: 3
Joined: Fri Mar 23, 2007 12:11 pm

Dynamic Label color for nodes (based on CPU usage)

Post by ben_2007 »

Hi all,

I'm trying to change the color of a node label based on CPU usage. Based on the manual, we have created the following code that does not work:


NODE PAPY
LABEL Home
ICON images/my_router.png
LABELOFFSET S
TARGET /var/www/html/rra/ce26212_5min_cpu_87.rrd:5min_cpu:-
POSITION 886 362

Could you help sorting out this please? :o
Ben
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Re: Dynamic Label color for nodes (based on CPU usage)

Post by Howie »

ben_2007 wrote:Hi all,

I'm trying to change the color of a node label based on CPU usage. Based on the manual, we have created the following code that does not work:


NODE PAPY
LABEL Home
ICON images/my_router.png
LABELOFFSET S
TARGET /var/www/html/rra/ce26212_5min_cpu_87.rrd:5min_cpu:-
POSITION 886 362

Could you help sorting out this please? :o
Ben
Which version of weathermap are you using? For node targets to work, you need to use the (beta test) 0.9pre1 version.

That's correct config though. Bear in mind that by default it will use the same scale as the bandwidth arrows, with a maximum value of 100. So your load average will need to be fairly high to get significant changes.

You probably want to set the MAXVALUE for your node to something more like 10 or 20, so that 100% is something you might see. If I saw a load of 100 on one of our servers, I would be listening for the fire system's gas-dump alarm :-)
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!)
ben_2007
Posts: 3
Joined: Fri Mar 23, 2007 12:11 pm

Post by ben_2007 »

Hi Howie,

I'm using v0.9 version. I already changed MAXVALUE to adjust current polled value to around 50% of MAXVALUE.

I should get some color. I tried with other values of OID. It works with these values.
Therefore, it seems to be an incompatibility between this function and the CPU value.

Any idea/comment about this?
Thanks, Ben
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

ben_2007 wrote:Hi Howie,

I'm using v0.9 version. I already changed MAXVALUE to adjust current polled value to around 50% of MAXVALUE.

I should get some color. I tried with other values of OID. It works with these values.
Therefore, it seems to be an incompatibility between this function and the CPU value.

Any idea/comment about this?
Thanks, Ben
One other thing - try

Code: Select all

TARGET gauge:/var/www/html/rra/ce26212_5min_cpu_87.rrd:5min_cpu:- 
By default the rrd data source plugin multiplies values by 8, because it assumes they are byte-counters (normal SNMP interface counters). gauge takes the raw value. That said, you should still get the 100% colour, really...

It definitely works, because I use it myself to map temperatures and humidity around our data centre.
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!)
khooker
Posts: 8
Joined: Thu Mar 22, 2007 5:29 pm
Location: Paris

Post by khooker »

I used the proposed code and it works for me.

However, the Weathermap log has now the following line for each of the CPU entry I use to colour the label:
Notice: Undefined index: - in /var/www/html/plugins/weathermap/lib/datasources/WeatherMapDataSource_rrd.php on line 172
Have you already experienced the same kind of notice?
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

khooker wrote:I used the proposed code and it works for me.

However, the Weathermap log has now the following line for each of the CPU entry I use to colour the label:
Notice: Undefined index: - in /var/www/html/plugins/weathermap/lib/datasources/WeatherMapDataSource_rrd.php on line 172
Have you already experienced the same kind of notice?
No, but I can see why you would get it. It's nothing to worry about. I'll make changes to stop the warning.
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!)
oasturiano
Posts: 6
Joined: Sat Mar 04, 2006 11:34 pm
Location: México

Node Icon changing color

Post by oasturiano »

Hi Howie, I was wondering if there is a way to link the data read by some Target and to scale it to a color, and that the value in between that scale can Set a specific number or name, in order to change the ICON using the Special Tokens (another image with other color).

I don't know if you understand me, but the idea is for a Map that changes it's color according to any data fetch value.
Last edited by oasturiano on Tue Apr 03, 2007 7:44 pm, edited 4 times in total.
oasturiano
Posts: 6
Joined: Sat Mar 04, 2006 11:34 pm
Location: México

Post by oasturiano »

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

Re: Node Icon changing color

Post by Howie »

oasturiano wrote:Hi Howie, I was wondering if there is a way to link the data read by some Target and to scale it to a color, and that the value in between that scale can Set a specific number or name, in order to change the ICON using the Special Tokens (another image with other color).

I don't know if you understand me, but the idea is for a Map that changes it's color according to any data fetch value.
Well, neither the map BACKGROUND colour or image can use the special string tokens at the moment, so the short answer is no.

You want the whole background of the map to change colour, so it's visible from the thumbnail view?

This is the sort of thing that the new weathermap post-processing plugins in 0.9 are intended for, although I haven't really worked out the details yet.
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!)
oasturiano
Posts: 6
Joined: Sat Mar 04, 2006 11:34 pm
Location: México

Post by oasturiano »

Well, what I meant was, if there is a way to set a specific value in a variable if some data read by cacti falls into a range of values (like the scale).

With that number set in a variable (0,1,2,3...), to change an Icon in the map, using the syntax:
ICON images/image_name_{node:this:variable}.png

Or something like that... But I guess like you say, there is got to be a pre or post-processing
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

oasturiano wrote:Well, what I meant was, if there is a way to set a specific value in a variable if some data read by cacti falls into a range of values (like the scale).

With that number set in a variable (0,1,2,3...), to change an Icon in the map, using the syntax:
ICON images/image_name_{node:this:variable}.png

Or something like that... But I guess like you say, there is got to be a pre or post-processing
How about if the matching scale line-number was stored away somewhere for each node/link? That way you could define a custom scale on a hidden-away node (position -100 0 or something), then read that line number back out to use somewhere. Just trying to think of a simple way to achieve this... simple for the code, I mean :-)

To do this for each node, you would need a hidden node for each one though :roll: So it still needs something that does the same comparisons as the scale/colour process, but without changing the colour...
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!)
KBBAch
Posts: 3
Joined: Fri Oct 23, 2009 3:09 am
Location: Denmark

Post by KBBAch »

Code: Select all

TARGET gauge:/var/www/html/rra/ce26212_5min_cpu_87.rrd:5min_cpu:- 
Can anyone explain to me how this code actually works?

I've tried implementing it but the labels are all grayed out...
Couldn't find anything on the weathermap site about this... :-?
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

KBBAch wrote:

Code: Select all

TARGET gauge:/var/www/html/rra/ce26212_5min_cpu_87.rrd:5min_cpu:- 
Can anyone explain to me how this code actually works?

I've tried implementing it but the labels are all grayed out...
Couldn't find anything on the weathermap site about this... :-?
There's a page of the manual about targets.

Anyway, this one looks at /var/www/html/rra/ce26212_5min_cpu_87.rrd
It doesn't multiply by 8 (gauge:) and it fetches a DS called 5min_cpu as the 'in' value and nothing at all as the 'out' value (-).

If you run DEBUG logging and look in the logs, you can see a lot of information about how the data is being collected.
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!)
KBBAch
Posts: 3
Joined: Fri Oct 23, 2009 3:09 am
Location: Denmark

Post by KBBAch »

Hiii thx for the fast reply...
Yeah, just found the documentation, so embarrasing.. :oops:

Well.. I guess in my case it should look like this then

Code: Select all

TARGET /var/www/cacti/rra/MT-RO-01_5min_cpu_22.rrd:5min_cpu:-
I'll try implementing it... [/code]
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

KBBAch wrote:Hiii thx for the fast reply...
Yeah, just found the documentation, so embarrasing.. :oops:

Well.. I guess in my case it should look like this then

Code: Select all

TARGET /var/www/cacti/rra/MT-RO-01_5min_cpu_22.rrd:5min_cpu:-
I'll try implementing it... [/code]
With the gauge: prefix. Otherwise it will multiply by 8 (the default is to treat the data as byte counters, and multiply by 8 to get bits).
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 4 guests