SHARE
TWEET

Patch for Zabbix agent under FreeBSD

a guest May 5th, 2011 121 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- src/libs/zbxsysinfo/freebsd/memory.c.orig   2011-05-05 16:24:40.000000000 +0400
  2. +++ src/libs/zbxsysinfo/freebsd/memory.c        2011-05-05 16:38:49.000000000 +0400
  3. @@ -70,6 +70,81 @@
  4.  #endif /* HAVE_FUNCTION_SYSCTLBYNAME */
  5.  }
  6.  
  7. +static int     VM_MEMORY_ACTIVE(AGENT_RESULT *result)
  8. +{
  9. +#if defined(HAVE_FUNCTION_SYSCTLBYNAME)
  10. +       /* FreeBSD 6.2 i386; FreeBSD 7.0 i386 */
  11. +       u_int           activepages, pagesize;
  12. +       size_t          len;
  13. +
  14. +       len = sizeof(activepages);
  15. +
  16. +       if (0 != sysctlbyname("vm.stats.vm.v_active_count", &activepages, &len, NULL, 0))
  17. +               return SYSINFO_RET_FAIL;
  18. +
  19. +       len = sizeof(pagesize);
  20. +
  21. +       if (0 != sysctlbyname("vm.stats.vm.v_page_size", &pagesize, &len, NULL, 0))
  22. +               return SYSINFO_RET_FAIL;
  23. +
  24. +       SET_UI64_RESULT(result, (zbx_uint64_t)activepages * pagesize);
  25. +
  26. +       return SYSINFO_RET_OK;
  27. +#else
  28. +       return SYSINFO_RET_FAIL;
  29. +#endif /* HAVE_FUNCTION_SYSCTLBYNAME */
  30. +}
  31. +
  32. +static int     VM_MEMORY_INACTIVE(AGENT_RESULT *result)
  33. +{
  34. +#if defined(HAVE_FUNCTION_SYSCTLBYNAME)
  35. +       /* FreeBSD 6.2 i386; FreeBSD 7.0 i386 */
  36. +       u_int           inactivepages, pagesize;
  37. +       size_t          len;
  38. +
  39. +       len = sizeof(inactivepages);
  40. +
  41. +       if (0 != sysctlbyname("vm.stats.vm.v_inactive_count", &inactivepages, &len, NULL, 0))
  42. +               return SYSINFO_RET_FAIL;
  43. +
  44. +       len = sizeof(pagesize);
  45. +
  46. +       if (0 != sysctlbyname("vm.stats.vm.v_page_size", &pagesize, &len, NULL, 0))
  47. +               return SYSINFO_RET_FAIL;
  48. +
  49. +       SET_UI64_RESULT(result, (zbx_uint64_t)inactivepages * pagesize);
  50. +
  51. +       return SYSINFO_RET_OK;
  52. +#else
  53. +       return SYSINFO_RET_FAIL;
  54. +#endif /* HAVE_FUNCTION_SYSCTLBYNAME */
  55. +}
  56. +
  57. +static int     VM_MEMORY_WIRED(AGENT_RESULT *result)
  58. +{
  59. +#if defined(HAVE_FUNCTION_SYSCTLBYNAME)
  60. +       /* FreeBSD 6.2 i386; FreeBSD 7.0 i386 */
  61. +       u_int           wiredpages, pagesize;
  62. +       size_t          len;
  63. +
  64. +       len = sizeof(wiredpages);
  65. +
  66. +       if (0 != sysctlbyname("vm.stats.vm.v_wire_count", &wiredpages, &len, NULL, 0))
  67. +               return SYSINFO_RET_FAIL;
  68. +
  69. +       len = sizeof(pagesize);
  70. +
  71. +       if (0 != sysctlbyname("vm.stats.vm.v_page_size", &pagesize, &len, NULL, 0))
  72. +               return SYSINFO_RET_FAIL;
  73. +
  74. +       SET_UI64_RESULT(result, (zbx_uint64_t)wiredpages * pagesize);
  75. +
  76. +       return SYSINFO_RET_OK;
  77. +#else
  78. +       return SYSINFO_RET_FAIL;
  79. +#endif /* HAVE_FUNCTION_SYSCTLBYNAME */
  80. +}
  81. +
  82.  static int     VM_MEMORY_USED(AGENT_RESULT *result)
  83.  {
  84.  #if defined(HAVE_FUNCTION_SYSCTLBYNAME)
  85. @@ -202,6 +277,9 @@
  86.         {
  87.                 {"total",       VM_MEMORY_TOTAL},
  88.                 {"free",        VM_MEMORY_FREE},
  89. +               {"active",      VM_MEMORY_ACTIVE},
  90. +               {"inactive",    VM_MEMORY_INACTIVE},
  91. +               {"wired",       VM_MEMORY_WIRED},
  92.                 {"used",        VM_MEMORY_USED},
  93.                 {"pfree",       VM_MEMORY_PFREE},
  94.                 {"pused",       VM_MEMORY_PUSED},
RAW Paste Data
Top