SNMP based template for memory / swap usage on a Unix host

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

Moderators: Developers, Moderators

User avatar
phalek
Developer
Posts: 2838
Joined: Thu Jan 31, 2008 6:39 am
Location: Kressbronn, Germany
Contact:

Post by phalek »

Easy.

The following line is wrong:

Code: Select all

..
CDEF:cdefa=g,e,-,c,-,a,-,1024,* \
...
Basically if you "translate" this the calculation is

Code: Select all

mem_used (cdefa) = ( mem_cache(min) - mem_cache(average) - mem_buffers (min) - mem_buffers (average) ) * 1024 
but it should be

Code: Select all

mem_used (cdefa) = ( mem_total(average) - mem_free(average) - mem_cache(average) - mem_buffers(average) ) * 1024
which again "translates" into:

Code: Select all

CDEF:cdefa=bc,i,-,e,-,a,-,1024,*
so you need to change the CDEf to that value for the mem used to show up correctly ...

( Go to Management -> Graph Management -> CDEFs
Select the Memory Used CDEF to change that )
agentc0re
Posts: 9
Joined: Sat Feb 16, 2008 4:20 pm

Post by agentc0re »

Thank you very much. I guess the one thing i don't understand is how the cdef gets writen versus the actual equation.

bc,i > doesn't really make sense to me. would you mind pointing me where i could read about it or tell me yourself?
User avatar
phalek
Developer
Posts: 2838
Joined: Thu Jan 31, 2008 6:39 am
Location: Kressbronn, Germany
Contact:

Post by phalek »

Note sure what you're after :-)

But I've rertieved those "letters" from the DEF section you posted:

Code: Select all

DEF:a="/opt/cacti/rra/bobafett_mem_buffers_349.rrd":mem_buffers:AVERAGE \
DEF:b="/opt/cacti/rra/bobafett_mem_buffers_349.rrd":mem_buffers:LAST \
DEF:c="/opt/cacti/rra/bobafett_mem_buffers_349.rrd":mem_buffers:MIN \
DEF:d="/opt/cacti/rra/bobafett_mem_buffers_349.rrd":mem_buffers:MAX \
DEF:e="/opt/cacti/rra/bobafett_mem_cache_350.rrd":mem_cache:AVERAGE \
DEF:f="/opt/cacti/rra/bobafett_mem_cache_350.rrd":mem_cache:LAST \
DEF:g="/opt/cacti/rra/bobafett_mem_cache_350.rrd":mem_cache:MIN \
DEF:h="/opt/cacti/rra/bobafett_mem_cache_350.rrd":mem_cache:MAX \
DEF:i="/opt/cacti/rra/bobafett_mem_free_351.rrd":mem_free:AVERAGE \
DEF:j="/opt/cacti/rra/bobafett_mem_free_351.rrd":mem_free:LAST \
DEF:ba="/opt/cacti/rra/bobafett_mem_free_351.rrd":mem_free:MIN \
DEF:bb="/opt/cacti/rra/bobafett_mem_free_351.rrd":mem_free:MAX \
DEF:bc="/opt/cacti/rra/bobafett_mem_total_352.rrd":mem_total:AVERAGE \
DEF:bd="/opt/cacti/rra/bobafett_mem_total_352.rrd":mem_total:MAX \ 
bc is therefore mem_total:AVERAGE
i is mem_free:AVERAGE
Findarato
Posts: 29
Joined: Wed Feb 06, 2008 2:56 pm

Post by Findarato »

I just tried to update your templates and got Error:
Error: XML: Hash version does not exist.
User avatar
RCK
Cacti User
Posts: 54
Joined: Fri Jan 26, 2007 12:38 pm

Post by RCK »

Thanks for those templates :)
Cacti: 0.8.7g | Spine: 0.8.7g
Plugins: RRDclean - Weathermap - Thold - Realtime
My Template: ApacheStats 0.8.2 (multiple RRD, Low disk usage, Script Server)
limaunion
Posts: 20
Joined: Tue Jul 05, 2005 10:44 am

Post by limaunion »

Thanks phalek, your CDEF suggestion fixed the problem I was having with 'free memory' showing negative values.

The main template should be updated to reflect this fix.
Best Regards!
User avatar
sumsum
Cacti User
Posts: 68
Joined: Mon Apr 26, 2004 7:18 am
Location: Switzerland
Contact:

Post by sumsum »

i followed the instruction of phalek and now i get the error

Code: Select all

ERROR: invalid rpn expression in: bc,i,-,e,-,a,-,1024,*
debug :

Code: Select all

  RRDTool Command:

/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="automatix.dmd2.ch - Memory Usage" \
--base=1024 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="bytes" \
--slope-mode \
--font TITLE:10: \
--font AXIS:8: \
--font LEGEND:8: \
--font UNIT:8: \
DEF:a="/var/www/systemstats087b/rra/automatix_dmd2_ch_mem_free_205.rrd":mem_free:AVERAGE \
DEF:b="/var/www/systemstats087b/rra/automatix_dmd2_ch_mem_free_205.rrd":mem_free:LAST \
DEF:c="/var/www/systemstats087b/rra/automatix_dmd2_ch_mem_free_205.rrd":mem_free:MIN \
DEF:d="/var/www/systemstats087b/rra/automatix_dmd2_ch_mem_free_205.rrd":mem_free:MAX \
DEF:e="/var/www/systemstats087b/rra/automatix_dmd2_ch_mem_total_206.rrd":mem_total:AVERAGE \
DEF:f="/var/www/systemstats087b/rra/automatix_dmd2_ch_mem_total_206.rrd":mem_total:LAST \
CDEF:cdefa=bc,i,-,e,-,a,-,1024,* \
CDEF:cdeff=a,1024,* \
CDEF:cdefg=b,1024,* \
CDEF:cdefi=c,1024,* \
CDEF:cdefj=d,1024,* \
CDEF:cdefba=e,1024,* \
CDEF:cdefbb=f,1024,* \
AREA:cdefa#DE0056FF:"Memory Used"  \
GPRINT:cdefa:LAST:"   Current\:%8.2lf %s"  \
GPRINT:cdefa:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:cdefa:MIN:"Min\:%8.2lf %s"  \
GPRINT:cdefa:MAX:"Max\:%8.2lf %s\n"  \
AREA:cdeff#FFC3C0FF:"Memory Free":STACK \
GPRINT:cdefg:LAST:"   Current\:%8.2lf %s"  \
GPRINT:cdeff:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:cdefi:MIN:"Min\:%8.2lf %s"  \
GPRINT:cdefj:MAX:"Max\:%8.2lf %s\n"  \
LINE1:cdefba#000000FF:"Memory Total"  \
GPRINT:cdefbb:LAST:"  Current\:%8.2lf %s" 

RRDTool Says:

ERROR: invalid rpn expression in: bc,i,-,e,-,a,-,1024,*

did I missed something ?
regards
tom
http://www.lounge-radio.com/
plotting4fun
Posts: 24
Joined: Thu Dec 11, 2008 10:42 am

Re: SNMP based template for memory / swap usage on a Unix ho

Post by plotting4fun »

fmangeant wrote: Image
This template is awesome, thanks !
smmpia
Posts: 2
Joined: Tue Feb 24, 2009 2:21 pm

Post by smmpia »

Hi,
I have few servers showing NAN for Swap value. and i also have hew server which is using same script and showing value for "SWAP" in the graph. I am totally new to this field. and no idea where to start.
If any of you direct me, it will be great help for me.

Thanks in advance.
I also have opened new forum also.
index name is below:
------------------------

Cacti grapg showing NAN for Swap Current in the Graph
ianacces
Posts: 2
Joined: Mon Mar 16, 2009 11:56 pm

Post by ianacces »

Hello,

I'm having the same problem as sumsum had. If someone could point me in the right direction I'd be very grateful:

Code: Select all

