X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fmemory.c;h=10bccdee75d940ad19075ded768f7326f22cd12f;hp=e49fe84a103ae90657db4b86a1e7d2b95fecc285;hb=48efd3deb4c9139fd060ff3d289896e9031bcc7c;hpb=d544398864bc02dfd1623e6d005591b512e2f6c6 diff --git a/src/memory.c b/src/memory.c index e49fe84a..10bccdee 100644 --- a/src/memory.c +++ b/src/memory.c @@ -25,8 +25,8 @@ #include "collectd.h" -#include "common.h" #include "plugin.h" +#include "utils/common/common.h" #ifdef HAVE_SYS_SYSCTL_H #include @@ -94,8 +94,8 @@ static int pagesize; #error "No applicable input method." #endif -static _Bool values_absolute = 1; -static _Bool values_percentage = 0; +static bool values_absolute = true; +static bool values_percentage; static int memory_config(oconfig_item_t *ci) /* {{{ */ { @@ -118,7 +118,7 @@ static int memory_init(void) { #if HAVE_HOST_STATISTICS port_host = mach_host_self(); host_page_size(port_host, &pagesize); -/* #endif HAVE_HOST_STATISTICS */ + /* #endif HAVE_HOST_STATISTICS */ #elif HAVE_SYSCTLBYNAME /* no init stuff */ @@ -140,7 +140,7 @@ static int memory_init(void) { return -1; } -/* #endif HAVE_LIBKSTAT */ + /* #endif HAVE_LIBKSTAT */ #elif HAVE_SYSCTL pagesize = getpagesize(); @@ -148,7 +148,7 @@ static int memory_init(void) { ERROR("memory plugin: Invalid pagesize: %i", pagesize); return -1; } -/* #endif HAVE_SYSCTL */ + /* #endif HAVE_SYSCTL */ #elif HAVE_LIBSTATGRAB /* no init stuff */ @@ -163,9 +163,9 @@ static int memory_init(void) { #define MEMORY_SUBMIT(...) \ do { \ if (values_absolute) \ - plugin_dispatch_multivalue(vl, 0, DS_TYPE_GAUGE, __VA_ARGS__, NULL); \ + plugin_dispatch_multivalue(vl, false, DS_TYPE_GAUGE, __VA_ARGS__, NULL); \ if (values_percentage) \ - plugin_dispatch_multivalue(vl, 1, DS_TYPE_GAUGE, __VA_ARGS__, NULL); \ + plugin_dispatch_multivalue(vl, true, DS_TYPE_GAUGE, __VA_ARGS__, NULL); \ } while (0) static int memory_read_internal(value_list_t *vl) { @@ -218,7 +218,7 @@ static int memory_read_internal(value_list_t *vl) { MEMORY_SUBMIT("wired", wired, "active", active, "inactive", inactive, "free", free); -/* #endif HAVE_HOST_STATISTICS */ + /* #endif HAVE_HOST_STATISTICS */ #elif HAVE_SYSCTLBYNAME /* @@ -259,7 +259,7 @@ static int memory_read_internal(value_list_t *vl) { (gauge_t)sysctl_vals[3], "active", (gauge_t)sysctl_vals[4], "inactive", (gauge_t)sysctl_vals[5], "cache", (gauge_t)sysctl_vals[6]); -/* #endif HAVE_SYSCTLBYNAME */ + /* #endif HAVE_SYSCTLBYNAME */ #elif KERNEL_LINUX FILE *fh; @@ -268,7 +268,7 @@ static int memory_read_internal(value_list_t *vl) { char *fields[8]; int numfields; - _Bool detailed_slab_info = 0; + bool detailed_slab_info = false; gauge_t mem_total = 0; gauge_t mem_used = 0; @@ -280,8 +280,7 @@ static int memory_read_internal(value_list_t *vl) { gauge_t mem_slab_unreclaimable = 0; if ((fh = fopen("/proc/meminfo", "r")) == NULL) { - char errbuf[1024]; - WARNING("memory: fopen: %s", sstrerror(errno, errbuf, sizeof(errbuf))); + WARNING("memory: fopen: %s", STRERRNO); return -1; } @@ -300,10 +299,10 @@ static int memory_read_internal(value_list_t *vl) { val = &mem_slab_total; else if (strncasecmp(buffer, "SReclaimable:", 13) == 0) { val = &mem_slab_reclaimable; - detailed_slab_info = 1; + detailed_slab_info = true; } else if (strncasecmp(buffer, "SUnreclaim:", 11) == 0) { val = &mem_slab_unreclaimable; - detailed_slab_info = 1; + detailed_slab_info = true; } else continue; @@ -315,8 +314,7 @@ static int memory_read_internal(value_list_t *vl) { } if (fclose(fh)) { - char errbuf[1024]; - WARNING("memory: fclose: %s", sstrerror(errno, errbuf, sizeof(errbuf))); + WARNING("memory: fclose: %s", STRERRNO); } if (mem_total < (mem_free + mem_buffered + mem_cached + mem_slab_total)) @@ -336,7 +334,7 @@ static int memory_read_internal(value_list_t *vl) { else MEMORY_SUBMIT("used", mem_used, "buffered", mem_buffered, "cached", mem_cached, "free", mem_free, "slab", mem_slab_total); -/* #endif KERNEL_LINUX */ + /* #endif KERNEL_LINUX */ #elif HAVE_LIBKSTAT /* Most of the additions here were taken as-is from the k9toolkit from @@ -408,7 +406,7 @@ static int memory_read_internal(value_list_t *vl) { MEMORY_SUBMIT("used", (gauge_t)mem_used, "free", (gauge_t)mem_free, "locked", (gauge_t)mem_lock, "kernel", (gauge_t)mem_kern, "arc", (gauge_t)arcsize, "unusable", (gauge_t)mem_unus); -/* #endif HAVE_LIBKSTAT */ + /* #endif HAVE_LIBKSTAT */ #elif HAVE_SYSCTL int mib[] = {CTL_VM, VM_METER}; @@ -421,9 +419,7 @@ static int memory_read_internal(value_list_t *vl) { size = sizeof(vmtotal); if (sysctl(mib, 2, &vmtotal, &size, NULL, 0) < 0) { - char errbuf[1024]; - WARNING("memory plugin: sysctl failed: %s", - sstrerror(errno, errbuf, sizeof(errbuf))); + WARNING("memory plugin: sysctl failed: %s", STRERRNO); return -1; } @@ -434,7 +430,7 @@ static int memory_read_internal(value_list_t *vl) { MEMORY_SUBMIT("active", mem_active, "inactive", mem_inactive, "free", mem_free); -/* #endif HAVE_SYSCTL */ + /* #endif HAVE_SYSCTL */ #elif HAVE_LIBSTATGRAB sg_mem_stats *ios; @@ -445,15 +441,13 @@ static int memory_read_internal(value_list_t *vl) { MEMORY_SUBMIT("used", (gauge_t)ios->used, "cached", (gauge_t)ios->cache, "free", (gauge_t)ios->free); -/* #endif HAVE_LIBSTATGRAB */ + /* #endif HAVE_LIBSTATGRAB */ #elif HAVE_PERFSTAT perfstat_memory_total_t pmemory = {0}; if (perfstat_memory_total(NULL, &pmemory, sizeof(pmemory), 1) < 0) { - char errbuf[1024]; - WARNING("memory plugin: perfstat_memory_total failed: %s", - sstrerror(errno, errbuf, sizeof(errbuf))); + WARNING("memory plugin: perfstat_memory_total failed: %s", STRERRNO); return -1; }