X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fzfs_arc.c;h=ab5cd64d6dcbcb7a903d3b8c5a64d8b946c5551d;hb=1fc00932fd49fa535551cc4bba09c4e4be059ab4;hp=b784ee3a3fc1374a66e03f12b432c625ae48dce1;hpb=cb314c15d51352ebcc4cfd2bbf1d6a3042c2402f;p=collectd.git diff --git a/src/zfs_arc.c b/src/zfs_arc.c index b784ee3a..ab5cd64d 100644 --- a/src/zfs_arc.c +++ b/src/zfs_arc.c @@ -186,7 +186,7 @@ static int za_read (void) return (-1); } - len = read_file_contents (ZOL_ARCSTATS_FILE, file_contents, sizeof(file_contents)); + len = read_file_contents (ZOL_ARCSTATS_FILE, file_contents, sizeof(file_contents) - 1); if (len > 1) { @@ -208,6 +208,12 @@ static int za_read (void) { llentry_t *e; llvalues = malloc(sizeof(long long int) * i); + if (llvalues == NULL) + { + ERROR ("zfs_arc plugin: `malloc' failed."); + llist_destroy (ksp); + return (-1); + } int j = 0; pnl = file_contents; @@ -251,7 +257,14 @@ static int za_read (void) /* 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");