diff --git a/src/zfs_arc.c b/src/zfs_arc.c
index c3c9cf9552f91df788b054204d034ccad00f1de0..f0d23239a82ab158c03c669f9a96cf2fc7f8dd24 100644 (file)
--- a/src/zfs_arc.c
+++ b/src/zfs_arc.c
* Copyright (C) 2012 Aurelien Rougemont
* Copyright (C) 2013 Xin Li
* Copyright (C) 2014 Marc Fournier
+ * Copyright (C) 2014 Wilfried Goesgens
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Aurelien Rougemont <beorn at gandi.net>
* Xin Li <delphij at FreeBSD.org>
* Marc Fournier <marc.fournier at camptocamp.com>
+ * Wilfried Goesgens <dothebart at citadel.org>
**/
#include "collectd.h"
return (-1);
}
- return ((long long int)e->value);
+ return (*(long long int*)e->value);
}
#elif !defined(__FreeBSD__) // Solaris
#if KERNEL_LINUX
long long int *llvalues = NULL;
- char FileContents[1024 * 10];
+ char file_contents[1024 * 10];
char *fields[3];
int numfields;
ssize_t len;
return (-1);
}
- len = read_file_contents (ZOL_ARCSTATS_FILE, FileContents, sizeof(FileContents));
+ len = read_file_contents (ZOL_ARCSTATS_FILE, file_contents, sizeof(file_contents));
if (len > 1)
{
int i=0;
- char *pnl = FileContents;
+ char *pnl = file_contents;
char *pnnl;
- FileContents[len] = '\0';
+ file_contents[len] = '\0';
while (pnl != NULL)
{
{
llentry_t *e;
llvalues = malloc(sizeof(long long int) * i);
- i = 0;
+ int j = 0;
- pnl = FileContents;
+ pnl = file_contents;
while (pnl != NULL)
{
pnnl = strchr(pnl, '\n');
if (pnnl != NULL)
*pnnl = '\0';
-
+
numfields = strsplit (pnl, fields, 4);
if (numfields == 3)
{
- llvalues[i] = atoll (fields[2]);
+ llvalues[j] = atoll (fields[2]);
- e = llentry_create (fields[0], (void *)llvalues[i]);
+ e = llentry_create (fields[0], &llvalues[j]);
if (e == NULL)
{
ERROR ("zfs_arc plugin: `llentry_create' failed.");
{
llist_append (ksp, e);
}
+ j++;
}
pnl = pnnl;
if (pnl != NULL)
/* Sizes */
za_read_gauge (ksp, "size", "cache_size", "arc");
- za_read_gauge (ksp, "l2_size", "cache_size", "L2");
+
+ /* The "l2_size" value has disappeared from Solaris some time in
+ * early 2013, and has only reappeared recently in Solaris 11.2.
+ * Stop trying if we ever fail to read it, so we don't spam the log.
+ */
+ static int l2_size_avail = 1;
+ if (l2_size_avail && za_read_gauge (ksp, "l2_size", "cache_size", "L2") != 0)
+ l2_size_avail = 0;
/* Operations */
za_read_derive (ksp, "deleted", "cache_operation", "deleted");
}
if (ksp != NULL)
{
-
llist_destroy (ksp);
}
#endif