Handle no-permission when checking IRQs on Alpine Linux (#962)

pull/966/head
Alessio Sergi 2016-11-10 17:01:55 +01:00
parent 4e3ce5ef42
commit c24cca191d
1 changed files with 23 additions and 20 deletions

View File

@ -194,25 +194,28 @@ class GlancesIRQ(object):
# Correct issue #947: IRQ file do not exist on OpenVZ container
return self.stats
with open(self.IRQ_FILE) as irq_proc:
time_since_update = getTimeSinceLastUpdate('irq')
# Read the header
self.__header(irq_proc.readline())
# Read the rest of the lines (one line per IRQ)
for line in irq_proc.readlines():
irq_line = self.__humanname(line)
current_irqs = self.__sum(line)
irq_rate = int(
current_irqs -
self.lasts.get(irq_line) if self.lasts.get(irq_line) else 0 //
time_since_update)
irq_current = {
'irq_line': irq_line,
'irq_rate': irq_rate,
'key': self.get_key(),
'time_since_update': time_since_update
}
self.stats.append(irq_current)
self.lasts[irq_line] = current_irqs
try:
with open(self.IRQ_FILE) as irq_proc:
time_since_update = getTimeSinceLastUpdate('irq')
# Read the header
self.__header(irq_proc.readline())
# Read the rest of the lines (one line per IRQ)
for line in irq_proc.readlines():
irq_line = self.__humanname(line)
current_irqs = self.__sum(line)
irq_rate = int(
current_irqs - self.lasts.get(irq_line)
if self.lasts.get(irq_line)
else 0 // time_since_update)
irq_current = {
'irq_line': irq_line,
'irq_rate': irq_rate,
'key': self.get_key(),
'time_since_update': time_since_update
}
self.stats.append(irq_current)
self.lasts[irq_line] = current_irqs
except (OSError, IOError):
pass
return self.stats