NetXMS Support Forum

English Support => General Support => Topic started by: xenth on April 16, 2008, 11:03:52 AM

Title: RAM percentage?
Post by: xenth on April 16, 2008, 11:03:52 AM
Hi

I'm trying to calculate the percentage of free ram using the NetXMS agent.

The system has 520093696 bytes of ram.
So I did this:

1)Went to transformation TAB of DCI
2)Put in the following calculation: ($1 / 520093696) * 100 
3)Set delta processing to: Keep original value.

This is the first time I've used this feature so talk slowly  :D
Thanks in advance.
Title: Re: RAM percentage?
Post by: Victor Kirhenshtein on April 17, 2008, 01:21:44 PM
Hello!

Looks correct. Do you have any problems with it? Also, since version 0.2.20 you can collect total amount of RAM as separate DCI and use it's value in calculation instead of hardcoded value.

Best regards,
Victor
Title: Re: RAM percentage?
Post by: xenth on April 17, 2008, 03:40:19 PM
It does nothing with my calculation, just keeps giving the numer in Mbytes  ???

Your idea sounds better, how would I do this? I haven't done this before so can you give me an example of how you would do this?

Thanks as always!

Title: Re: RAM percentage?
Post by: Victor Kirhenshtein on April 18, 2008, 11:12:25 AM
Some additional info can be found in this thread: https://www.netxms.org/forum/index.php/topic,289.0.html (https://www.netxms.org/forum/index.php/topic,289.0.html).

Assuming that you have DCI for parameter System.Memory.Physical.Total, your transformation script may look like this:


sub main()
{
   total = GetDCIValue($node, FindDCIByName($node, "System.Memory.Physical.Total"));
   return $1 / total * 100;
}


or simplified to


$1 / GetDCIValue($node, FindDCIByName($node, "System.Memory.Physical.Total")) * 100


Best regards,
Victor
Title: Re: RAM percentage?
Post by: xenth on April 18, 2008, 01:20:03 PM
I don't know why but your scripts aren't working either.

It looks like whatever I put as transformation script with "no delta processing", does absolutely nothing  :(

Hardcoded: ($1 / 520093696) * 100:
Gives the normal value

Your codE: $1 / GetDCIValue($node, FindDCIByName($node, "System.Memory.Physical.Total")) * 100 :
Gives the normal value

What could be causing this, am I doing something wrong?
Title: Re: RAM percentage?
Post by: Victor Kirhenshtein on April 18, 2008, 03:42:25 PM
It' because DCI data type is unsigned int64, and automatic conversion from it to float (real) is not allowed. If you take a look at event log, you most likely will see a lot of SYS_SCRIPT_ERROR events. You have two options: change DCI data type to "float" or "integer", or do an explicit type conversion like this:


int64($1) / GetDCIValue($node, FindDCIByName($node, "System.Memory.Physical.Total")) * 100


Currently NetXMS will leave original value if transformation script fails - not a correct behaviour probably.

Best regards,
Victor
Title: Re: RAM percentage?
Post by: xenth on April 18, 2008, 04:47:32 PM
Aaaah I see! Excellent  :)

Thanks so much again, nice to have this running.