Multi CPU Utilization Graph

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

Multi CPU Utilization Graph

Post by argon0 »

Multi CPU Utilization Graphs, using SNMP

So far (see below) I've found that the 3 xmls in slech's zip file
multi.2.4.8.cpu.zip
Slech's version of the Multi-CPU graphs.
(9.52 KiB) Downloaded 12015 times
(Page 9 of this thread), work well - at least as well as my original's, though you DO still need to associate the data items AFTER creating the graphs. I've attached this zip to this post. {Edit: I have new versions with a little tweak to them almost ready to upload}
Pink variant
Pink variant
Multi_CPU_Example.PNG (54.52 KiB) Viewed 71278 times

Quick tutorial on how to use/customise:

1. Import the template in cacti
-- Goto the console pane
-- Click on Import Templates
-- Choose the file (template) to import
-- Click Import

2. Create Graphs
-- Goto console pane
-- Goto Devices
-- Choose your device (host)
-- Click on Create *Create Graphs for this Host
-- Choose from the drop down in the "Graph Template Section" the relevant graph - "HOST MIB - MULT CPU utilization on X processor box" - Where X is the number of CPUs in your device
-- Click Create
-- on the next screen you will asked the index-value/type ... just click on save and its not over yet !!

3. Get the Graphs working
-- Goto Console
-- Goto Graph Management
-- locate the graph you just created, click on it
-- in "Supplemental Graph Template Data” select the cpu you wish to graph on the multi-cpu-graph, for each data source item, from the relevant dropdown. This is most likely HOSTNAME - CPU Utilization - CPU0 (cpu), HOSTNAME - CPU Utilization - CPU1 (cpu) and so on ...
-- (optional - : you can now delete the initial graphs that you created in step 2 but when asked be sure to keep the data-sources intact because the multi-cpu-graph needs these data sources.)

4. A little bit of customisation
-- This bit just changes the colour of the Average (or MEAN) CPU utilization from yellow to PINK (as above), but you can choose any colour/opacity combination
-- Goto Graph Templates on the Console Tab
-- Click on the Multi-CPU Template you want to change
-- Click on Item #1
-- Choose the "Color" [sic] from the dropdown (I chose FF00FF)
-- Choose the "Opacity/Alpha Channel" from the dropdown (I chose 30%)
-- Click Save



Some of the above has been borrowed from this tutorial: http://www.goldfisch.at/knowwiki/howtos ... u_graphing, though I do take exception to point 6 - as far as I can work out the average IS calculated correctly my way. If you use the ALL_DATA_SOURCES_NODUPS special data source, you end up with a higher average CPU ute than you would expect - as it also includes ITSELF in the calculation - unless TPTB have fixed it since I wrote the original CDEF. Either way the original way does work, and IS correct (IMO).

More to come... Maybe... if I can pretty these things up (ponders if you do more than 8 should/could you do some going down as well as some going up ?). I may have worked out a way to shortcut some of the above...

All, I've just spent an hour trawling through this thread, and realised that, to a Cacti Newbie, or just someone wanting to do this for the first time, its a complete nightmare.... Everything above is new/subject to change

Thus this edit...

I'm at a new site, brand new CactiEZ install (Cacti 0.8.8a), with no Multi-CPU graphs. So I tried using Aggregate to create Multi-CPU, well it works, but its not pretty, and just not as good as my earlier efforts, so... I shall look at the templates we've all come up with get 3 (or 4) which actually work, maybe pretty them up a bit, and put them back here, and probably over at the repository - may start a new thread here too...

This MAY take a while, as I'll be doing it in my lunch hours...

(I've decided against using WMI unless I REALLY can't avoid it as I just kept coming up against performance problems when using it before, and most, if not all, of what I need is now exposed via SNMP).

OK - first thing - this template by jzondor: cacti_graph_template_multi_cpu_utilization_on_4_processor_box_v2a.xml only has stuff to do with Cisco 3000 in it - does anybody know why this is?


----------------------------------------------------------------------------------
Original Post Below this line
----------------------------------------------------------------------------------

Right, like many people I have many servers with multiple CPUs.

What I want to see is:

a graph which shows :
1) the average utilization over all CPUs (maybe as a light area in the "background")
2) the utilization of each CPU (perhaps as dark lines in the foreground).

That's it really...

Trying to work this out at the moment, worked out how to do part 2 on a case by case basis (as long as the individual data sources exist) - but now want to turn it into a template (using the convert to template function works but takes the data sources I used for the graph with it - instead of using the query...)

So how do you graph the average over 2 data sources? Create a new source?

