Confused as to why two values in this template are backwards

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
stormonts
Cacti User
Posts: 349
Joined: Tue Mar 31, 2009 10:05 am

Confused as to why two values in this template are backwards

Post by stormonts »

As shown in the graph below, the "Memory Used" and "Memory Free' values are reversed based on what is shown in "top" on that server.
Untitled.png
Untitled.png (44.02 KiB) Viewed 930 times
The debug of the graph is below with the CDEFs shown. They appear to be correct, but the numbers aren't correct. What am I missing?
cdefs.png
cdefs.png (92.77 KiB) Viewed 930 times
User avatar
Osiris
Cacti Guru User
Posts: 1424
Joined: Mon Jan 05, 2015 10:10 am

Re: Confused as to why two values in this template are backwards

Post by Osiris »

What is the type of the data input Method?
Before history, there was a paradise, now dust.
stormonts
Cacti User
Posts: 349
Joined: Tue Mar 31, 2009 10:05 am

Re: Confused as to why two values in this template are backwards

Post by stormonts »

They are using the Net-SNMP - Buffers, Net-SNMP - Cache, Net-SNMP - Free, Net-SNMP - Total "Get SNMP Data" data templates.

bsi-util-btp - Memory - Buffers bsi-util-btp SNMP Version: 2, Community: public, OID: .1.3.6.1.4.1.2021.4.14.0
RRD: /usr/local/cacti-1.2.9/rra/bsi-util-btp_mem_buffers_3410.rrd
bsi-util-btp - Memory - Cache bsi-util-btp SNMP Version: 2, Community: public, OID: .1.3.6.1.4.1.2021.4.15.0
RRD: /usr/local/cacti-1.2.9/rra/bsi-util-btp_mem_cache_3411.rrd
bsi-util-btp - Memory - Free bsi-util-btp SNMP Version: 2, Community: public, OID: .1.3.6.1.4.1.2021.4.6.0
RRD: /usr/local/cacti-1.2.9/rra/bsi-util-btp_mem_free_3412.rrd
bsi-util-btp - Memory - memTotalReal bsi-util-btp SNMP Version: 2, Community: public, OID: .1.3.6.1.4.1.2021.4.5.0
RRD: /usr/local/cacti-1.2.9/rra/bsi-util-btp_memtotalreal_3414.rrd
User avatar
Osiris
Cacti Guru User
Posts: 1424
Joined: Mon Jan 05, 2015 10:10 am

Re: Confused as to why two values in this template are backwards

Post by Osiris »

Can you log this into GitHub?
Before history, there was a paradise, now dust.
stormonts
Cacti User
Posts: 349
Joined: Tue Mar 31, 2009 10:05 am

Re: Confused as to why two values in this template are backwards

Post by stormonts »

