#endif
#include "collectd.h"
+
#include "common.h"
#include "plugin.h"
static _Bool report_by_device = 0;
/* #endif HAVE_SWAPCTL && HAVE_SWAPCTL_TWO_ARGS */
+#elif HAVE_SWAPCTL && HAVE_SWAPCTL_THREE_ARGS
+/* No global variables */
+/* #endif HAVE_SWAPCTL && HAVE_SWAPCTL_THREE_ARGS */
+
#elif defined(VM_SWAPUSAGE)
/* No global variables */
/* #endif defined(VM_SWAPUSAGE) */
static int swap_config (oconfig_item_t *ci) /* {{{ */
{
- int i;
-
- for (i = 0; i < ci->children_num; i++)
+ for (int i = 0; i < ci->children_num; i++)
{
oconfig_item_t *child = ci->children + i;
if (strcasecmp ("ReportBytes", child->key) == 0)
char *s_paths;
int swap_num;
int status;
- int i;
gauge_t avail = 0;
gauge_t total = 0;
return (0);
/* Allocate and initialize the swaptbl_t structure */
- s = (swaptbl_t *) smalloc (swap_num * sizeof (swapent_t) + sizeof (struct swaptable));
+ s = malloc (swap_num * sizeof (swapent_t) + sizeof (struct swaptable));
if (s == NULL)
{
- ERROR ("swap plugin: smalloc failed.");
+ ERROR ("swap plugin: malloc failed.");
return (-1);
}
s_paths = calloc (swap_num, PATH_MAX);
if (s_paths == NULL)
{
- ERROR ("swap plugin: malloc failed.");
+ ERROR ("swap plugin: calloc failed.");
sfree (s);
return (-1);
}
- for (i = 0; i < swap_num; i++)
+ for (int i = 0; i < swap_num; i++)
s->swt_ent[i].ste_path = s_paths + (i * PATH_MAX);
s->swt_n = swap_num;
/* less elements returned than requested */
swap_num = status;
- for (i = 0; i < swap_num; i++)
+ for (int i = 0; i < swap_num; i++)
{
char path[PATH_MAX];
gauge_t this_total;
struct swapent *swap_entries;
int swap_num;
int status;
- int i;
gauge_t used = 0;
gauge_t total = 0;
/* TODO: Report per-device stats. The path name is available from
* swap_entries[i].se_path */
- for (i = 0; i < swap_num; i++)
+ for (int i = 0; i < swap_num; i++)
{
if ((swap_entries[i].se_flags & SWF_ENABLE) == 0)
continue;
#elif HAVE_PERFSTAT
static int swap_read (void) /* {{{ */
{
- perfstat_memory_total_t pmemory;
+ perfstat_memory_total_t pmemory = { 0 };
int status;
gauge_t total;
gauge_t free;
gauge_t reserved;
- memset (&pmemory, 0, sizeof (pmemory));
status = perfstat_memory_total (NULL, &pmemory, sizeof(perfstat_memory_total_t), 1);
if (status < 0)
{