Skip to content

Commit bd9cb6c

Browse files
committed
Diskio plugin make Glances 4.5.0.5 crash on OpenBSD #3452
1 parent ee2dfa5 commit bd9cb6c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

glances/plugins/diskio/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ def update_latency(self, stats):
128128
# Compute read/write latency if we have the rate stats
129129
for stat in stats:
130130
# Compute read/write latency if we have the rate stats
131-
if stat.get("read_count_rate_per_sec", 0) > 0:
131+
if 'read_time_rate_per_sec' in stat and stat.get("read_count_rate_per_sec", 0) > 0:
132132
stat["read_latency"] = int(stat["read_time_rate_per_sec"] / stat["read_count_rate_per_sec"])
133133
else:
134134
stat["read_latency"] = 0
135135

136-
if stat.get("write_count_rate_per_sec", 0) > 0:
136+
if 'write_time_rate_per_sec' in stat and stat.get("write_count_rate_per_sec", 0) > 0:
137137
stat["write_latency"] = int(stat["write_time_rate_per_sec"] / stat["write_count_rate_per_sec"])
138138
else:
139139
stat["write_latency"] = 0

glances/plugins/plugin/model.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,9 @@ def compute_rate(self, stat, stat_previous):
11961196
# 2) compute the _rate_per_sec
11971197
# 3) set the original field to the delta between the current and the previous value
11981198
for field in self.fields_description:
1199+
# Check if the field exist (avoid error on some OS where some fields are not available)
1200+
if field not in stat:
1201+
continue
11991202
# For all the field with the rate=True flag
12001203
# if 'rate' in self.fields_description[field] and self.fields_description[field]['rate'] is True:
12011204
if self.fields_description[field].get('rate', False):

0 commit comments

Comments
 (0)