better ucd/net-snmp memory usage -- update June 21 2009

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

Moderators: Developers, Moderators

ehall
Cacti User
Posts: 246
Joined: Fri Dec 09, 2005 3:42 pm

better ucd/net-snmp memory usage -- update June 21 2009

Post by ehall »

I have been working on a way to get better information about memory usage on my *NIX servers and have come up with the following.

Image

That graph shows the total real memory installed, real mem used by processes, cache, and buffers, and real memory that is unused. It also displays used swap space as a pink strip on the top, above the real memory.

A script is used to gather various bits of information from the Host MIB as well as ucd/net-snmp, then does some basic math, and returns all of the information back to cacti (this includes data not in the graph, such as total amount of installed swap space). The script is necessary because some *NIX flavors do weird things with some of the net-snmp numbers (FreeBSD changes the amount of memory available whenever swap space is activated for example, while Solaris 10 does not provide any numbers for buffers and cache).

--> see this page for the tarball and instructions <--
Last edited by ehall on Tue Jun 23, 2009 11:19 am, edited 13 times in total.
User avatar
fmangeant
Cacti Guru User
Posts: 2345
Joined: Fri Sep 19, 2003 8:36 am
Location: Sophia-Antipolis, France
Contact:

Post by fmangeant »

Hi

many thanks for this template, it works great.

I had to modify the data input method to add the "-q" flag to php, in order to suppress HTTP Header output :

Code: Select all

$ php -q /cacti/cacti-0.8.6h/scripts/netsnmp_memory_usage.php 10.37.12.82, xxxx, 1, , , 161, 500
totalReal:4150332 availReal:3817268 totalSwap:4192956 availSwap:4192956 memBuffer:68124 memCached:178876 usedReal:86064 usedSwap:0
instead of

Code: Select all

$ php /cacti/cacti-0.8.6h/scripts/netsnmp_memory_usage.php 10.37.12.82, xxxx, 1, , , 161, 500
Content-type: text/html
X-Powered-By: PHP/4.3.9

totalReal:4150332 availReal:3817268 totalSwap:4192956 availSwap:4192956 memBuffer:68124 memCached:178876 usedReal:86064 usedSwap:0
As cactid 0.8.6g is out (http://www.cacti.net/cactid_download.php), it should also be a good idea to add the full path to php.

Regards,
[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]
tman
Cacti User
Posts: 97
Joined: Thu Oct 14, 2004 4:14 pm

Post by tman »

Thanks ehall, very useful.

On a sidenote, can I ask what font you are using for your legend items in your graphs. Looks like your squeezing a lot of info in there.

Cheers
ehall
Cacti User
Posts: 246
Joined: Fri Dec 09, 2005 3:42 pm

Post by ehall »

That font is 7pt Vera Mono, which came with SUSE I think
driden91
Cacti User
Posts: 52
Joined: Fri Jan 20, 2006 10:38 am

Post by driden91 »

When i import the xml file i have this error :

Code: Select all

Error: XML: Hash version does not exist.
I use cacti 0.8.6.g
driden91
Cacti User
Posts: 52
Joined: Fri Jan 20, 2006 10:38 am

Post by driden91 »

driden91 wrote:When i import the xml file i have this error :

Code: Select all

Error: XML: Hash version does not exist.
I use cacti 0.8.6.g
No idee .?
redcap
Posts: 18
Joined: Mon Jan 23, 2006 5:49 am

Post by redcap »

driden91 wrote:When i import the xml file i have this error :

Code: Select all

Error: XML: Hash version does not exist.
I use cacti 0.8.6.g
I run into the same error.
It also says:

Code: Select all

Notice: Only variable references should be returned by reference in /usr/share/cacti/site/lib/import.php on line 44

Warning: Cannot modify header information - headers already sent by (output started at /usr/share/cacti/site/lib/import.php:44) in /usr/share/cacti/site/templates_import.php on line 67
also using 0.8.6.g

Thanks,
Redcap
redcap
Posts: 18
Joined: Mon Jan 23, 2006 5:49 am

Post by redcap »

I upgraded to 0.8.6h (Debian unstable package), and now I can import without any problems.

Thanks for this nice template!
These memory graphs are finally showing what I want to see ;-)
redcap
intellutions
Posts: 1
Joined: Thu Mar 23, 2006 7:55 pm

Post by intellutions »

I haven't been able to get this report to work, or any other report that involves load average or memory stats. I just don't get any data back from certain MIBs. (ex: .1.3.6.1.4.1.2021.4.6.0)

An snmpwalk shows results such as:

UCD-SNMP-MIB::memAvailReal.0 = No more variables left in this MIB View (It is past the end of the MIB tree)

Other stats and graphs work fine (ex: ethernet traffic) so I know I have snmp and cacti setup correctly.

Is there something I need to do/edit/upgrade on my servers to get these other stats?

Servers are Fedora Core 1.

Any tips/hints would be great.

Thank You,
Rich
giovanni
Posts: 25
Joined: Sat May 20, 2006 8:06 pm

Post by giovanni »

Works beautifully!

Thank you very much!
User avatar
AntiSpoofing
Posts: 26
Joined: Mon May 15, 2006 11:21 am

Had to edit the PHP...

Post by AntiSpoofing »

Works like a champ - but in the off chance that someone else runs into the concrete wall that I hit, here goes...

In the PHP file - which I put to the scripts directory. The command-line kept trying to go to /var.... I edited the lines to put the exact path to the binaries referenced and all was well after that...

If someone can give me the proper way to inherit the cacti path - I would be happy to revert - or not - cause I got it to work.

:wink:
dio
Posts: 1
Joined: Sat Jun 10, 2006 9:33 am

Post by dio »

intellutions wrote:I haven't been able to get this report to work, or any other report that involves load average or memory stats. I just don't get any data back from certain MIBs. (ex: .1.3.6.1.4.1.2021.4.6.0)
Rich
What version of snmp are you using?
Did you alter your snmp cpnfiguration to allow viewing of mib data other than [system]?
--dio
carpenike
Posts: 6
Joined: Mon Jun 19, 2006 8:05 am

Post by carpenike »

Thank you for an awesome script! Just what I was looking for!

I'm having issues with it not correctly reporting the amount of memory I have...

The graph says I have 885MB, but there's a gig in there.. and here's my meminfo...

Is this expected behavior?

homefileserv ~ # cat /proc/meminfo
MemTotal: 906604 kB
MemFree: 90164 kB
Buffers: 283556 kB
Cached: 279512 kB
SwapCached: 0 kB
Active: 322144 kB
Inactive: 319968 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 906604 kB
LowFree: 90164 kB
SwapTotal: 987988 kB
SwapFree: 987988 kB
Dirty: 24 kB
Writeback: 0 kB
Mapped: 90684 kB
Slab: 168492 kB
CommitLimit: 1441288 kB
Committed_AS: 294220 kB
PageTables: 744 kB
VmallocTotal: 122580 kB
VmallocUsed: 3440 kB
VmallocChunk: 119140 kB
sauron
Posts: 42
Joined: Wed Jul 05, 2006 8:24 am
Location: London, UK

Post by sauron »

homefileserv ~ # cat /proc/meminfo
MemTotal: 906604 kB
That isn't 1Gb - 906604 Kb is 885Mb - divide by 1024. So, the amount reported by the graph is correct - at least as far as your system is concerned.

Assuming this is Linux, I suspect you have a kernel compiled without HIGHMEM support, which limits the available memory for the system. Some memory is reserved for storing kernel data structures that hold information about the memory map and page tables. On x86, this subtracts 128 MB from the 1Gb physical RAM you have installed, as kernel virtual addresses in this 128 MB are mapped to physical memory. If you recompile your kernel with 4Gb HIGHMEM support, you should find the available RAM increases, as the virtual address space has changed.

There's another 10Mb or so missing that I can't account for, but perhaps you have a graphics chipset that shares system RAM or something?

Mike
carpenike
Posts: 6
Joined: Mon Jun 19, 2006 8:05 am

Post by carpenike »

Right right!

Thanks!

Do you think I should compile that into my kernel or leave it out?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest