iocost_monitor: Always use strings for json values

Json has limited accuracy for numbers and can silently truncate 64bit
values, which can be extremely confusing.  Let's consistently use
string encapsulated values for json output.

While at it, convert an unnecesary f-string to str().

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Tejun Heo 2019-09-04 12:45:54 -07:00 committed by Jens Axboe
parent e1518f63f2
commit e742bd5cb5
1 changed files with 20 additions and 20 deletions

View File

@ -111,14 +111,14 @@ class IocStat:
def dict(self, now): def dict(self, now):
return { 'device' : devname, return { 'device' : devname,
'timestamp' : now, 'timestamp' : str(now),
'enabled' : self.enabled, 'enabled' : str(int(self.enabled)),
'running' : self.running, 'running' : str(int(self.running)),
'period_ms' : self.period_ms, 'period_ms' : str(self.period_ms),
'period_at' : self.period_at, 'period_at' : str(self.period_at),
'period_vtime_at' : self.vperiod_at, 'period_vtime_at' : str(self.vperiod_at),
'busy_level' : self.busy_level, 'busy_level' : str(self.busy_level),
'vrate_pct' : self.vrate_pct, } 'vrate_pct' : str(self.vrate_pct), }
def table_preamble_str(self): def table_preamble_str(self):
state = ('RUN' if self.running else 'IDLE') if self.enabled else 'OFF' state = ('RUN' if self.running else 'IDLE') if self.enabled else 'OFF'
@ -171,19 +171,19 @@ class IocgStat:
def dict(self, now, path): def dict(self, now, path):
out = { 'cgroup' : path, out = { 'cgroup' : path,
'timestamp' : now, 'timestamp' : str(now),
'is_active' : self.is_active, 'is_active' : str(int(self.is_active)),
'weight' : self.weight, 'weight' : str(self.weight),
'weight_active' : self.active, 'weight_active' : str(self.active),
'weight_inuse' : self.inuse, 'weight_inuse' : str(self.inuse),
'hweight_active_pct' : self.hwa_pct, 'hweight_active_pct' : str(self.hwa_pct),
'hweight_inuse_pct' : self.hwi_pct, 'hweight_inuse_pct' : str(self.hwi_pct),
'inflight_pct' : self.inflight_pct, 'inflight_pct' : str(self.inflight_pct),
'use_delay' : self.use_delay, 'use_delay' : str(self.use_delay),
'delay_ms' : self.delay_ms, 'delay_ms' : str(self.delay_ms),
'usage_pct' : self.usage } 'usage_pct' : str(self.usage) }
for i in range(len(self.usages)): for i in range(len(self.usages)):
out[f'usage_pct_{i}'] = f'{self.usages[i]}' out[f'usage_pct_{i}'] = str(self.usages[i])
return out return out
def table_row_str(self, path): def table_row_str(self, path):