Cacti is a wonderful tool, but many of the default graphs are ugly. Worse, the “ucd/net Memory Usage” graph is totally useless. It displays memory which is free, or dedicated to cache or buffers. But it doesn’t display the actual used memory or total. And it uses the wrong base, assuming there are 1000 bytes in a kilobyte of memory. I can’t imagine why this graph template is even included with Cacti by default. So, I set out to make a better one.
Here is the default graph:
(Click to embiggen)
The implementation for “used memory” in the SNMP OID is inconsistent across devices. But you can fetch “total memory”, and do the math:
Used memory = Total – (Free + Cache + Buffers)
Many people have used this method to make better memory usage templates. Eric A. Hall made a much prettier graph, but it relies on an external script to fetch the data and do the math. This is unnecessary, and (slightly) slower than using Cacti CDEF functions. Hans Fugal used CDEF functions, but his graphs use an eye-searing colour scheme. He also uses the wrong base; there are 1024 bytes in a kilobyte of RAM, not 1000 as in hard drives or network data rate.
Here are mine:
My implementation uses Eric Hall’s colour scheme and Hans Fugal’s CDEF method, but graphs real memory and swap as two separate graphs. It also uses the correct unit base of 1024. These graphs are also intended for Linux. Unix operating systems won’t report Buffers or Cache, but they’ll graph correctly as long as they report Free and Total.
Only after making my own did I discover fmangeant‘s graphs. These use the CDEF method and correct base, although I’m not fond of the colours. The “Memory Usage Unix” graph would be useful if your device doesn’t report Buffers or Cache and you don’t want to see zero values on your graph.