SNMP based template for memory / swap usage on a Unix host
Moderators: Developers, Moderators
- fmangeant
- Cacti Guru User
- Posts: 2345
- Joined: Fri Sep 19, 2003 8:36 am
- Location: Sophia-Antipolis, France
- Contact:
SNMP based template for memory / swap usage on a Unix host
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.
Beware when importing these templates, I'm using "large" RRA definitions...
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.
Beware when importing these templates, I'm using "large" RRA definitions...
- Attachments
-
- cacti_graph_template_ucdnet_-_memory_usage_linux.xml
- (34.01 KiB) Downloaded 4610 times
-
- cacti_graph_template_ucdnet_-_memory_usage_unix.xml
- (21.55 KiB) Downloaded 2885 times
-
- cacti_graph_template_ucdnet_-_swap_usage.xml
- (21.06 KiB) Downloaded 3378 times
Last edited by fmangeant on Wed Apr 02, 2008 9:45 am, edited 2 times in total.
[size=84]
[color=green]HOWTOs[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15353]Install and configure the Net-SNMP agent for Unix[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=26151]Install and configure the Net-SNMP agent for Windows[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=28175]Graph multiple servers using an SNMP proxy[/url][/list]
[color=green]Templates[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15412]Multiple CPU usage for Linux[/url]
[*][url=http://forums.cacti.net/viewtopic.php?p=125152]Memory & swap usage for Unix[/url][/list][/size]
[color=green]HOWTOs[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15353]Install and configure the Net-SNMP agent for Unix[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=26151]Install and configure the Net-SNMP agent for Windows[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=28175]Graph multiple servers using an SNMP proxy[/url][/list]
[color=green]Templates[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15412]Multiple CPU usage for Linux[/url]
[*][url=http://forums.cacti.net/viewtopic.php?p=125152]Memory & swap usage for Unix[/url][/list][/size]
- fmangeant
- Cacti Guru User
- Posts: 2345
- Joined: Fri Sep 19, 2003 8:36 am
- Location: Sophia-Antipolis, France
- Contact:
[size=84]
[color=green]HOWTOs[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15353]Install and configure the Net-SNMP agent for Unix[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=26151]Install and configure the Net-SNMP agent for Windows[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=28175]Graph multiple servers using an SNMP proxy[/url][/list]
[color=green]Templates[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15412]Multiple CPU usage for Linux[/url]
[*][url=http://forums.cacti.net/viewtopic.php?p=125152]Memory & swap usage for Unix[/url][/list][/size]
[color=green]HOWTOs[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15353]Install and configure the Net-SNMP agent for Unix[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=26151]Install and configure the Net-SNMP agent for Windows[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=28175]Graph multiple servers using an SNMP proxy[/url][/list]
[color=green]Templates[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15412]Multiple CPU usage for Linux[/url]
[*][url=http://forums.cacti.net/viewtopic.php?p=125152]Memory & swap usage for Unix[/url][/list][/size]
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.
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
-
- memory 2.png (37.01 KiB) Viewed 42078 times
-
- mem usage.png (33.12 KiB) Viewed 42078 times
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?
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: Select all
root@yoda:~# 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:
root@yoda:~# 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:
- fmangeant
- Cacti Guru User
- Posts: 2345
- Joined: Fri Sep 19, 2003 8:36 am
- Location: Sophia-Antipolis, France
- Contact:
I've not tried this template on 0.8.7b, will do tomorrow.
[size=84]
[color=green]HOWTOs[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15353]Install and configure the Net-SNMP agent for Unix[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=26151]Install and configure the Net-SNMP agent for Windows[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=28175]Graph multiple servers using an SNMP proxy[/url][/list]
[color=green]Templates[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15412]Multiple CPU usage for Linux[/url]
[*][url=http://forums.cacti.net/viewtopic.php?p=125152]Memory & swap usage for Unix[/url][/list][/size]
[color=green]HOWTOs[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15353]Install and configure the Net-SNMP agent for Unix[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=26151]Install and configure the Net-SNMP agent for Windows[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=28175]Graph multiple servers using an SNMP proxy[/url][/list]
[color=green]Templates[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15412]Multiple CPU usage for Linux[/url]
[*][url=http://forums.cacti.net/viewtopic.php?p=125152]Memory & swap usage for Unix[/url][/list][/size]
- fmangeant
- Cacti Guru User
- Posts: 2345
- Joined: Fri Sep 19, 2003 8:36 am
- Location: Sophia-Antipolis, France
- Contact:
[size=84]
[color=green]HOWTOs[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15353]Install and configure the Net-SNMP agent for Unix[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=26151]Install and configure the Net-SNMP agent for Windows[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=28175]Graph multiple servers using an SNMP proxy[/url][/list]
[color=green]Templates[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15412]Multiple CPU usage for Linux[/url]
[*][url=http://forums.cacti.net/viewtopic.php?p=125152]Memory & swap usage for Unix[/url][/list][/size]
[color=green]HOWTOs[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15353]Install and configure the Net-SNMP agent for Unix[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=26151]Install and configure the Net-SNMP agent for Windows[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=28175]Graph multiple servers using an SNMP proxy[/url][/list]
[color=green]Templates[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15412]Multiple CPU usage for Linux[/url]
[*][url=http://forums.cacti.net/viewtopic.php?p=125152]Memory & swap usage for Unix[/url][/list][/size]
- phalek
- Developer
- Posts: 2838
- Joined: Thu Jan 31, 2008 6:39 am
- Location: Kressbronn, Germany
- Contact:
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:
So the CDEF needs to state the following: mem_used(average) = ( mem_total(average) - mem_free(average) - mem_cache(average) - mem_buffers(average) ) * 1024
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: Select all
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,* \
- Attachments
-
- graph_properties.jpg (3.74 KiB) Viewed 40899 times
- phalek
- Developer
- Posts: 2838
- Joined: Thu Jan 31, 2008 6:39 am
- Location: Kressbronn, Germany
- Contact:
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)
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 (35.02 KiB) Viewed 40891 times
-
- graph_invisible_area.jpg (7.77 KiB) Viewed 40894 times
- fmangeant
- Cacti Guru User
- Posts: 2345
- Joined: Fri Sep 19, 2003 8:36 am
- Location: Sophia-Antipolis, France
- Contact:
Many many thanks for finding this "bug"
I've uploaded corrected versions of the templates (tested on a clean 0.8.7b + PIA 2.1 installation).
I've uploaded corrected versions of the templates (tested on a clean 0.8.7b + PIA 2.1 installation).
[size=84]
[color=green]HOWTOs[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15353]Install and configure the Net-SNMP agent for Unix[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=26151]Install and configure the Net-SNMP agent for Windows[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=28175]Graph multiple servers using an SNMP proxy[/url][/list]
[color=green]Templates[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15412]Multiple CPU usage for Linux[/url]
[*][url=http://forums.cacti.net/viewtopic.php?p=125152]Memory & swap usage for Unix[/url][/list][/size]
[color=green]HOWTOs[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15353]Install and configure the Net-SNMP agent for Unix[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=26151]Install and configure the Net-SNMP agent for Windows[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=28175]Graph multiple servers using an SNMP proxy[/url][/list]
[color=green]Templates[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15412]Multiple CPU usage for Linux[/url]
[*][url=http://forums.cacti.net/viewtopic.php?p=125152]Memory & swap usage for Unix[/url][/list][/size]
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!
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!
phalek, i appreciate you helping me out with this
Here's the info.
I think i understand why. The cdef is subtracting from itself in the equation. However, i'm not sure how to change that.
Here's the info.
Code: Select all
/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"
Last edited by agentc0re on Tue Apr 08, 2008 2:42 pm, edited 1 time in total.
Who is online
Users browsing this forum: No registered users and 1 guest