Multi CPU Utilization Graph

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

Moderators: Developers, Moderators

Post Reply
simonc
Posts: 4
Joined: Thu Aug 07, 2008 5:36 am

Re: Dual QuadCore CPU

Post by simonc »

super-hornet wrote:
rmarinho wrote:Hi,

I've an dual quadcore cpu wich template should I use, I've try 8 cpu but I getting error:
ERROR: invalid rpn expression in: a,b,+,c,+,d,+,e,+,f,+,g,+,h,+,8,/

Help please.

Regards,
8CPU should correct.
Go debug mode and double check on what value it has. Your error message maybe due to:
1. U are not using snmp-5.4 and above for the system u going to monitor.
2. U didn't plot the individual CPU also.
3. Sometime, different system (cacti system) may end up having different value in the a, b, c, d and so on.

SH
Hi all,

I'm trying to solve the same problem from days without results!

This is the debug (I have a dual socket quad-core board) :

RRDTool Command:

/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="server xxxx - 8 CPU Utilization" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:10: \
--font UNIT:8: \
DEF:a="/usr/share/cacti/rra/server_xxxx_cpu_14.rrd":cpu:AVERAGE \
CDEF:cdefa=a,b,+,c,+,d,+,e,+,f,+,g,+,h,+,8,/ \
AREA:cdefa#F9FD5FFF:"Mean CPU\:" \
GPRINT:cdefa:LAST:"Current\:%8.2lf %%" \
GPRINT:cdefa:MIN:"Min\:%8.2lf %%" \
GPRINT:cdefa:MAX:"Max\:%8.2lf %%\n" \
LINE1:a#0000FFFF:"CPU0\:" \
GPRINT:a:LAST:" Current\:%8.2lf %%" \
GPRINT:a:MIN:"Min\:%8.2lf %%" \
GPRINT:a:MAX:"Max\:%8.2lf %%\n" \
LINE1:a#00A348FF:"CPU1\:" \
GPRINT:a:LAST:" Current\:%8.2lf %%" \
GPRINT:a:MIN:"Min\:%8.2lf %%" \
GPRINT:a:MAX:"Max\:%8.2lf %%\n" \
LINE1:a#C4FD3DFF:"CPU2\:" \
GPRINT:a:LAST:" Current\:%8.2lf %%" \
GPRINT:a:MIN:"Min\:%8.2lf %%" \
GPRINT:a:MAX:"Max\:%8.2lf %%\n" \
LINE1:a#FF0000FF:"CPU3\:" \
GPRINT:a:LAST:" Current\:%8.2lf %%" \
GPRINT:a:MIN:"Min\:%8.2lf %%" \
GPRINT:a:MAX:"Max\:%8.2lf %%\n" \
LINE1:a#000000FF:"CPU4\:" \
GPRINT:a:LAST:" Current\:%8.2lf %%" \
GPRINT:a:MIN:"Min\:%8.2lf %%" \
GPRINT:a:MAX:"Max\:%8.2lf %%\n" \
LINE1:a#00BED9FF:"CPU5\:" \
GPRINT:a:LAST:" Current\:%8.2lf %%" \
GPRINT:a:MIN:"Min\:%8.2lf %%" \
GPRINT:a:MAX:"Max\:%8.2lf %%\n" \
LINE1:a#FF00FFFF:"CPU6\:" \
GPRINT:a:LAST:" Current\:%8.2lf %%" \
GPRINT:a:MIN:"Min\:%8.2lf %%" \
GPRINT:a:MAX:"Max\:%8.2lf %%\n" \
LINE1:a#AAABA1FF:"CPU7\:" \
GPRINT:a:LAST:" Current\:%8.2lf %%" \
GPRINT:a:MIN:"Min\:%8.2lf %%" \
GPRINT:a:MAX:"Max\:%8.2lf %%\n"
RRDTool Says:

ERROR: invalid rpn expression in: a,b,+,c,+,d,+,e,+,f,+,g,+,h,+,8,/


I've installed net-snmp 5.4.1.2 from source (with the old net-snpm-5.3 got from apt-get install I have the same error) in the destination device to monitor.

Another strange behavior: when I create the graph for the host , cacti prompt me with three blank fields :

- Index Type
- Index Value
- Output Type ID


I need to monitor CPUs graph , this is the main reason I'm trying to use cacti. I'm using debian etch with cacti and net-snmp-5.4 compiled from source, I've rebuild the system three times to avoid procedures mistakes without results...help and thank in advance,

Simon
reisercl
Posts: 4
Joined: Tue Sep 09, 2008 11:35 am
Location: Zurich, Switzerland

Re: Dual QuadCore CPU

Post by reisercl »

First of all, thanks for this really nice template. It works perfectly for me :)
simonc wrote: Another strange behavior: when I create the graph for the host , cacti prompt me with three blank fields :

- Index Type
- Index Value
- Output Type ID

...
I've had this problem too, but that was my solution:
argon0 wrote: ...
Have you created the individual cpu graphs for the host?

If so you can probably skip this screen (i.e. enter nothing)... Then when the you go to "edit" the graph you can provide the individual data sources...
...
Argon0
simonc
Posts: 4
Joined: Thu Aug 07, 2008 5:36 am

Re: Dual QuadCore CPU

Post by simonc »

reisercl wrote:
I've had this problem too, but that was my solution:


If so you can probably skip this screen (i.e. enter nothing)... Then when the you go to "edit" the graph you can provide the individual data sources...
...
Thanks for the answer.

I try , but all data Source (Cpu0,Cpu1,etc...) has only one possible choice "Server XXX - CPU Utilization (cpu)" , I guess that must be one data source for every CPU (Cpu0,Cpu1....Cpu8) am I wrong?
reisercl
Posts: 4
Joined: Tue Sep 09, 2008 11:35 am
Location: Zurich, Switzerland

Post by reisercl »

I also had this problem.
But when you create/edit the device and add under: "Associated Data Queries" the data query: "SNMP - Get Processor Information" and create a normal Graph for it, you should have the needed data sources:

Image


After this you can delete the normal CPU graph and create the one from the thread here. Then you should be able to choose the CPU0/CPU1/... data sources.
simonc
Posts: 4
Joined: Thu Aug 07, 2008 5:36 am

Post by simonc »

reisercl wrote:
After this you can delete the normal CPU graph and create the one from the thread here. Then you should be able to choose the CPU0/CPU1/... data sources.
Thanks for the info.

In Associated data Queries I add "SNMP - Get Processor Information" with status "Success" [8 Items,8 Rows] that's Ok (I have a dual Xeon Quad motherboard).

When I make "Create Graph for this Host" I got Data Query [ SNMP - Get Processor Information ] with the processor index number from 0 to 7 . That's good I guessed.
I checked CPUs and create graphs but the problem is still there: it doesn't build graphs (data) . Now I have only the dead link of the graph.stop.
However I made a few steps !


EDIT:


In the console -> Collection Methods -> Data Queries -> SNMP - Get Processor Information -> Data input method I have selected "Get Script Server Data (Indexed)

Is that right?


EDIT 2:

In Graph Management In "Supplemental Graph TEmplate Data" -> Cpu Utilization Data Source I have "none" selected and I can't choose nothing like "cpu0" or "CPU1" or similarbut only the classic default data Sources.

This is the relative Debug :

RRDTool Command:

/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="Server XXX - CPU Utilization - CPU|query_hrProcessorFrwID|" \
--rigid \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="percent" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:10: \
--font UNIT:8: \
AREA:#FF0000FF:"CPU Utilization" \
GPRINT::LAST:"Current\:%8.0lf" \
GPRINT::AVERAGE:"Average\:%8.0lf" \
GPRINT::MAX:"Maximum\:%8.0lf"

RRDTool Says:

ERROR: parameter '#FF0000FF' does not represent a number in line AREA:#FF0000FF:CPU Utilization
reisercl
Posts: 4
Joined: Tue Sep 09, 2008 11:35 am
Location: Zurich, Switzerland

Post by reisercl »

simonc wrote: ...
In the console -> Collection Methods -> Data Queries -> SNMP - Get Processor Information -> Data input method I have selected "Get Script Server Data (Indexed)

Is that right?
I have the same :)
simonc wrote: EDIT 2:

In Graph Management In "Supplemental Graph TEmplate Data" -> Cpu Utilization Data Source I have "none" selected and I can't choose nothing like "cpu0" or "CPU1" or similarbut only the classic default data Sources.
...
So you mean, you can't do this?:
Image

That means, that you don't have the data sources like this:
Image

That means, you should add the normal CPU Graph again (That the data sources for each core will be added correctly)

I have to go now, I'll write tomorrow a step-by-step description, how I got it to work.
simonc wrote: RRDTool Says:

ERROR: parameter '#FF0000FF' does not represent a number in line AREA:#FF0000FF:CPU Utilization
#FF0000FF <-- This looks like a color code (perhaps the one for the cpu graphic line), but it is wrong :P there are too much letters (there are 8, ther have to be 6).
#FF0000 works and #0000FF works.
Pulsar
Posts: 10
Joined: Wed Aug 06, 2008 3:49 pm

Post by Pulsar »

