X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fzfs_arc.c;h=b784ee3a3fc1374a66e03f12b432c625ae48dce1;hb=1bbefd777881fee2534b976d161743c5fe6fc536;hp=ebfc54b4453c1e00166ae6dfc08e0695eac09b44;hpb=3e0942fc2d97a3028b9244fde6605c9ba68224fe;p=collectd.git diff --git a/src/zfs_arc.c b/src/zfs_arc.c index ebfc54b4..b784ee3a 100644 --- a/src/zfs_arc.c +++ b/src/zfs_arc.c @@ -4,6 +4,7 @@ * 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 @@ -23,6 +24,7 @@ * Aurelien Rougemont * Xin Li * Marc Fournier + * Wilfried Goesgens **/ #include "collectd.h" @@ -51,7 +53,7 @@ static long long get_zfs_value(kstat_t *zfs_stats __attribute__((unused)), return (-1); } - return ((long long int)e->value); + return (*(long long int*)e->value); } #elif !defined(__FreeBSD__) // Solaris @@ -172,7 +174,7 @@ static int za_read (void) #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; @@ -184,15 +186,15 @@ static int za_read (void) 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) { @@ -206,21 +208,21 @@ static int za_read (void) { 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], &llvalues[i]); + e = llentry_create (fields[0], &llvalues[j]); if (e == NULL) { ERROR ("zfs_arc plugin: `llentry_create' failed."); @@ -229,6 +231,7 @@ static int za_read (void) { llist_append (ksp, e); } + j++; } pnl = pnnl; if (pnl != NULL) @@ -298,7 +301,6 @@ static int za_read (void) } if (ksp != NULL) { - llist_destroy (ksp); } #endif