mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 00:24:40 +00:00
vmstat, better handling of irq counters, for https://github.com/opnsense/core/issues/1662
This commit is contained in:
parent
f15eb3b203
commit
932a086ea7
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user