From 3e7cdf1e98f7cc004f23ce65ff09b30f3c14bceb Mon Sep 17 00:00:00 2001 From: cburroughs Date: Fri, 21 Nov 2014 13:57:25 -0500 Subject: [PATCH 1/2] doc typos --- zfs_arc/conf.d/zfs_arc.pyconf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zfs_arc/conf.d/zfs_arc.pyconf b/zfs_arc/conf.d/zfs_arc.pyconf index 7176ae98..10435a2c 100644 --- a/zfs_arc/conf.d/zfs_arc.pyconf +++ b/zfs_arc/conf.d/zfs_arc.pyconf @@ -8,7 +8,7 @@ modules { value = "linux" } # This module calculates all metrics (including derived) rates at - # onces and then serves them out of a cache. This determines the + # once and then serves them out of a cache. This determines the # minimum TTL. param min_poll_seconds { value = 5 @@ -24,7 +24,7 @@ modules { # Ideally some sort of unsigned integer would be used for # measurements of bytes of memory. gmond/modpython on a # particular architecture does not necessarily support 64bit (let - # along zfs's 128bit) integers. If true this flag reports all + # alone zfs's 128bit) integers. If true this flag reports all # metrics as doubles. param force_double { value = True From 4652800a3439fa7af10ed918774791b947d0cc28 Mon Sep 17 00:00:00 2001 From: cburroughs Date: Fri, 21 Nov 2014 15:21:12 -0500 Subject: [PATCH 2/2] fix handling of boolean config files Config values appear to all be treated as strings regardless of quotes. That mean `"True"` is not `True` and thus '"True" is True` is false. This would result in garbage values being recorded and all of the problems that `force_double` was supposed to address. --- zfs_arc/python_modules/zfs_arc.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/zfs_arc/python_modules/zfs_arc.py b/zfs_arc/python_modules/zfs_arc.py index 6b145a78..ff05fb9e 100644 --- a/zfs_arc/python_modules/zfs_arc.py +++ b/zfs_arc/python_modules/zfs_arc.py @@ -179,6 +179,14 @@ 'units': 'bytes/s'}, ] +def sbool(s): + """ convert a string that is probably supposed to be a boolean + value into an actual bool type.""" + if isinstance(s, str): + return s.lower() in ['true', '1', 't', 'y', 'yes', 'yeah', 'yup', 'certainly', 'uh-huh'] + else: + return bool(s) + ##### Data Access class ArcStats(object): @@ -338,7 +346,7 @@ def metric_init(params): d['name'] = METRIC_PREFIX + d['name'] d['call_back'] = ARC_STATS.get_metric_value descriptors.append(d) - if params['force_double'] is True: + if sbool(params['force_double']) is True: d['value_type'] = 'double' d['format'] = '%f' log.debug('descriptors: %r' % descriptors)