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__': ...@@ -40,18 +40,22 @@ if __name__ == '__main__':
subprocess.call(['/usr/bin/vmstat', '-i'], stdout=output_stream, stderr=open(os.devnull, 'wb')) subprocess.call(['/usr/bin/vmstat', '-i'], stdout=output_stream, stderr=open(os.devnull, 'wb'))
output_stream.seek(0) output_stream.seek(0)
data = output_stream.read().strip() data = output_stream.read().strip()
intf = None intf = None
interrupts = dict() interrupts = dict()
interrupt_map = dict() interrupt_map = dict()
for line in data.split('\n'): for line in data.split('\n'):
if line.find(':') > -1: if line.find(':') > -1:
intrp = line.split(':')[0].strip() intrp = line.split(':')[0].strip()
parts = line.split(':')[1].split() parts = ':'.join(line.split(':')[1:]).split()
interrupts[intrp] = {'devices': [], 'total': None, 'rate': None} interrupts[intrp] = {'devices': [], 'total': None, 'rate': None}
for part in parts: for part in parts:
if not part.isdigit(): if not part.isdigit():
interrupts[intrp]['devices'].append(part) 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: elif interrupts[intrp]['total'] is None:
interrupts[intrp]['total'] = int(part) interrupts[intrp]['total'] = int(part)
else: else:
......
...@@ -438,17 +438,30 @@ include("head.inc"); ...@@ -438,17 +438,30 @@ include("head.inc");
<?php <?php
endif; endif;
if (!empty($vmstat_interupts['interrupt_map'][$ifinfo['if']])): if (!empty($vmstat_interupts['interrupt_map'][$ifinfo['if']])):
$intrpt = $vmstat_interupts['interrupt_map'][$ifinfo['if']]; $intrpts = $vmstat_interupts['interrupt_map'][$ifinfo['if']];?>
$interrupt_total = $vmstat_interupts['interrupts'][$intrpt]['total'];
$interrupt_rate = $vmstat_interupts['interrupts'][$intrpt]['rate'];?>
<tr> <tr>
<td><?= gettext("Interrupts per Second") ?></td> <td><?= gettext("Interrupts") ?></td>
<td> <td>
<?php <table class="table">
printf(gettext("%s total"),$interrupt_total); <thead>
echo "<br />"; <tr>
printf(gettext("%s rate"),$interrupt_rate); <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> </td>
</tr> </tr>
<?php <?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