za_submit (type, type_instance, &vv, 1);
}
-static void za_submit_derive (const char* type, const char* type_instance, derive_t dv)
+static int za_read_derive (kstat_t *ksp, const char *kstat_value,
+ const char *type, const char *type_instance)
{
- value_t vv;
+ long long tmp;
+ value_t v;
+
+ tmp = get_kstat_value (ksp, kstat_value);
+ if (tmp == -1LL)
+ {
+ ERROR ("zfs_arc plugin: Reading kstat value \"%s\" failed.", kstat_value);
+ return (-1);
+ }
+
+ v.derive = (derive_t) tmp;
+ za_submit (type, type_instance, /* values = */ &v, /* values_num = */ 1);
+}
- vv.derive = dv;
- za_submit (type, type_instance, &vv, 1);
+static int za_read_gauge (kstat_t *ksp, const char *kstat_value,
+ const char *type, const char *type_instance)
+{
+ long long tmp;
+ value_t v;
+
+ tmp = get_kstat_value (ksp, kstat_value);
+ if (tmp == -1LL)
+ {
+ ERROR ("zfs_arc plugin: Reading kstat value \"%s\" failed.", kstat_value);
+ return (-1);
+ }
+
+ v.gauge = (gauge_t) tmp;
+ za_submit (type, type_instance, /* values = */ &v, /* values_num = */ 1);
}
static void za_submit_ratio (const char* type_instance, gauge_t hits, gauge_t misses)
static int za_read (void)
{
- gauge_t arc_size, l2_size;
- derive_t demand_data_hits,
- demand_metadata_hits,
- prefetch_data_hits,
- prefetch_metadata_hits,
- demand_data_misses,
- demand_metadata_misses,
- prefetch_data_misses,
- prefetch_metadata_misses;
gauge_t arc_hits, arc_misses, l2_hits, l2_misses;
value_t l2_io[2];
- derive_t mutex_miss;
- derive_t allocated, deleted, stolen;
- derive_t evict_l2_cached, evict_l2_eligible, evict_l2_ineligible;
- derive_t hash_collisions;
get_kstat (&ksp, "zfs", 0, "arcstats");
if (ksp == NULL)
}
/* Sizes */
- arc_size = get_kstat_value(ksp, "size");
- l2_size = get_kstat_value(ksp, "l2_size");
+ za_read_gauge (ksp, "size", "cache_size", "arc");
+ za_read_gauge (ksp, "l2_size", "cache_size", "L2");
- za_submit_gauge ("cache_size", "arc", arc_size);
- za_submit_gauge ("cache_size", "L2", l2_size);
+ /* Operations */
+ za_read_derive (ksp, "allocated","cache_operation", "allocated");
+ za_read_derive (ksp, "deleted", "cache_operation", "deleted");
+ za_read_derive (ksp, "stolen", "cache_operation", "stolen");
- mutex_miss = get_kstat_value (ksp, "mutex_miss");
- za_submit_derive ("mutex_operation", "miss", mutex_miss);
-
- allocated = get_kstat_value(ksp, "allocated");
- deleted = get_kstat_value(ksp, "deleted");
- stolen = get_kstat_value(ksp, "stolen");
- za_submit_derive ("cache_operation", "allocated", allocated);
- za_submit_derive ("cache_operation", "deleted", deleted);
- za_submit_derive ("cache_operation", "stolen", stolen);
-
- hash_collisions = get_kstat_value(ksp, "hash_collisions");
- za_submit_derive ("hash_collisions", "", hash_collisions);
-
- evict_l2_cached = get_kstat_value(ksp, "evict_l2_cached");
- evict_l2_eligible = get_kstat_value(ksp, "evict_l2_eligible");
- evict_l2_ineligible = get_kstat_value(ksp, "evict_l2_ineligible");
+ /* Issue indicators */
+ za_read_derive (ksp, "mutex_miss", "mutex_operation", "miss");
+ za_read_derive (ksp, "hash_collisions", "hash_collisions", "");
- za_submit_derive ("cache_eviction", "cached", evict_l2_cached);
- za_submit_derive ("cache_eviction", "eligible", evict_l2_eligible);
- za_submit_derive ("cache_eviction", "ineligible", evict_l2_ineligible);
+ /* Evictions */
+ za_read_derive (ksp, "evict_l2_cached", "cache_eviction", "cached");
+ za_read_derive (ksp, "evict_l2_eligible", "cache_eviction", "eligible");
+ za_read_derive (ksp, "evict_l2_ineligible", "cache_eviction", "ineligible");
/* Hits / misses */
- demand_data_hits = get_kstat_value(ksp, "demand_data_hits");
- demand_metadata_hits = get_kstat_value(ksp, "demand_metadata_hits");
- prefetch_data_hits = get_kstat_value(ksp, "prefetch_data_hits");
- prefetch_metadata_hits = get_kstat_value(ksp, "prefetch_metadata_hits");
-
- demand_data_misses = get_kstat_value(ksp, "demand_data_misses");
- demand_metadata_misses = get_kstat_value(ksp, "demand_metadata_misses");
- prefetch_data_misses = get_kstat_value(ksp, "prefetch_data_misses");
- prefetch_metadata_misses = get_kstat_value(ksp, "prefetch_metadata_misses");
-
- za_submit_derive ("cache_result", "demand_data-hit", demand_data_hits);
- za_submit_derive ("cache_result", "demand_metadata-hit", demand_metadata_hits);
- za_submit_derive ("cache_result", "prefetch_data-hit", prefetch_data_hits);
- za_submit_derive ("cache_result", "prefetch_metadata-hit", prefetch_metadata_hits);
-
- za_submit_derive ("cache_result", "demand_data-miss", demand_data_misses);
- za_submit_derive ("cache_result", "demand_metadata-miss", demand_metadata_misses);
- za_submit_derive ("cache_result", "prefetch_data-miss", prefetch_data_misses);
- za_submit_derive ("cache_result", "prefetch_metadata-miss", prefetch_metadata_misses);
+ za_read_derive (ksp, "demand_data_hits", "cache_result", "demand_data-hit");
+ za_read_derive (ksp, "demand_metadata_hits", "cache_result", "demand_metadata-hit");
+ za_read_derive (ksp, "prefetch_data_hits", "cache_result", "prefetch_data-hit");
+ za_read_derive (ksp, "prefetch_metadata_hits", "cache_result", "prefetch_metadata-hit");
+ za_read_derive (ksp, "demand_data_misses", "cache_result", "demand_data-miss");
+ za_read_derive (ksp, "demand_metadata_misses", "cache_result", "demand_metadata-miss");
+ za_read_derive (ksp, "prefetch_data_misses", "cache_result", "prefetch_data-miss");
+ za_read_derive (ksp, "prefetch_metadata_misses", "cache_result", "prefetch_metadata-miss");
/* Ratios */
arc_hits = (gauge_t) get_kstat_value(ksp, "hits");