which is how we get mem_used 3,134.00%

Comments

baldwinlouie’s picture

StatusFileSize
new425 bytes

Here is a quick little patch which converts the limit_maxbytes to KB before doing the mem_used calculation.

robertdouglass’s picture

@baldwinlouie: I think your math might be off: http://www.matisse.net/bitcalc/

baldwinlouie’s picture

StatusFileSize
new540 bytes

@robertDouglass: My bad. I should of double checked everything before.

Anyhow, here's a new patch. All I did was move the $mem_used calculation to the top, before the format_size() functions are called. Looks like all the values are stored as bytes first, so this should take care of any conversion issues.

robertdouglass’s picture

I'm not sure your patch is as intended. Could I ask for a re-roll? Pretty please? =)

baldwinlouie’s picture

StatusFileSize
new491 bytes

I just rerolled it with a fresh copy from cvs. The results are the same. I'll attach the re-roll as well.

I'll post what I did to the code here:

            case 'default' :
              $mem_used = $values['bytes'] / $values['limit_maxbytes'];
              $values['uptime'] = format_interval($values['uptime']);
              $values['time'] = format_date($values['time']);
              $values['bytes'] = format_size($values['bytes']);
              $values['bytes_read'] = format_size($values['bytes_read']);
              $values['bytes_written'] = format_size($values['bytes_written']);
              $values['limit_maxbytes'] = format_size($values['limit_maxbytes']);

              //Custom Entries
              $values['hit_percentage'] = number_format(100.0 * $values['get_hits'] / $values['cmd_get'], 2) . '%';

              $values['mem_used'] = number_format(100.0 * $mem_used, 2) . '%';
              break;

Note, I declared the $mem_used variable before any of the format_size() functions are called. I was thinking by declaring it at the top, the units for bytes and limit_maxbytes will be the same. Thus the calculation should come out correct.

Let me know if I missed something somewhere :)

robertdouglass’s picture

Status: Active » Fixed

I solved this differently. The 'limit_maxbytes' value is expressed in megabytes so I multiplied it by 1048576 to match the units with 'bytes' and then did the math.

-              $mem_used = $values['bytes'] / $values['limit_maxbytes'];
+              $mem_used = intval($values['bytes']) / (intval($values['limit_maxbytes']) * 1048576);
robertdouglass’s picture

Status: Fixed » Active

gah. Either I'm off in my math by an order of magnitude or there's some other problem. Need more eyeballs.

baldwinlouie’s picture

hmm...I think it is because after this:

$values['bytes'] = format_size($values['bytes']);

$values['bytes'] can either be in KB, MB. so converting limit_maxbytes to bytes might throw off the math.

kamleshpatidar’s picture

is it working?
i get 0.00% mem_used. how can i increase it?
Kamlesh Patidar

jaydub’s picture

I believe this has been addressed in CVS:

http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/memcache/me...

If someone can verify then I think this can be closed out

catch’s picture

Status: Active » Closed (fixed)

Closing this out, 18 months since that commit.