Argon0
Last edited by argon0 on Fri Feb 15, 2013 11:33 am, edited 5 times in total.
No longer a n00by, probably, by now an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....
ehall
Cacti User
Posts: 246
Joined: Fri Dec 09, 2005 3:42 pm

Post by ehall »

You can create a cdef that adds two data sources together. You might be able to do this by creating hidden graph objects (one "hidden" line per cpu) and then create a CDEF that was something like "a, b, +". The variables reflect the ordering of the graph objects btw.
argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

Post by argon0 »

Hokay - I thought I'd created a data source that included multiple cpu instances, but when I try to use it to create graphs I get this:

Code: Select all

/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="UKEC4SI - Test Server - CPU Utilization Multi" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="" \
--slope-mode \
DEF:a="/var/www/html/rra/ukec4si_test_server_cpu_194.rrd":cpu:AVERAGE \
DEF:b="/var/www/html/rra/ukec4si_test_server_cpu_194.rrd":cpu1:AVERAGE \
LINE1:a#FF0000:"CPU Utilization (CPU0)"  \
GPRINT:a:LAST:"Current\:%8.0lf"  \
GPRINT:a:AVERAGE:"Average\:%8.0lf"  \
GPRINT:a:MAX:"Max\:%8.0lf\n"  \
LINE1:b#0D006A:"CPU Utilization (CPU1)"  \
GPRINT:b:LAST:"Current\:%8.0lf"  \
GPRINT:b:AVERAGE:"Average\:%8.0lf"  \
GPRINT:b:MAX:"Max\:%8.0lf" 

RRDTool Says:

ERROR: opening '/var/www/html/rra/ukec4si_test_server_cpu_194.rrd': No such file or directory
i.e. the data source file doesn't exist.

The Data Source itself gives me this code:

Code: Select all

/usr/bin/rrdtool create \
/var/www/html/rra/ukec4si_test_server_cpu_194.rrd \
--step 300  \
DS:cpu:GAUGE:600:0:U \
DS:cpu1:GAUGE:600:1:1 \
DS:cpu2:GAUGE:600:2:2 \
DS:cpu3:GAUGE:600:3:3 \
RRA:AVERAGE:0.5:1:600 \
RRA:AVERAGE:0.5:6:700 \
RRA:AVERAGE:0.5:24:775 \
RRA:AVERAGE:0.5:288:797 \
RRA:MIN:0.5:1:600 \
RRA:MIN:0.5:6:700 \
RRA:MIN:0.5:24:775 \
RRA:MIN:0.5:288:797 \
RRA:MAX:0.5:1:600 \
RRA:MAX:0.5:6:700 \
RRA:MAX:0.5:24:775 \
RRA:MAX:0.5:288:797 \
RRA:LAST:0.5:1:600 \
RRA:LAST:0.5:6:700 \
RRA:LAST:0.5:24:775 \
RRA:LAST:0.5:288:797 \
The file in question does not exit...[/i]
No longer a n00by, probably, by now an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....
argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

Post by argon0 »

When I try and create the graph for a new host I get asked for:

Custom Data [Template: Host MIB - CPU Utilization]
Index Type
Index Value
Output Type ID

What (if anything) should I put here?
No longer a n00by, probably, by now an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....
argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

Post by argon0 »

After running the data source code through a terminal I create the file - I get the graph up now... Dunno it it'll contain any data though...
No longer a n00by, probably, by now an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....
argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

Post by argon0 »

OK, I'm stuck - thought I knew what I was doing, but no, buggered if I can get it right!!!

At the moment wouldn't mind if all I could do was get two graphs...

1) Showing up to 4 cpus
2) shoing the average over up to 4 cpus

At the moment I'm going around in circles trying to get it to graph the separate CPUs - anybody offer any help?

Argon0
No longer a n00by, probably, by now an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....
argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

HAYELP...

Post by argon0 »

Ok here is a graph I've managed to create of 4 CPUs on one box:

Image

As you will see its not *quite* right, the Mean CPU function seems to give a different amount than you would expect - i.e. higher..

The function it uses is a CDEF I created which looks like this:
CDEF:cdefa=TIME,1138381205,GT,b,b,UN,0,b,IF,IF,TIME,1138381205,GT,b,b,UN,0,b,IF,IF,TIME,1138381205,GT,c,c,UN,0,c,IF,IF,TIME,1138381205,GT,d,d,UN,0,d,IF,IF,TIME,1138381205,GT,e,e,UN,0,e,IF,IF,+,+,+,+,4,/ \

basically What I thought I was doing was a cdef which looks like this:

Code: Select all

Item   	 Item Value   	  
Item #1 	Special Data Source: ALL_DATA_SOURCES_NODUPS 	
Item #2 	Custom String: 4 	
Item #3 	Operator: / 	