/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="dev-gw - Memory Usage" \
--base=1024 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="bytes" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:10: \
--font UNIT:8: \
DEF:a="/var/www/cacti/rra/dev-gw_mem_buffers_74.rrd":mem_buffers:AVERAGE \
DEF:b="/var/www/cacti/rra/dev-gw_mem_cache_75.rrd":mem_cache:AVERAGE \
DEF:c="/var/www/cacti/rra/dev-gw_mem_free_76.rrd":mem_free:AVERAGE \
DEF:d="/var/www/cacti/rra/dev-gw_mem_total_77.rrd":mem_total:AVERAGE \
CDEF:cdefa=bc,i,-,e,-,a,-,1024,* \
CDEF:cdeff=a,1024,* \
CDEF:cdefba=b,1024,* \
CDEF:cdefbf=c,1024,* \
CDEF:cdefca=d,1024,* \
AREA:cdefa#FFF200FF:"Memory Used"  \
GPRINT:cdefa:LAST:"   Current\:%8.2lf %s"  \
GPRINT:cdefa:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:cdefa:MIN:"Min\:%8.2lf %s"  \
GPRINT:cdefa:MAX:"Max\:%8.2lf %s\n"  \
AREA:cdeff#6EA100FF:"Memory Buffers":STACK \
GPRINT:cdeff:LAST:"Current\:%8.2lf %s"  \
GPRINT:cdeff:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:cdeff:MIN:"Min\:%8.2lf %s"  \
GPRINT:cdeff:MAX:"Max\:%8.2lf %s\n"  \
AREA:cdefba#942D0CFF:"Memory Cached":STACK \
GPRINT:cdefba:LAST:" Current\:%8.2lf %s"  \
GPRINT:cdefba:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:cdefba:MIN:"Min\:%8.2lf %s"  \
GPRINT:cdefba:MAX:"Max\:%8.2lf %s\n"  \
AREA:cdefbf#12B3B5FF:"Memory Free":STACK \
GPRINT:cdefbf:LAST:"   Current\:%8.2lf %s"  \
GPRINT:cdefbf:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:cdefbf:MIN:"Min\:%8.2lf %s"  \
GPRINT:cdefbf:MAX:"Max\:%8.2lf %s\n"  \
LINE1:cdefca#000000FF:"Memory Total"  \
GPRINT:cdefca:MAX:"  Current\:%8.2lf %s" 

RRDTool Says:

ERROR: invalid rpn expression in: bc,i,-,e,-,a,-,1024,*
Thanks in advance
ianacces
Posts: 2
Joined: Mon Mar 16, 2009 11:56 pm

Post by ianacces »

OK, I *think* I've worked it out. My CDEF was not referencing my DEFs. It was attempting to reference non-existent DEFs.
User avatar
phalek
Developer
Posts: 2838
Joined: Thu Jan 31, 2008 6:39 am
Location: Kressbronn, Germany
Contact:

Post by phalek »

yes, your cdef should be:
DEF:a="/var/www/cacti/rra/dev-gw_mem_buffers_74.rrd":mem_buffers:AVERAGE \
DEF:b="/var/www/cacti/rra/dev-gw_mem_cache_75.rrd":mem_cache:AVERAGE \
DEF:c="/var/www/cacti/rra/dev-gw_mem_free_76.rrd":mem_free:AVERAGE \
DEF:d="/var/www/cacti/rra/dev-gw_mem_total_77.rrd":mem_total:AVERAGE \
CDEF:cdefa=d,c,-,b,-,a,-,1024,* \
or translated:
mem_used (cdefa) = ( mem_total(d) - mem_free(c) -mem_cache(b) - mem_buffers(a) ) * 1024
Greetings,
Phalek
---
Need more help ? Read the Cacti documentation or my new Cacti 1.x Book
Need on-site support ? Look here Cacti Workshop
Need professional Cacti support ? Look here CereusService
---
Plugins : CereusReporting
User avatar
phalek
Developer
Posts: 2838
Joined: Thu Jan 31, 2008 6:39 am
Location: Kressbronn, Germany
Contact:

Post by phalek »

sumsum wrote:i followed the instruction of phalek and now i get the error

Code: Select all

ERROR: invalid rpn expression in: bc,i,-,e,-,a,-,1024,*

Code: Select all

DEF:a="/var/www/systemstats087b/rra/automatix_dmd2_ch_mem_free_205.rrd":mem_free:AVERAGE \
DEF:b="/var/www/systemstats087b/rra/automatix_dmd2_ch_mem_free_205.rrd":mem_free:LAST \
DEF:c="/var/www/systemstats087b/rra/automatix_dmd2_ch_mem_free_205.rrd":mem_free:MIN \
DEF:d="/var/www/systemstats087b/rra/automatix_dmd2_ch_mem_free_205.rrd":mem_free:MAX \
DEF:e="/var/www/systemstats087b/rra/automatix_dmd2_ch_mem_total_206.rrd":mem_total:AVERAGE \
DEF:f="/var/www/systemstats087b/rra/automatix_dmd2_ch_mem_total_206.rrd":mem_total:LAST \
CDEF:cdefa=bc,i,-,e,-,a,-,1024,* \
That's wrong, you don't have a DEF:i and the others reference wrong numbers.

You want :

Code: Select all

CDEF:cdefa=e,a,-,1024,*
or translated:

mem_used (cdefa) = ( mem_total(e) - mem_free(a) ) * 1024


