Commit 932a086e authored by Ad Schellevis's avatar Ad Schellevis

vmstat, better handling of irq counters, for https://github.com/opnsense/core/issues/1662

parent f15eb3b2
......@@ -40,18 +40,22 @@ if __name__ == '__main__':
subprocess.call(['/usr/bin/vmstat', '-i'], stdout=output_stream, stderr=open(os.devnull, 'wb'))
output_stream.seek(0)
data = output_stream.read().strip()
intf = None
interrupts = dict()
interrupt_map = dict()
for line in data.split('\n'):
if line.find(':') > -1:
intrp = line.split(':')[0].strip()
parts = line.split(':')[1].split()
parts = ':'.join(line.split(':')[1:]).split()
interrupts[intrp] = {'devices': [], 'total': None, 'rate': None}
for part in parts:
if not part.isdigit():
interrupts[intrp]['devices'].append(part)
interrupt_map[part] = intrp
devnm = part.split(':')[0]
if devnm not in interrupt_map:
interrupt_map[devnm] = list()
interrupt_map[devnm].append(intrp)
elif interrupts[intrp]['total'] is None:
interrupts[intrp]['total'] = int(part)
else:
......
......@@ -438,17 +438,30 @@ include("head.inc");
<?php
endif;
if (!empty($vmstat_interupts['interrupt_map'][$ifinfo['if']])):
$intrpt = $vmstat_interupts['interrupt_map'][$ifinfo['if']];
$interrupt_total = $vmstat_interupts['interrupts'][$intrpt]['total'];
$interrupt_rate = $vmstat_interupts['interrupts'][$intrpt]['rate'];?>
$intrpts = $vmstat_interupts['interrupt_map'][$ifinfo['if']];?>
<tr>
<td><?= gettext("Interrupts per Second") ?></td>
<td><?= gettext("Interrupts") ?></td>
<td>
<?php
printf(gettext("%s total"),$interrupt_total);
echo "<br />";
printf(gettext("%s rate"),$interrupt_rate);
?>
<table class="table">
<thead>
<tr>
<th><?=gettext("irq");?></th>
<th><?=gettext("device");?></th>
<th><?=gettext("total");?></th>
<th><?=gettext("rate");?></th>
</tr>
</thead>
<?php
foreach ($intrpts as $intrpt):?>
<tr>
<td><?=$intrpt;?></td>
<td><?=implode(' ', $vmstat_interupts['interrupts'][$intrpt]['devices']);?></td>
<td><?=$vmstat_interupts['interrupts'][$intrpt]['total'];?></td>
<td><?=$vmstat_interupts['interrupts'][$intrpt]['rate'];?></td>
</tr>
<?php
endforeach; ?>
</table>
</td>
</tr>
<?php
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment