Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Tue Jun 27, 2017 7:20 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 38 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: SNMP based template for memory / swap usage on a Unix host
PostPosted: Tue Feb 05, 2008 9:37 am 
Offline
Cacti Guru User
User avatar

Joined: Fri Sep 19, 2003 8:36 am
Posts: 2326
Location: Sophia-Antipolis, France
Edit : these templates now work with Cacti 0.8.7b, thanks to phalek

Hi

here are some templates for memory & swap under Unix; they use SNMP queries only.

The ucd/net - Memory Usage (Linux) graph template works only with Linux hosts, but the ucd/net - Memory Usage and ucd/net - Swap Usage graph templates work with any Unix system running Net-SNMP (including Linux).

These templates were exported from a Cacti 0.8.7a installation, so you need at least this version.

Image

Image

Image

Beware when importing these templates, I'm using "large" RRA definitions...


Attachments:
cacti_graph_template_ucdnet_-_memory_usage_linux.xml [34.01 KiB]
Downloaded 4143 times
cacti_graph_template_ucdnet_-_memory_usage_unix.xml [21.55 KiB]
Downloaded 2613 times
cacti_graph_template_ucdnet_-_swap_usage.xml [21.06 KiB]
Downloaded 3014 times

_________________

HOWTOs :
Templates :


Last edited by fmangeant on Wed Apr 02, 2008 9:45 am, edited 2 times in total.
Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 06, 2008 3:03 pm 
Offline

Joined: Wed Feb 06, 2008 2:56 pm
Posts: 29
Having a little issue with your graphs, using 8.7a

as you can see the graphs are well not exactly working correctly. I am not exactly sure what the issue is.
Image

Image

The totals are correct for both graphs, just the rest are not.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 07, 2008 3:17 am 
Offline
Cacti Guru User
User avatar

Joined: Fri Sep 19, 2003 8:36 am
Posts: 2326
Location: Sophia-Antipolis, France
Hi

did you apply the first patch available here ?

_________________

HOWTOs :
Templates :


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 07, 2008 10:44 am 
Offline

Joined: Wed Feb 06, 2008 2:56 pm
Posts: 29
I had not applied those patches. After applying them the Pink graph started working, but not the more in depth Linux one. All the hosts being graphed this way are running Fedora 7/8 and the newest Net-SNMP.

I have attached what the graph looks like ATM, that I am having issue with. I added the graph of one of our servers running F7, the one from "Auto1" is running F8 if that matters, both have the same version of NET-SNMP.


Attachments:
mem usage.png
mem usage.png [ 33.12 KiB | Viewed 36710 times ]
memory 2.png
memory 2.png [ 37.01 KiB | Viewed 36710 times ]
Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 16, 2008 4:28 pm 
Offline

Joined: Sat Feb 16, 2008 4:20 pm
Posts: 9
Hi, first i would like to thank you for making these graphs! :) Awesome work.
I am having some issues with the linux one though. I am using latest 8.7b.
it imports just fine and creates the RRD fine as well. However the used memory shows a negative number. when i look in Graph Templates and click on ucd/net - memory usage (linux), the first 5 Items for Memory used have NO TASK.
I have searched the forums for a resolution but found that everyone got it fixed for patches for 8.7a but im using b which should have those fixes already.

What are your suggestions?

Code:
[email protected]:~# snmpwalk -v 1 -c public localhost memory

UCD-SNMP-MIB::memIndex.0 = INTEGER: 0

UCD-SNMP-MIB::memErrorName.0 = STRING: swap

UCD-SNMP-MIB::memTotalSwap.0 = INTEGER: 1831400 kB

UCD-SNMP-MIB::memAvailSwap.0 = INTEGER: 1831400 kB

UCD-SNMP-MIB::memTotalReal.0 = INTEGER: 2070608 kB

UCD-SNMP-MIB::memAvailReal.0 = INTEGER: 1543512 kB

UCD-SNMP-MIB::memTotalFree.0 = INTEGER: 3374912 kB

UCD-SNMP-MIB::memMinimumSwap.0 = INTEGER: 16000 kB

UCD-SNMP-MIB::memShared.0 = INTEGER: 0 kB

UCD-SNMP-MIB::memBuffer.0 = INTEGER: 240 kB

UCD-SNMP-MIB::memCached.0 = INTEGER: 407188 kB

UCD-SNMP-MIB::memSwapError.0 = INTEGER: noError(0)

UCD-SNMP-MIB::memSwapErrorMsg.0 = STRING:

[email protected]:~# snmpwalk -v 2c -c public localhost memory

UCD-SNMP-MIB::memIndex.0 = INTEGER: 0

UCD-SNMP-MIB::memErrorName.0 = STRING: swap

UCD-SNMP-MIB::memTotalSwap.0 = INTEGER: 1831400 kB

UCD-SNMP-MIB::memAvailSwap.0 = INTEGER: 1831400 kB

UCD-SNMP-MIB::memTotalReal.0 = INTEGER: 2070608 kB

UCD-SNMP-MIB::memAvailReal.0 = INTEGER: 1526740 kB

UCD-SNMP-MIB::memTotalFree.0 = INTEGER: 3358140 kB

UCD-SNMP-MIB::memMinimumSwap.0 = INTEGER: 16000 kB

UCD-SNMP-MIB::memShared.0 = INTEGER: 0 kB

UCD-SNMP-MIB::memBuffer.0 = INTEGER: 240 kB

UCD-SNMP-MIB::memCached.0 = INTEGER: 407220 kB

UCD-SNMP-MIB::memSwapError.0 = INTEGER: noError(0)

UCD-SNMP-MIB::memSwapErrorMsg.0 = STRING:



Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 17, 2008 3:28 am 
Offline
Cacti Guru User
User avatar

Joined: Fri Sep 19, 2003 8:36 am
Posts: 2326
Location: Sophia-Antipolis, France
I've not tried this template on 0.8.7b, will do tomorrow.

_________________

HOWTOs :
Templates :


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 19, 2008 3:26 am 
Offline
Cacti Guru User
User avatar

Joined: Fri Sep 19, 2003 8:36 am
Posts: 2326
Location: Sophia-Antipolis, France
You're riight, it does not work with 0.8.7b

I've opened bug #1187

_________________

HOWTOs :
Templates :


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 19, 2008 8:45 am 
Offline

Joined: Sat Feb 16, 2008 4:20 pm
Posts: 9
Thank you for checking into it and opening the bug! :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 28, 2008 6:30 am 
Offline
Cacti Guru User
User avatar

Joined: Thu Jan 31, 2008 6:39 am
Posts: 2589
Location: Kressbronn, Germany
There's a simple solution to this, the CDEFs for the graphs are wrong. Seems like the graph now has some more RRD files (MAX in addition to AVERAGE) and therefore the calculation for the CDEFs are wrong ...

To fix this do the following:

Go to Management -> Graph Management -> CDEFs
Select the Memory Used CDEF
It should display something like "cdef=d,c,-,b,-,a,-,1024,*"
you'll need to change this, so it states something like: "cdef=g,e,-,c,-,a,-,1024,*"

In order to get the correct function, you need to look at the graph properties of the memory graph. There are some lines displaying the following:
Code:
DEF:a="/home/cacti-087b/rra/cachebox_mem_buffers_49.rrd":mem_buffers:AVERAGE \
DEF:b="/home/cacti-087b/rra/cachebox_mem_buffers_49.rrd":mem_buffers:MAX \
DEF:c="/home/cacti-087b/rra/cachebox_mem_cache_50.rrd":mem_cache:AVERAGE \
DEF:d="/home/cacti-087b/rra/cachebox_mem_cache_50.rrd":mem_cache:MAX \
DEF:e="/home/cacti-087b/rra/cachebox_mem_free_51.rrd":mem_free:AVERAGE \
DEF:f="/home/cacti-087b/rra/cachebox_mem_free_51.rrd":mem_free:MAX \
DEF:g="/home/cacti-087b/rra/cachebox_mem_total_52.rrd":mem_total:AVERAGE \
DEF:h="/home/cacti-087b/rra/cachebox_mem_total_52.rrd":mem_total:MAX \
DEF:i="/home/cacti-087b/rra/cachebox_swap_free_53.rrd":swap_free:AVERAGE \
DEF:j="/home/cacti-087b/rra/cachebox_swap_free_53.rrd":swap_free:MAX \
DEF:ba="/home/cacti-087b/rra/cachebox_swap_total_54.rrd":swap_total:AVERAGE \
DEF:bb="/home/cacti-087b/rra/cachebox_swap_total_54.rrd":swap_total:MAX \
CDEF:cdefa=a,0,* \
CDEF:cdefb=g,e,-,c,-,a,-,1024,* \


So the CDEF needs to state the following: mem_used(average) = ( mem_total(average) - mem_free(average) - mem_cache(average) - mem_buffers(average) ) * 1024


Attachments:
graph_properties.jpg
graph_properties.jpg [ 3.74 KiB | Viewed 35531 times ]
Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 28, 2008 6:33 am 
Offline
Cacti Guru User
User avatar

Joined: Thu Jan 31, 2008 6:39 am
Posts: 2589
Location: Kressbronn, Germany
BTW, the swap info has the same problem, the CDEF for swap_used is using/refering to the wrong rrd files ....


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 28, 2008 6:36 am 
Offline
Cacti Guru User
User avatar

Joined: Thu Jan 31, 2008 6:39 am
Posts: 2589
Location: Kressbronn, Germany
One addition, after changing the CDEFs for the graph cacti calculates the mem_used only after it got the latest values for the other sources. It's N/A until then and the graph will not show the mem_used.

To fix this you'll need to add an invisible area right at the top of the graph template (see screenshots)


Attachments:
graph_invisible_settings.jpg
graph_invisible_settings.jpg [ 35.02 KiB | Viewed 35523 times ]
graph_invisible_area.jpg
graph_invisible_area.jpg [ 7.77 KiB | Viewed 35526 times ]
Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 02, 2008 9:43 am 
Offline
Cacti Guru User
User avatar

Joined: Fri Sep 19, 2003 8:36 am
Posts: 2326
Location: Sophia-Antipolis, France
Many many thanks for finding this "bug" :oops:

I've uploaded corrected versions of the templates (tested on a clean 0.8.7b + PIA 2.1 installation).

_________________

HOWTOs :
Templates :


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 08, 2008 1:12 pm 
Offline

Joined: Sat Feb 16, 2008 4:20 pm
Posts: 9
I just downloaded the updated files. They're the ones still listed up at the top of this thread, right?

Anyways, before importing them i deleted all my rra's and the templates, data sources the whole shebang. However, when i reupload the template and try to use it, i'm still have the same issue where the memory used is a negative #.

I probably didn't do everything i needed or possibly downloaded the wrong files. could you help point me in the right direction? Thanks! :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 08, 2008 1:40 pm 
Offline
Cacti Guru User
User avatar

Joined: Thu Jan 31, 2008 6:39 am
Posts: 2589
Location: Kressbronn, Germany
Just go and check the graph properties for the rras and the CDEF function if that is correct (see the formular in one of my earlier posts) . Or simply paste it here (in code tags :-) ) so we can have a look at it


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 08, 2008 2:27 pm 
Offline

Joined: Sat Feb 16, 2008 4:20 pm
Posts: 9
phalek, i appreciate you helping me out with this :)
Here's the info.

Code:
/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=1207592838 \
--end=1207679238 \
--title="Bobafett - Memory Usage" \
--base=1024 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
COMMENT:"From 2008/04/07 12\:27\:18 To 2008/04/08 12\:27\:18\c" \
COMMENT:"  \n" \
--vertical-label="bytes" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:10: \
--font UNIT:8: \
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 \
CDEF:cdefa=g,e,-,c,-,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,* \
CDEF:cdefbd=g,1024,* \
CDEF:cdefbe=h,1024,* \
CDEF:cdefbf=i,1024,* \
CDEF:cdefbg=j,1024,* \
CDEF:cdefbi=ba,1024,* \
CDEF:cdefbj=bb,1024,* \
CDEF:cdefca=bc,1024,* \
CDEF:cdefcb=bd,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: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"  \
AREA:cdefba#942D0CFF:"Memory Cached":STACK \
GPRINT:cdefbb:LAST:" Current\:%8.2lf %s"  \
GPRINT:cdefba:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:cdefbd:MIN:"Min\:%8.2lf %s"  \
GPRINT:cdefbe:MAX:"Max\:%8.2lf %s\n"  \
AREA:cdefbf#12B3B5FF:"Memory Free":STACK \
GPRINT:cdefbg:LAST:"   Current\:%8.2lf %s"  \
GPRINT:cdefbf:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:cdefbi:MIN:"Min\:%8.2lf %s"  \
GPRINT:cdefbj:MAX:"Max\:%8.2lf %s\n"  \
LINE1:cdefca#000000FF:"Memory Total"  \
GPRINT:cdefcb:MAX:"  Current\:%8.2lf %s"


I think i understand why. The cdef is subtracting from itself in the equation. However, i'm not sure how to change that.


Last edited by agentc0re on Tue Apr 08, 2008 2:42 pm, edited 1 time in total.

Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 38 posts ]  Go to page 1, 2, 3  Next

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group