Please guys, don't just copy and paste , think about what you want, the letters represent the different DEF statements, and there's a nice human readable string behind all of these ...
Greetings,
Phalek
---
Need more help ? Read the Cacti documentation or my new Cacti 1.x Book
Need on-site support ? Look here Cacti Workshop
Need professional Cacti support ? Look here CereusService
---
Plugins : CereusReporting
jfxura
Posts: 2
Joined: Thu Dec 17, 2009 1:46 am
Location: India
Contact:

Template broke after upgrade to 0.8.7e

Post by jfxura »

I've just upgraded to Cacti 0.8.7e. The Swap / Memory usage for unix graphs are now reporting "invalid rpn" error messages.

From 0.8.7e instance

Code: Select all

/usr/local/rrdtool-1.2.19/bin/rrdtool graph - \
--imgformat=PNG \
--start=1260987146 \
--end=1261030346 \
--title="XXXX - Memory Usage" \
--base=1024 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
COMMENT:"From 2009/12/16 23\:42\:26 To 2009/12/17 11\:42\:26\c" \
COMMENT:"  \n" \
--vertical-label="bytes" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:10: \
--font UNIT:8: \
DEF:a="XXXX-mem_free_6074.rrd":mem_free:AVERAGE \
DEF:b="XXXX-mem_total_6075.rrd":mem_total:AVERAGE \
CDEF:cdefa=c,a,-,1024,* \
CDEF:cdeff=a,1024,* \
CDEF:cdefba=b,1024,* \
AREA:cdefa#DE0056FF:"Memory Used"  \
GPRINT:cdefa:LAST:"   Current\:%8.2lf %s"  \
GPRINT:cdefa:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:cdefa:MIN:"Min\:%8.2lf %s"  \
GPRINT:cdefa:MAX:"Max\:%8.2lf %s\n"  \
AREA:cdeff#FFC3C0FF:"Memory Free":STACK \
GPRINT:cdeff:LAST:"   Current\:%8.2lf %s"  \
GPRINT:cdeff:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:cdeff:MIN:"Min\:%8.2lf %s"  \
GPRINT:cdeff:MAX:"Max\:%8.2lf %s\n"  \
LINE1:cdefba#000000FF:"Memory Total"  \
GPRINT:cdefba:LAST:"  Current\:%8.2lf %s"

From 0.8.7b instance

Code: Select all

/usr/local/rrdtool-1.2.19/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="XXXX - Memory Usage" \
--base=1024 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="bytes" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:10: \
--font UNIT:8: \
DEF:a="XXXX_mem_free_2451.rrd":mem_free:AVERAGE \
DEF:b="XXXX_mem_free_2451.rrd":mem_free:LAST \
DEF:c="XXXX_mem_free_2451.rrd":mem_free:MAX \
DEF:d="XXXX_mem_total_2452.rrd":mem_total:AVERAGE \
DEF:e="XXXX_mem_total_2452.rrd":mem_total:LAST \
CDEF:cdefa=d,a,-,1024,* \
CDEF:cdeff=a,1024,* \
CDEF:cdefg=b,1024,* \
CDEF:cdefj=c,1024,* \
CDEF:cdefba=d,1024,* \
CDEF:cdefbb=e,1024,* \
AREA:cdefa#DE0056FF:"Memory Used"  \
GPRINT:cdefa:LAST:"   Current\:%8.2lf %s"  \
GPRINT:cdefa:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:cdefa:MIN:"Min\:%8.2lf %s"  \
GPRINT:cdefa:MAX:"Max\:%8.2lf %s\n"  \
AREA:cdeff#FFC3C0FF:"Memory Free":STACK \
GPRINT:cdefg:LAST:"   Current\:%8.2lf %s"  \
GPRINT:cdeff:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:cdeff:MIN:"Min\:%8.2lf %s"  \
GPRINT:cdefj:MAX:"Max\:%8.2lf %s\n"  \
LINE1:cdefba#000000FF:"Memory Total"  \
GPRINT:cdefbb:LAST:"  Current\:%8.2lf %s"
Some of the DEFs vanished after the upgrade to 0.8.7e ..
User avatar
phalek
Developer
Posts: 2838
Joined: Thu Jan 31, 2008 6:39 am
Location: Kressbronn, Germany
Contact:

Post by phalek »

The following line

Code: Select all

CDEF:cdefa=c,a,-,1024,* \ 
should be

Code: Select all

CDEF:cdefa=b,a,-,1024,* \ 
other than that it looks like the two graps are from different templates
Greetings,
Phalek
---
Need more help ? Read the Cacti documentation or my new Cacti 1.x Book
Need on-site support ? Look here Cacti Workshop
Need professional Cacti support ? Look here CereusService
---
Plugins : CereusReporting
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests