zfs_arc: Don't spam the log if we fail to read the "l2_size" kstat value.
[collectd.git] / src / zfs_arc.c
index aa90019..311a718 100644 (file)
@@ -63,7 +63,7 @@ static int za_read_derive (kstat_t *ksp, const char *kstat_value,
   tmp = get_kstat_value (ksp, (char *)kstat_value);
   if (tmp == -1LL)
   {
-    ERROR ("zfs_arc plugin: Reading kstat value \"%s\" failed.", kstat_value);
+    WARNING ("zfs_arc plugin: Reading kstat value \"%s\" failed.", kstat_value);
     return (-1);
   }
 
@@ -81,7 +81,7 @@ static int za_read_gauge (kstat_t *ksp, const char *kstat_value,
   tmp = get_kstat_value (ksp, (char *)kstat_value);
   if (tmp == -1LL)
   {
-    ERROR ("zfs_arc plugin: Reading kstat value \"%s\" failed.", kstat_value);
+    WARNING ("zfs_arc plugin: Reading kstat value \"%s\" failed.", kstat_value);
     return (-1);
   }
 
@@ -120,12 +120,21 @@ 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, "allocated","cache_operation", "allocated");
        za_read_derive (ksp, "deleted",  "cache_operation", "deleted");
+#if __FreeBSD__
+       za_read_derive (ksp, "allocated","cache_operation", "allocated");
        za_read_derive (ksp, "stolen",   "cache_operation", "stolen");
+#endif
 
         /* Issue indicators */
         za_read_derive (ksp, "mutex_miss", "mutex_operations", "miss");