Skip to content

Commit

Permalink
Merge pull request #173 from cburroughs/uint-mystery
Browse files Browse the repository at this point in the history
fix handling of boolean config files
  • Loading branch information
jbuchbinder committed Dec 8, 2014
2 parents 225594d + 4652800 commit 1974800
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions zfs_arc/conf.d/zfs_arc.pyconf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
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 1974800

Please sign in to comment.