Is there acdef function you can use which will give the average over all data sources?

What the CDEF I've created SEEMS to do is add up ALL the data sources (including itself) for the graph then divide by 4.... Which gives the higher value than the average should be - and leads to the MAX value being higher than 100%...


Here is the entire code for the graph.

Code: Select all

/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="Multi CPU Utilization on UKHALWEB1" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="" \
--slope-mode \
DEF:a="/var/www/html/rra/ukhalweb1_cpu_97.rrd":cpu:AVERAGE \
DEF:b="/var/www/html/rra/ukhalweb1_cpu_97.rrd":cpu:AVERAGE \
DEF:c="/var/www/html/rra/ukhalweb1_cpu_98.rrd":cpu:AVERAGE \
DEF:d="/var/www/html/rra/ukhalweb1_cpu_99.rrd":cpu:AVERAGE \
DEF:e="/var/www/html/rra/ukhalweb1_cpu_100.rrd":cpu:AVERAGE \
CDEF:cdefa=TIME,1138381205,GT,b,b,UN,0,b,IF,IF,TIME,1138381205,GT,b,b,UN,0,b,IF,IF,TIME,1138381205,GT,c,c,UN,0,c,IF,IF,TIME,1138381205,GT,d,d,UN,0,d,IF,IF,TIME,1138381205,GT,e,e,UN,0,e,IF,IF,+,+,+,+,4,/ \
CDEF:cdefb=TIME,1138381205,GT,b,b,UN,0,b,IF,IF,TIME,1138381205,GT,b,b,UN,0,b,IF,IF,TIME,1138381205,GT,c,c,UN,0,c,IF,IF,TIME,1138381205,GT,d,d,UN,0,d,IF,IF,TIME,1138381205,GT,e,e,UN,0,e,IF,IF,+,+,+,+,4,/ \
AREA:cdefa#FAFD9E:"Mean CPU"  \
GPRINT:cdefb:LAST:"    Current\:%8.2lf %%"  \
GPRINT:cdefb:MIN:"Min\:%8.2lf %%"  \
GPRINT:cdefb:MAX:"Max\:%8.2lf %%\n"  \
LINE1:b#0000FF:"CPU0"  \
GPRINT:b:LAST:"    Current\:%8.2lf %%"  \
GPRINT:b:MIN:"Min\:%8.2lf %%"  \
GPRINT:b:MAX:"Max\:%8.2lf %%\n"  \
LINE1:c#00A348:"CPU1"  \
GPRINT:c:LAST:"    Current\:%8.2lf %%"  \
GPRINT:c:MIN:"Min\:%8.2lf %%"  \
GPRINT:c:MAX:"Max\:%8.2lf %%\n"  \
LINE1:d#C4FD3D:"CPU2"  \
GPRINT:d:AVERAGE:"    Current\:%8.2lf %%"  \
GPRINT:d:MIN:"Min\:%8.2lf %%"  \
GPRINT:d:MAX:"Max\:%8.2lf %%\n"  \
LINE1:e#FF0000:"CPU3"  \
GPRINT:e:AVERAGE:"    Current\:%8.2lf %%"  \
GPRINT:e:MIN:"Min\:%8.2lf %%"  \
GPRINT:e:MAX:"Max\:%8.2lf %%" 
Attachments
graph_image_multi_cpu.png
graph_image_multi_cpu.png (42.11 KiB) Viewed 208872 times
No longer a n00by, probably, by now an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....
argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

Post by argon0 »

ANybody got any ideas how I could

a) turn this graph into a generic template
b) get the average CPU utilisation over all CPUs to read correctly...
No longer a n00by, probably, by now an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: HAYELP...

Post by gandalf »

argon0 wrote:The function it uses is a CDEF I created which looks like this:
CDEF:cdefa=TIME,1138381205,GT,b,b,UN,0,b,IF,IF,TIME,1138381205,GT,b,b,UN,0,b,IF,IF,TIME,1138381205,GT,c,c,UN,0,c,IF,IF,TIME,1138381205,GT,d,d,UN,0,d,IF,IF,TIME,1138381205,GT,e,e,UN,0,e,IF,IF,+,+,+,+,4,/ \

DEF:a="/var/www/html/rra/ukhalweb1_cpu_97.rrd":cpu:AVERAGE \
DEF:b="/var/www/html/rra/ukhalweb1_cpu_97.rrd":cpu:AVERAGE \
You included a data source twice. Please have a look at your graph template to reveal this ...
Reinhard
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

argon0 wrote:ANybody got any ideas how I could

a) turn this graph into a generic template
b) get the average CPU utilisation over all CPUs to read correctly...
a) Goto Graph Management and select the Graph; select Convert to Graph Template. To use this: Goto Graph Management and ADD. Choose the newly generated Graph Template and the host in question. Now you're getting the required data sources to select. AFAIK, this will ONLY work, if the Graph Template defines exactly the same number of Items you want to graph (e.g. the template holds for 4 CPUs, but your current host has only 3 => won't work). I'm currently looking at that stuff. Perhaps I'll find a workaround; but this may take time
b) see my post above
Reinhard
argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

Post by argon0 »

Yup - worked that out about the multi cdefs...

Graph template, well this kind of works, but the problem then becomes the data sources..

I've fudged a way around most of the problems. But still can't get it to graph/calculate the average utilsation over all cpus properly.

(I use the cdef Special Data Source: ALL_DATA_SOURCES_NODUPS, and divide by the number of cpus, this too high a value, as it includes this cdef in the calculation, e.g. I have two processors, one at 50% util, one at 40% util, the mean util should be 45%, but the calculation gives 72.5%, I think what is happening is it takes the 50 adds the 45 divides by two, adds the result of this calculation to the first two data sources, then divides by two again to get the final answer...) -- hayelp...
No longer a n00by, probably, by now an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....
argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

Post by argon0 »

Here's the code for the graph:

Code: Select all

RRDTool Command:

/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="Multi CPU Utilization on UKHALWEB2" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="" \
--slope-mode \
DEF:a="/var/www/html/rra/ukhalweb2_cpu_231.rrd":cpu:AVERAGE \
DEF:b="/var/www/html/rra/ukhalweb2_cpu_231.rrd":cpu:AVERAGE \
DEF:c="/var/www/html/rra/ukhalweb2_cpu_232.rrd":cpu:AVERAGE \
CDEF:cdefa=TIME,1138704170,GT,b,b,UN,0,b,IF,IF,TIME,1138704170,GT,b,b,UN,0,b,IF,IF,TIME,1138704170,GT,c,c,UN,0,c,IF,IF,+,+,2,/ \
AREA:cdefa#FAFD9E:"Mean CPU"  \
GPRINT:cdefa:LAST:"    Current\:%8.2lf %%"  \
GPRINT:cdefa:MIN:"Min\:%8.2lf %%"  \
GPRINT:cdefa:MAX:"Max\:%8.2lf %%\n"  \
LINE1:b#0000FF:"CPU0"  \
GPRINT:b:LAST:"    Current\:%8.2lf %%"  \
GPRINT:b:MIN:"Min\:%8.2lf %%"  \
GPRINT:b:MAX:"Max\:%8.2lf %%\n"  \
LINE1:c#00A348:"CPU1"  \
GPRINT:c:LAST:"    Current\:%8.2lf %%"  \
GPRINT:c:MIN:"Min\:%8.2lf %%"  \
GPRINT:c:MAX:"Max\:%8.2lf %%\n" 
You will notice there are THREE data sources on this 2 CPU graph, 2 of which are the same (so no_dups should take care of that, surely...) - no idea why this is I've only defined 2 data sources in the graph & only been asked for 2 when I change the graph around...

again -- HAYELP!!!
No longer a n00by, probably, by now an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....
Doraken
Posts: 2
Joined: Tue Jan 31, 2006 5:56 am

One important thing whent you hade some hole in your graphe

Post by Doraken »

If like me you have some Time Out on CPU request
you must add a minimu value to your CDEF command

like this

Item #1 Special Data Source: ALL_DATA_SOURCES_NODUPS Move Down Move Up Delete
Item #2 Custom String: 4 Move Down Move Up Delete
Item #3 Operator: + Move Down Move Up Delete
Item #4 Custom String: 4 Move Down Move Up Delete
Item #5 Operator: /

If you don't do this your graph will not display anymore information after applying the CDEF command

( you can't divide 0 by any number .... )

Here i put a value like one percent i think this is ok and don't make my graph too false

If someone hade an idea about the methode to bypass this limitation ?

8)
In the dark we trust.
in the light we die.
argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

Post by argon0 »

Is there any way to directly edit the RRD Tool command that leads to the graph - if there were I'd just need to delete one of the DEF commands...
No longer a n00by, probably, by now an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....
Doraken
Posts: 2
Joined: Tue Jan 31, 2006 5:56 am

The template for exemple

Post by Doraken »

Here is the temple i hade generated with cacti export tool
Attachments
cacti_graph_template_charge_total_cpu.xml
All cpu information for Server which hade 4 CPU
(21.08 KiB) Downloaded 21183 times
In the dark we trust.
in the light we die.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest