How to populate RAM field in Gb as existing one is showing value in Mb but lable as Gb.

nick2015
Tera Contributor

Hi,

I am working on Helsinki version and discovered Windows and Unix devices. On server form RAM label is in Gb but value appears in Mb. Please help me how to convert Mb value into Gb value before populating the RAM field.

Regards,

Nick

1 ACCEPTED SOLUTION

Dave Smith1
ServiceNow Employee
ServiceNow Employee

Tried:


if (columns[0] == "MemTotal:")


ram += parseInt(columns[1]) / 1073741824;


...?


View solution in original post

7 REPLIES 7

Anurag Tripathi
Mega Patron
Mega Patron

Hi Nick,



A simple before update business rule on the table in question



Condition: <RAM field> <changes>



Script



current.<ram>=current.<ram>/1024;     //this will convert Mb to Gb


-Anurag

Dave Smith1
ServiceNow Employee
ServiceNow Employee

Have you checked the sensor for that probe?   Changes there may help insert the correct value.


Hi Dave,


Thanks for reply.



In Sensors, I have not found any relevant details but probe is showing below statement about memory capacity



module.capacity                 = parseFloat(Win32_PhysicalMemory.Capacity) / 1048576;


  total_memory += (parseFloat(Win32_PhysicalMemory.Capacity) / 1048576);



Do I need to make the changes here?I am working on production instance. Plz suggest.



Regards,


Nick


Dave Smith1
ServiceNow Employee
ServiceNow Employee

Ohhh... that is... actually a tough one.   Will the answer ALWAYS be in GB, or is there a unit against it?



1048576 = 1024 * 1024, giving an answer in MB, so I presume you simply need to change that to "1073741824".   However, I'd write it:



module.capacity                 = parseFloat(Win32_PhysicalMemory.Capacity) / (1024 * 1024 * 1024);



I've just checked that value on this machine (wbemtext.exe rocks!) and got a figure of: 2147483648 (presumably bytes)


  • 2147483648 / 1024 = 2097152 KB
  • 2097152 / 1024 = 2048 MB
  • 2048MB / 1024 = 2 GB


So if you want the answer in GB, instead of "/ 1048576" (which is 1024 squared), you'll need "/1073741824" (1024 cubed, = GB) - give that a whirl, see what happens.