IDone (https://github.com/Cacti/cacti/issues/3329). I didn't know if it was actually a bug or if I was just doing something wrong with CDEFs.
stormonts
Cacti User
Posts: 349
Joined: Tue Mar 31, 2009 10:05 am

Re: Confused as to why two values in this template are backwards

Post by stormonts »

Jimmy closed the issue on Github statng it is not a bug, so I am back to square one.

His comment was:
So, this looks like a custom graph template, not written by The Cacti Group. Reviewing the Data Template, the specific OID's seem to be correct. Review the various Graph Items and ensure that they are using the CDEF "Multiply by 1024" each and that the base units of the Graph Template are also 1024. If you want the unit's to be SI (KiB, GiB), then you need to add a "Multiply by 1000" CDEF and change the base units for the Graph Template to 1000.
But that doesn't explain why the two values (memory free and memory used) seem to be backwards.

Memory free is d,c,-,1024,* Which is (MemoryTotalReal-MemFree)*1024 correct? Why would that be giving me the value of the memory used according to top on the server (and why is the "memory used" cdef giving me the total of the memory free according to top?
Last edited by stormonts on Mon Mar 09, 2020 7:49 am, edited 1 time in total.
User avatar
camerabob
Cacti User
Posts: 386
Joined: Fri Feb 10, 2017 2:45 pm
Location: Long Island, New York, USA
Contact:

Re: Confused as to why two values in this template are backwards

Post by camerabob »

I'm not a CDEF pro, but shouldn't there be a minus sign in that CDEF definition? Something like "d,c,-,1024,*"
Prod: Cacti 1.2.15 @ CentOS Linux release 7.9.2009 (Core) & PHP 5.4.16-48.el7
Maint @ 1.2
Monitor @ 2.3.6
Thold @ 1.2.4

Temp: Cacti 1.2.3 @ CentOS Linux release 7.9.2009 (Core) & PHP 5.4.16-48.el7
Flowview @ 2.1
Mactrack @ 4.2
Maint @ 1.2
Monitor @ 2.3.6
Router Configs @ 1.3.4
Syslog Monitoring @ 2.1
Thold @ 1.2.4
stormonts
Cacti User
Posts: 349
Joined: Tue Mar 31, 2009 10:05 am

Re: Confused as to why two values in this template are backwards

Post by stormonts »

There is, I just failed to type it correctly in that comment (comment is updated now).

Attached is the template if anyone wants to take a look and help me figure out where my math is wrong.
Dummy
Posts: 24
Joined: Wed Jan 03, 2018 4:35 pm

Re: Confused as to why two values in this template are backwards

Post by Dummy »

To me this calculation is not clear (I'm not an expert in CDEF):
Values collected:
a=mem_buffers
b=mem_cache
c=mem_free
d=memTotalReal

Is this the correct Calculation to get Memory Used?
Memory Used = c,a,b,-,+,1024,*
= (c + (a-b)) * 1024

The values on the Graph did not match with the values from "top" - Command
Top shows: 5.712.552 Free, your graph: 1,52 Current

You had checked each single value in the graph separately before starting caluculation wiht CDEF?
stormonts
Cacti User
Posts: 349
Joined: Tue Mar 31, 2009 10:05 am

Re: Confused as to why two values in this template are backwards

Post by stormonts »

Yes, I did check them individually. What we are trying to show is the amount of physical memory that is used which does not include buffers/cache. (top shows "Used" as the total of buff/cache + actual memory usage).

If your break down of my equation is correct, then I guess I should change it to:

a=mem_buffers
b=mem_cache
c=mem_free
d=memTotalReal

Memory Used = d,a,b,+,-,1024,*
= (d - (a+b)) * 1024

Correct?
User avatar
camerabob
Cacti User
Posts: 386
Joined: Fri Feb 10, 2017 2:45 pm
Location: Long Island, New York, USA
Contact:

Re: Confused as to why two values in this template are backwards

Post by camerabob »

I would go with:

Memory Used = d,a,-,b,-,1024,*
= (d - a - b) * 1024
Prod: Cacti 1.2.15 @ CentOS Linux release 7.9.2009 (Core) & PHP 5.4.16-48.el7
Maint @ 1.2
Monitor @ 2.3.6
Thold @ 1.2.4

Temp: Cacti 1.2.3 @ CentOS Linux release 7.9.2009 (Core) & PHP 5.4.16-48.el7
Flowview @ 2.1
Mactrack @ 4.2
Maint @ 1.2
Monitor @ 2.3.6
Router Configs @ 1.3.4
Syslog Monitoring @ 2.1
Thold @ 1.2.4
Dummy
Posts: 24
Joined: Wed Jan 03, 2018 4:35 pm

Re: Confused as to why two values in this template are backwards

Post by Dummy »

Both of the last two Posts should provide the same results :wink:

Maybe it makes sense to start with one Value as Area and three values as Lines. Only a CDEF which does the calculation '* 1024'
Then compare the Current-Values with the Values shown in "top".

If these values will match do some calculation to check which formula you will need to get the desired values.
Then just define a matching CDEF.
stormonts
Cacti User
Posts: 349
Joined: Tue Mar 31, 2009 10:05 am

Re: Confused as to why two values in this template are backwards

Post by stormonts »

I finally figured it out, but now I have a different problem. I am using the same graph template on multiple servers, but the problem is that the values aren't coming in the same way across devices.

In the image below, you can see that the order of DEFs is MemTotalReal, then mem_buffers, then mem_cache, then mem_free.
working.png
working.png (82.77 KiB) Viewed 880 times

This is from a system that is displaying incorrectly and the order of the DEFs is mem_buffers, then mem_cache, then mem_free, then MemTotalReal
broken.png
broken.png (52.47 KiB) Viewed 880 times
Shouldn't they always be uniform since the same template is in use and the servers are all running the same OS?
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Confused as to why two values in this template are backwards

Post by TheWitness »

You may have multiple versions of the template installed. There is a Sync Template dropdown on the Graph Templates page. You should try that.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Dummy
Posts: 24
Joined: Wed Jan 03, 2018 4:35 pm

Re: Confused as to why two values in this template are backwards

Post by Dummy »

Yes, agreed with Witness. I seems you are not using only one template for your servers. Maybe you selected a different Template for your second server?
If you are using two Templates and you will stay on two Templates: it might be an idea to validate the configuration of both Templates.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest