SHARE
TWEET

patch for correct calculation of pfree and pused

a guest May 6th, 2011 43 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- src/libs/zbxsysinfo/freebsd/memory.c.orig3  2011-05-05 17:40:35.000000000 +0400
  2. +++ src/libs/zbxsysinfo/freebsd/memory.c        2011-05-05 17:40:43.000000000 +0400
  3. @@ -149,7 +149,7 @@
  4.  {
  5.  #if defined(HAVE_FUNCTION_SYSCTLBYNAME)
  6.         /* FreeBSD 6.2 i386; FreeBSD 7.0 i386 */
  7. -       u_int           totalpages, freepages;
  8. +       u_int           totalpages, freepages, cachepages, inactivepages;
  9.         size_t          len;
  10.  
  11.         len = sizeof(totalpages);
  12. @@ -162,7 +162,17 @@
  13.         if (0 != sysctlbyname("vm.stats.vm.v_free_count", &freepages, &len, NULL, 0))
  14.                 return SYSINFO_RET_FAIL;
  15.  
  16. -       SET_DBL_RESULT(result, (double)(100.0 * freepages) / totalpages);
  17. +       len = sizeof(cachepages);
  18. +
  19. +       if (0 != sysctlbyname("vm.stats.vm.v_cache_count", &cachepages, &len, NULL, 0))
  20. +               return SYSINFO_RET_FAIL;
  21. +
  22. +       len = sizeof(inactivepages);
  23. +
  24. +       if (0 != sysctlbyname("vm.stats.vm.v_inactive_count", &inactivepages, &len, NULL, 0))
  25. +               return SYSINFO_RET_FAIL;
  26. +
  27. +       SET_DBL_RESULT(result, (double)(100.0 * (freepages + cachepages + inactivepages) / totalpages));
  28.  
  29.         return SYSINFO_RET_OK;
  30.  #else
  31. @@ -174,7 +184,7 @@
  32.  {
  33.  #if defined(HAVE_FUNCTION_SYSCTLBYNAME)
  34.         /* FreeBSD 6.2 i386; FreeBSD 7.0 i386 */
  35. -       u_int           totalpages, freepages;
  36. +       u_int           totalpages, activepages, wiredpages;
  37.         size_t          len;
  38.  
  39.         len = sizeof(totalpages);
  40. @@ -182,12 +192,17 @@
  41.         if (0 != sysctlbyname("vm.stats.vm.v_page_count", &totalpages, &len, NULL, 0))
  42.                 return SYSINFO_RET_FAIL;
  43.  
  44. -       len = sizeof(freepages);
  45. +       len = sizeof(activepages);
  46.  
  47. -       if (0 != sysctlbyname("vm.stats.vm.v_free_count", &freepages, &len, NULL, 0))
  48. +       if (0 != sysctlbyname("vm.stats.vm.v_active_count", &activepages, &len, NULL, 0))
  49. +               return SYSINFO_RET_FAIL;
  50. +
  51. +       len = sizeof(wiredpages);
  52. +
  53. +       if (0 != sysctlbyname("vm.stats.vm.v_wire_count", &wiredpages, &len, NULL, 0))
  54.                 return SYSINFO_RET_FAIL;
  55.  
  56. -       SET_DBL_RESULT(result, (double)(100.0 * (totalpages - freepages)) / totalpages);
  57. +       SET_DBL_RESULT(result, (double)((100.0 * (activepages + wiredpages)) / totalpages));
  58.  
  59.         return SYSINFO_RET_OK;
  60.  #else
RAW Paste Data
Top