My Centos 5.2 box returns something like this:

Code: Select all

snmpwalk -v 2c -c public 127.0.0.1 .1.3.6.1.2.1.25.3.3.1
HOST-RESOURCES-MIB::hrProcessorFrwID.768 = OID: SNMPv2-SMI::zeroDotZero
HOST-RESOURCES-MIB::hrProcessorFrwID.769 = OID: SNMPv2-SMI::zeroDotZero
rafiso
Posts: 20
Joined: Sat Dec 10, 2005 8:54 pm

Linux !! you need net-snmp v5.4 to get separate CPUs infos

Post by rafiso »

Edge wrote:I think I found the problem.. :-(

I guess all you ppl are runing this script on a Windows OS..
What about multi-processor systems?
----------------------------------

Sorry - the CPU statistics (both original percentages, and the newer raw statistics) both refer to the system as a whole. There is currently no way to access individual statistics for a particular processor (except on Solaris systems - see below).

Note that although the Host Resources table includes a hrProcessorTable, the current implementation suffers from two major flaws. Firstly, it doesn't currently recognise the presence of multiple processors, and simply assumes that all systems have precisely one CPU. Secondly, it doesn't calculate the hrProcessorLoad value correctly, and either returns a dummy value (based on the load average) or nothing at all.

As of net-snmp version 5.1, the Solaris operating system delivers some information about multiple CPU's such as speed and type.

Other than that, to monitor a multi-processor system, you're currently out of luck. We hope to address this in a future release of the agent.
Hello everybody,

after hours of heavy researchs I think that I can finally help !

As a linux user I couln't not have CPU infos because the templates "Generic SNMP-enabled Host", "Local Linux Machine", or "ucd/net SNMP Host" didn't give you access to Associated Data Queries "SNMP - Get Processor Information". I had sometimes "[0 Items, 0 Rows]" or the same problem as Edge and others.

The problem was that my LINUX CENTOS 5 server was running net-snmp v5.3. If you uninstall it and then install a beta version of net-snmp v5.5 (and net-snmp-devel), it's working. Beware, to get the Associated Data Queries "SNMP - Get Processor Information" working ("[2 Items, 2 Rows]"), I had to change my server's Host Template to "WINDOWS 2000/XP HOST" then save. This added this damn query :)

In fact I created my device with the logical "Local Linux Machine", then I choose "Generic SNMP-enabled Host", "ucd/net SNMP Host" and finally "WINDOWS 2000/XP HOST" to get : (save at each time)

Associated Graph Templates
1) Host MIB - Logged in Users Not Being Graphed Delete Graph Template Association
2) Host MIB - Processes Not Being Graphed Delete Graph Template Association
3) Linux - Memory Usage Not Being Graphed Delete Graph Template Association
4) ucd/net - CPU Usage Not Being Graphed Delete Graph Template Association
5) ucd/net - Load Average Not Being Graphed Delete Graph Template Association
6) ucd/net - Memory Usage Not Being Graphed Delete Graph Template Association
7) Unix - Load Average Not Being Graphed Delete Graph Template Association
8) Unix - Logged in Users Not Being Graphed Delete Graph Template Association
9) Unix - Processes Not Being Graphed Delete Graph Template Association

Associated Data Queries
1) SNMP - Get Mounted Partitions (Verbose Query) Uptime Goes Backwards Success [27 Items, 9 Rows] Reload Data Query Delete Data Query Association
2) SNMP - Get Processor Information (Verbose Query) Uptime Goes Backwards Success [2 Items, 2 Rows] Reload Data Query Delete Data Query Association
3) SNMP - Interface Statistics (Verbose Query) Uptime Goes Backwards Success [53 Items, 6 Rows] Reload Data Query Delete Data Query Association
4) ucd/net - Get Monitored Partitions (Verbose Query) Uptime Goes Backwards Success [3 Items, 1 Row] Reload Data Query Delete Data Query Association
5) Unix - Get Mounted Partitions (Verbose Query) Uptime Goes Backwards Success [8 Items, 4 Rows] Reload Data Query Delete Data Query Association
Actually I can graph the two differents CPUs and I'll play with the templates from this thead to get both drawn in only one graph.

You can get newer versions of net-snmp here : http://net-snmp.sourceforge.net/wiki/in ... y_Packages

You must of course have a valid configuration for snmp.conf, here is mine to allow easy access everywhere in my network :
rocommunity public
disk /
Thanks you all for your amazing work ! 8)
2x Amd opt. 64bits
4TB raid5 SATA2
Linux CentOS 5.2 final
snmp-net 5.5(dev)
Pulsar
Posts: 10
Joined: Wed Aug 06, 2008 3:49 pm

Post by Pulsar »

It's still not OK :/

Code: Select all

+ Running data query [9].
+ Found type = '6 '[script query].
+ Found data query XML file at '/home/admin/stats.citygirl.pl/resource/script_server/host_cpu.xml'
+ XML file parsed ok.
+ Executing script for list of indexes '/usr/bin/php -q /home/admin/stats.citygirl.pl/scripts/ss_host_cpu.php 127.0.0.1 5 0:161:500:public:::MD5::DES: index'
+ Executing script query '/usr/bin/php -q /home/admin/stats.citygirl.pl/scripts/ss_host_cpu.php 127.0.0.1 5 0:161:500:public:::MD5::DES: query index'
+ Found data query XML file at '/home/admin/stats.citygirl.pl/resource/script_server/host_cpu.xml'
+ Found data query XML file at '/home/admin/stats.citygirl.pl/resource/script_server/host_cpu.xml'
+ Found data query XML file at '/home/admin/stats.citygirl.pl/resource/script_server/host_cpu.xml'

Code: Select all

snmpwalk -V
NET-SNMP version: 5.5.dev
Rael
Cacti User
Posts: 129
Joined: Thu Apr 05, 2007 9:28 am

Post by Rael »

So I couldn't get these graphs working, so I decided to create my own and share them with everyone else (And hopefully you can help me with my problem!)

So I created a script that using an SSH trust relationship will go to the target server and run mpstat.

Here's the script

Code: Select all

#!/bin/bash

# Author: Rael Mussell
# Date: 10/13/2008
# Purpose: mpstat to display graph for each independant CPU.

HOST=$1
OS=`ssh -xq $HOST uname`
TEMPFILE=`mktemp`

if [ $OS = "Linux" ]; then
	RHV=`ssh -xq $HOST cat /etc/redhat-release | grep "release 4" | wc -l`
	NUMCPU=`ssh -xq $HOST cat /proc/cpuinfo | grep processor | awk '{print $3}' | wc -l`
		if [ $NUMCPU -eq 16 ]; then
			if [ $RHV -eq 1 ]; then
				CPUUSE=`ssh -xq $HOST mpstat -P ALL | grep -v all | grep -v CPU | awk '{print $10}' | tail -16 >> $TEMPFILE`
			else
				CPUUSE=`ssh -xq $HOST mpstat -P ALL | grep -v all | grep -v CPU | awk '{print $11}' | tail -16 >> $TEMPFILE`
			fi
				export CPU1=$((100 - `cat $TEMPFILE | head -1 | cut -f1 -d.`))
				export CPU2=$((100 - `cat $TEMPFILE | head -2 | tail -1 | cut -f1 -d.`))
				export CPU3=$((100 - `cat $TEMPFILE | head -3 | tail -1 | cut -f1 -d.`))
				export CPU4=$((100 - `cat $TEMPFILE | head -4 | tail -1 | cut -f1 -d.`))
				export CPU5=$((100 - `cat $TEMPFILE | head -5 | tail -1 | cut -f1 -d.`))
				export CPU6=$((100 - `cat $TEMPFILE | head -6 | tail -1 | cut -f1 -d.`))
				export CPU7=$((100 - `cat $TEMPFILE | head -7 | tail -1 | cut -f1 -d.`))
				export CPU8=$((100 - `cat $TEMPFILE | head -8 | tail -1 | cut -f1 -d.`))
				export CPU9=$((100 - `cat $TEMPFILE | head -9 | tail -1 | cut -f1 -d.`))
				export CPU10=$((100 - `cat $TEMPFILE | head -10 | tail -1 | cut -f1 -d.`))
				export CPU11=$((100 - `cat $TEMPFILE | head -11 | tail -1 | cut -f1 -d.`))
				export CPU12=$((100 - `cat $TEMPFILE | head -12 | tail -1 | cut -f1 -d.`))
				export CPU13=$((100 - `cat $TEMPFILE | head -13 | tail -1 | cut -f1 -d.`))
				export CPU14=$((100 - `cat $TEMPFILE | head -14 | tail -1 | cut -f1 -d.`))
				export CPU15=$((100 - `cat $TEMPFILE | head -15 | tail -1 | cut -f1 -d.`))
				export CPU16=$((100 - `cat $TEMPFILE | head -16 | tail -1 | cut -f1 -d.`))
				echo "CPU1:$CPU1 CPU2:$CPU2 CPU3:$CPU3 CPU4:$CPU4 CPU5:$CPU5 CPU6:$CPU6 CPU7:$CPU7 CPU8:$CPU8 CPU9:$CPU9 CPU10:$CPU10 CPU11:$CPU11 CPU12:$CPU12 CPU13:$CPU13 CPU14:$CPU14 CPU15:$CPU15 CPU16:$CPU16"
				rm $TEMPFILE
		elif [ $NUMCPU -eq 8 ]; then
			if [ $RHV -eq 1 ]; then
				CPUUSE=`ssh -xq $HOST mpstat -P ALL | grep -v all | grep -v CPU | awk '{print $10}' | tail -8 >> $TEMPFILE`
			else
				CPUUSE=`ssh -xq $HOST mpstat -P ALL | grep -v all | grep -v CPU | awk '{print $11}' | tail -8 >> $TEMPFILE`
			fi
				export CPU1=$((100 - `cat $TEMPFILE | head -1 | cut -f1 -d.`))
				export CPU2=$((100 - `cat $TEMPFILE | head -2 | tail -1 | cut -f1 -d.`))
				export CPU3=$((100 - `cat $TEMPFILE | head -3 | tail -1 | cut -f1 -d.`))
				export CPU4=$((100 - `cat $TEMPFILE | head -4 | tail -1 | cut -f1 -d.`))
				export CPU5=$((100 - `cat $TEMPFILE | head -5 | tail -1 | cut -f1 -d.`))
				export CPU6=$((100 - `cat $TEMPFILE | head -6 | tail -1 | cut -f1 -d.`))
				export CPU7=$((100 - `cat $TEMPFILE | head -7 | tail -1 | cut -f1 -d.`))
				export CPU8=$((100 - `cat $TEMPFILE | head -8 | tail -1 | cut -f1 -d.`))
				echo "CPU1:$CPU1 CPU2:$CPU2 CPU3:$CPU3 CPU4:$CPU4 CPU5:$CPU5 CPU6:$CPU6 CPU7:$CPU7 CPU8:$CPU8"
				rm $TEMPFILE
		elif [ $NUMCPU -eq 4 ]; then
			if [ $RHV -eq 1 ]; then
				CPUUSE=`ssh -xq $HOST mpstat -P ALL | grep -v all | grep -v CPU | awk '{print $10}' | tail -4 >> $TEMPFILE`
			else
				CPUUSE=`ssh -xq $HOST mpstat -P ALL | grep -v all | grep -v CPU | awk '{print $11}' | tail -4 >> $TEMPFILE`
			fi
				export CPU1=$((100 - `cat $TEMPFILE | head -1 | cut -f1 -d.`))
				export CPU2=$((100 - `cat $TEMPFILE | head -2 | tail -1 | cut -f1 -d.`))
				export CPU3=$((100 - `cat $TEMPFILE | head -3 | tail -1 | cut -f1 -d.`))
				export CPU4=$((100 - `cat $TEMPFILE | head -4 | tail -1 | cut -f1 -d.`))
				echo "CPU1:$CPU1 CPU2:$CPU2 CPU3:$CPU3 CPU4:$CPU4"
				rm $TEMPFILE
		elif [ $NUMCPU -eq 2 ]; then
			if [ $RHV -eq 1 ]; then
				CPUUSE=`ssh -xq $HOST mpstat -P ALL | grep -v all | grep -v CPU | awk '{print $10}' | tail -2 >> $TEMPFILE`
			else
				CPUUSE=`ssh -xq $HOST mpstat -P ALL | grep -v all | grep -v CPU | awk '{print $11}' | tail -2 >> $TEMPFILE`
			fi
				export CPU1=$((100 - `cat $TEMPFILE | head -1 | cut -f1 -d.`))
				export CPU2=$((100 - `cat $TEMPFILE | head -2 | tail -1 | cut -f1 -d.`))
				echo "CPU1:$CPU1 CPU2:$CPU2"
				rm $TEMPFILE
		fi
elif [ $OS = "SunOS" ]; then
	NUMCPU=`ssh -xq $HOST /usr/bin/mpstat -P ALL | grep -v CPU | wc -l`
		if [ $NUMCPU -eq 16 ]; then
			TEMPFILE=`mktemp`
			CPUUSE=`ssh -xq $HOST mpstat -P ALL | grep -v all | grep -v CPU | awk '{print $16}' | tail -16 >> $TEMPFILE`
				export CPU1=$((100 - `cat $TEMPFILE | head -1`))
				export CPU2=$((100 - `cat $TEMPFILE | head -2 | tail -1`))
				export CPU3=$((100 - `cat $TEMPFILE | head -3 | tail -1`))
				export CPU4=$((100 - `cat $TEMPFILE | head -4 | tail -1`))
				export CPU5=$((100 - `cat $TEMPFILE | head -5 | tail -1`))
				export CPU6=$((100 - `cat $TEMPFILE | head -6 | tail -1`))
				export CPU7=$((100 - `cat $TEMPFILE | head -7 | tail -1`))
				export CPU8=$((100 - `cat $TEMPFILE | head -8 | tail -1`))
				export CPU9=$((100 - `cat $TEMPFILE | head -9 | tail -1`))
				export CPU10=$((100 - `cat $TEMPFILE | head -10 | tail -1`))
				export CPU11=$((100 - `cat $TEMPFILE | head -11 | tail -1`))
				export CPU12=$((100 - `cat $TEMPFILE | head -12 | tail -1`))
				export CPU13=$((100 - `cat $TEMPFILE | head -13 | tail -1`))
				export CPU14=$((100 - `cat $TEMPFILE | head -14 | tail -1`))
				export CPU15=$((100 - `cat $TEMPFILE | head -15 | tail -1`))
				export CPU16=$((100 - `cat $TEMPFILE | head -16 | tail -1`))
				echo "CPU1:$CPU1 CPU2:$CPU2 CPU3:$CPU3 CPU4:$CPU4 CPU5:$CPU5 CPU6:$CPU6 CPU7:$CPU7 CPU8:$CPU8 CPU9:$CPU9 CPU10:$CPU10 CPU11:$CPU11 CPU12:$CPU12 CPU13:$CPU13 CPU14:$CPU14 CPU15:$CPU15 CPU16:$CPU16"
				rm $TEMPFILE
		elif [ $NUMCPU -eq 8 ]; then
			TEMPFILE=`mktemp`
			CPUUSE=`ssh -xq $HOST mpstat -P ALL | grep -v all | grep -v CPU | awk '{print $16}' | tail -8 >> $TEMPFILE`
				export CPU1=$((100 - `cat $TEMPFILE | head -1`))
				export CPU2=$((100 - `cat $TEMPFILE | head -2 | tail -1`))
				export CPU3=$((100 - `cat $TEMPFILE | head -3 | tail -1`))
				export CPU4=$((100 - `cat $TEMPFILE | head -4 | tail -1`))
				export CPU5=$((100 - `cat $TEMPFILE | head -5 | tail -1`))
				export CPU6=$((100 - `cat $TEMPFILE | head -6 | tail -1`))
				export CPU7=$((100 - `cat $TEMPFILE | head -7 | tail -1`))
				export CPU8=$((100 - `cat $TEMPFILE | head -8 | tail -1`))
				echo "CPU1:$CPU1 CPU2:$CPU2 CPU3:$CPU3 CPU4:$CPU4 CPU5:$CPU5 CPU6:$CPU6 CPU7:$CPU7 CPU8:$CPU8"
				rm $TEMPFILE
		elif [ $NUMCPU -eq 4 ]; then
			TEMPFILE=`mktemp`
			CPUUSE=`ssh -xq $HOST mpstat -P ALL | grep -v all | grep -v CPU | awk '{print $16}' | tail -4 >> $TEMPFILE`
				export CPU1=$((100 - `cat $TEMPFILE | head -1`))
				export CPU2=$((100 - `cat $TEMPFILE | head -2 | tail -1`))
				export CPU3=$((100 - `cat $TEMPFILE | head -3 | tail -1`))
				export CPU4=$((100 - `cat $TEMPFILE | head -4 | tail -1`))
				echo "CPU1:$CPU1 CPU2:$CPU2 CPU3:$CPU3 CPU4:$CPU4"
				rm $TEMPFILE
		elif [ $NUMCPU -eq 2 ]; then
			TEMPFILE=`mktemp`
			CPUUSE=`ssh -xq $HOST mpstat -P ALL | grep -v all | grep -v CPU | awk '{print $16}' | tail -2 >> $TEMPFILE`
				export CPU1=$((100 - `cat $TEMPFILE | head -1`))
				export CPU2=$((100 - `cat $TEMPFILE | head -2 | tail -1`))
				echo "CPU1:$CPU1 CPU2:$CPU2"
				rm $TEMPFILE
		fi
fi
From here I make a DIQ 'Script/Command' and referance these various Templates for 2/4/8/16 CPU servers. So, everything is working as I expect it but the first custom output is always 0. In the log files it comes back with a valid integer, however in the data source debug it shows "U" for the first value. ???

I'm stummped.

Here are the templates.
Attachments
cacti_graph_template_mpstat-2.xml
(11.22 KiB) Downloaded 1564 times
cacti_graph_template_mpstat-4.xml
(18.08 KiB) Downloaded 1433 times
cacti_graph_template_mpstat-8.xml
(31.88 KiB) Downloaded 1499 times
cacti_graph_template_mpstat-16.xml
(59.51 KiB) Downloaded 1800 times
StRiP3
Posts: 4
Joined: Sun May 27, 2007 5:48 pm
Location: Haarlem, The Netherlands

Post by StRiP3 »

When I downloaded the multi.2.4.8.cpu.zip on page 9, it didn't work 'out of the box'.

I have imported the XML files in Cacti, this was going fine, but when I added the Graph Template called 'Host MIB - Multi CPU Utilization on 2 Processor Box' to my device:

Image

Clicked Add and then clicked 'Create Graphs for this Host' and got this:

Image

So in someway it was not working.

First off all, I want to thank the maker of these files and all the credits goes out to him, but I have changed some things.. for example:

In the graph there is a 'Mean CPU', I'm from the Netherlands and I didn't really know the meaning of 'mean' in this situation. I know I can be mean at someone but that shouldn't be right in this situation :) My dictionairy said that 'mean' is the same as 'average'.

But when we look in the graph and the statistics under the graph, we can see that 'Mean CPU' is not showing the average of the 2 CPU's:

Image

So I have created a new CDEF which will add statistics of the 2 CPU's and then divide it in 2 so you got the average of the 2 CPU's.

I also changed the text 'Mean CPU' into 'Average', so people like me don't have to get their dictionairy ;), and I changed the colour of the average graph a bit darker because it was a bit hard to see on my screen..

And I added the 'average' statistics under the graph in text format and I renamed the Template to 'CPU Utilization (2 CPU's)' because I want it to be on the top of the device page ;)

The graph now looks like this:

Image

You can download the 2 CPU version here, maybe I will make the 4 CPU later :)

Can someone give this one a try to see if it works?
Attachments
cacti_graph_template_cpu_utilization_2_cpus_v2.0.xml
(15.83 KiB) Downloaded 2148 times
Pulsar
Posts: 10
Joined: Wed Aug 06, 2008 3:49 pm

Post by Pulsar »

Code: Select all

RRDTool Command:

/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="localhost - 2 CPU Utilization" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:10: \
--font UNIT:8: \
DEF:a="/home/admin/stats.citygirl.pl/rra/localhost_cpu_69.rrd":cpu:AVERAGE \
CDEF:cdefa=TIME,1224540938,GT,a,a,UN,0,a,IF,IF,2,/ \
AREA:cdefa#AFECEDB2:"Average"  \
GPRINT:cdefa:LAST:"Current\:%8.2lf %%"  \
GPRINT:cdefa:AVERAGE:"Average\:%8.2lf %%"  \
GPRINT:cdefa:MIN:"Min\:%8.2lf %%"  \
GPRINT:cdefa:MAX:"Max\:%8.2lf %%\n"  \
LINE1:a#0000FFFF:"CPU0"  \
GPRINT:a:LAST:"   Current\:%8.2lf %%"  \
GPRINT:a:AVERAGE:"Average\:%8.2lf %%"  \
GPRINT:a:MIN:"Min\:%8.2lf %%"  \
GPRINT:a:MAX:"Max\:%8.2lf %%\n"  \
LINE1:a#00A348FF:"CPU1"  \
GPRINT:a:LAST:"   Current\:%8.2lf %%"  \
GPRINT:a:AVERAGE:"Average\:%8.2lf %%"  \
GPRINT:a:MIN:"Min\:%8.2lf %%"  \
GPRINT:a:MAX:"Max\:%8.2lf %%\n" 

RRDTool Says:

ERROR: opening '/home/admin/stats.citygirl.pl/rra/localhost_cpu_69.rrd': No such file or directory
Evgen787
Posts: 18
Joined: Fri Oct 31, 2008 10:52 pm

:)

Post by Evgen787 »

Hi all, a have some problem in monitoring 8 CPU.


I use this template :
cacti_graph_template_multi_cpu_utilization_on_8_processor_box_118.xml

Code: Select all

/usr/local/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="Multi CPU Utilization on Server2" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="" \
--slope-mode \
DEF:a="/usr/local/www/cacti/rra/server2_cpu_184.rrd":cpu:AVERAGE \
DEF:b="/usr/local/www/cacti/rra/server2_cpu0_202.rrd":cpu0:AVERAGE \
DEF:c="/usr/local/www/cacti/rra/server2_cpu_185.rrd":cpu:AVERAGE \
DEF:d="/usr/local/www/cacti/rra/server2_cpu1_203.rrd":cpu1:AVERAGE \
DEF:e="/usr/local/www/cacti/rra/server2_cpu_186.rrd":cpu:AVERAGE \
DEF:f="/usr/local/www/cacti/rra/server2_cpu2_204.rrd":cpu2:AVERAGE \
DEF:g="/usr/local/www/cacti/rra/server2_cpu_187.rrd":cpu:AVERAGE \
DEF:h="/usr/local/www/cacti/rra/server2_cpu_188.rrd":cpu:AVERAGE \
DEF:i="/usr/local/www/cacti/rra/server2_cpu_189.rrd":cpu:AVERAGE \
DEF:j="/usr/local/www/cacti/rra/server2_cpu_190.rrd":cpu:AVERAGE \
DEF:ba="/usr/local/www/cacti/rra/server2_cpu_191.rrd":cpu:AVERAGE \
CDEF:cdefa=a,b,+,c,+,d,+,e,+,f,+,g,+,h,+,8,/ \
AREA:cdefa#F9FD5F:"Mean CPU\:"  \
GPRINT:cdefa:LAST:"Current\:%8.2lf %%"  \
GPRINT:cdefa:AVERAGE:"Mean\:%8.2lf %%"  \
GPRINT:cdefa:MAX:"Max\:%8.2lf %%\n"  \
LINE1:a#0000FF:"CPU0\:"  \
GPRINT:b:LAST:"    Current\:%8.2lf %%"  \
GPRINT:a:AVERAGE:"    Mean\:%8.2lf %%"  \
GPRINT:b:MAX:"    Max\:%8.2lf %%\n"  \
LINE1:c#00A348:"CPU1\:"  \
GPRINT:d:LAST:"    Current\:%8.2lf %%"  \
GPRINT:c:AVERAGE:"    Mean\:%8.2lf %%"  \
GPRINT:d:MAX:"    Max\:%8.2lf %%\n"  \
LINE1:e#C4FD3D:"CPU2\:"  \
GPRINT:e:LAST:"    Current\:%8.2lf %%"  \
GPRINT:e:AVERAGE:"Mean\:%8.2lf %%"  \
GPRINT:f:MAX:"Max\:%8.2lf %%\n"  \
LINE1:g#FF0000:"CPU3\:"  \
GPRINT:g:LAST:"    Current\:%8.2lf %%"  \
GPRINT:g:AVERAGE:"Mean\:%8.2lf %%"  \
GPRINT:g:MAX:"Max\:%8.2lf %%\n"  \
LINE1:h#000000:"CPU4\:"  \
GPRINT:h:LAST:"    Current\:%8.2lf %%"  \
GPRINT:h:AVERAGE:"Mean\:%8.2lf %%"  \
GPRINT:h:MAX:"Max\:%8.2lf %%\n"  \
LINE1:i#00BED9:"CPU5\:"  \
GPRINT:i:LAST:"    Current\:%8.2lf %%"  \
GPRINT:i:AVERAGE:"Mean\:%8.2lf %%"  \
GPRINT:i:MAX:"Max\:%8.2lf %%\n"  \
LINE1:j#FF00FF:"CPU6\:"  \
GPRINT:j:LAST:"    Current\:%8.2lf %%"  \
GPRINT:j:AVERAGE:"Mean\:%8.2lf %%"  \
GPRINT:j:MAX:"Max\:%8.2lf %%\n"  \
LINE1:ba#AAABA1:"CPU7\:"  \
GPRINT:ba:LAST:"    Current\:%8.2lf %%"  \
GPRINT:ba:AVERAGE:"Mean\:%8.2lf %%"  \
GPRINT:ba:MAX:"Max\:%8.2lf %%" 
RRDTool Says:
ERROR: opening '/usr/local/www/cacti/rra/server2_cpu0_202.rrd': No such file or directory
But 2 CPU graphed OK. :)
jwilda
Posts: 7
Joined: Wed Oct 22, 2008 10:32 am
Location: Tampa, FL

is there a version for N number of cpus?

Post by jwilda »

Has anyone been able to make this work for any number of CPUs?
Achromatic
Posts: 3
Joined: Mon Nov 24, 2008 10:06 pm

Post by Achromatic »

Rael, I started setting up your mpstat scripts, and I'm getting output like this:

CPU1:1 CPU2:1 CPU3:6 CPU4:3 CPU5:12 CPU6:2 CPU7:5 CPU8:1

but my graphs are showing everything as NaN.

I notice in Data Input, that all the output fields are showing as "not in use":

Name Field Order Friendly Name Update RRA
CPU1 0 (Not In Use)
...
CPU8 0 (Not In Use)

and suspect that this is my issue. Can you, or anyone, point me to how to tweak this sufficient that it works?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest