Skip to content

Commit

Permalink
fix handling of boolean config files
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cburroughs committed Nov 21, 2014
1 parent 3e7cdf1 commit 4652800
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion zfs_arc/python_modules/zfs_arc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4652800

Please sign in to comment.