Commit 6401d20e authored by Ad Schellevis's avatar Ad Schellevis

step one, cleaning up get_interface_info(), move pfctl calls to configd. for...

step one, cleaning up get_interface_info(), move pfctl calls to configd. for https://github.com/opnsense/core/issues/1662
parent b6e4e56e
......@@ -4651,49 +4651,6 @@ function get_interface_info($ifdescr)
$ifinfo['outerrs'] = $ifinfotmp['output errors'];
$ifinfo['collisions'] = $ifinfotmp['collisions'];
/* Use pfctl for non wrapping 64 bit counters */
/* Pass */
exec("/sbin/pfctl -vvsI -i {$chkif}", $pfctlstats);
$pf_in4_pass = preg_split("/ +/ ", $pfctlstats[3]);
$pf_out4_pass = preg_split("/ +/", $pfctlstats[5]);
$pf_in6_pass = preg_split("/ +/ ", $pfctlstats[7]);
$pf_out6_pass = preg_split("/ +/", $pfctlstats[9]);
$in4_pass = $pf_in4_pass[5];
$out4_pass = $pf_out4_pass[5];
$in4_pass_packets = $pf_in4_pass[3];
$out4_pass_packets = $pf_out4_pass[3];
$in6_pass = $pf_in6_pass[5];
$out6_pass = $pf_out6_pass[5];
$in6_pass_packets = $pf_in6_pass[3];
$out6_pass_packets = $pf_out6_pass[3];
$ifinfo['inbytespass'] = $in4_pass + $in6_pass;
$ifinfo['outbytespass'] = $out4_pass + $out6_pass;
$ifinfo['inpktspass'] = $in4_pass_packets + $in6_pass_packets;
$ifinfo['outpktspass'] = $out4_pass_packets + $out6_pass_packets;
/* Block */
$pf_in4_block = preg_split("/ +/", $pfctlstats[4]);
$pf_out4_block = preg_split("/ +/", $pfctlstats[6]);
$pf_in6_block = preg_split("/ +/", $pfctlstats[8]);
$pf_out6_block = preg_split("/ +/", $pfctlstats[10]);
$in4_block = $pf_in4_block[5];
$out4_block = $pf_out4_block[5];
$in4_block_packets = $pf_in4_block[3];
$out4_block_packets = $pf_out4_block[3];
$in6_block = $pf_in6_block[5];
$out6_block = $pf_out6_block[5];
$in6_block_packets = $pf_in6_block[3];
$out6_block_packets = $pf_out6_block[3];
$ifinfo['inbytesblock'] = $in4_block + $in6_block;
$ifinfo['outbytesblock'] = $out4_block + $out6_block;
$ifinfo['inpktsblock'] = $in4_block_packets + $in6_block_packets;
$ifinfo['outpktsblock'] = $out4_block_packets + $out6_block_packets;
$ifinfo['inbytes'] = $in4_pass + $in6_pass;
$ifinfo['outbytes'] = $out4_pass + $out6_pass;
$ifinfo['inpkts'] = $in4_pass_packets + $in6_pass_packets;
$ifinfo['outpkts'] = $out4_pass_packets + $out6_pass_packets;
$ifconfiginfo = "";
$link_type = $config['interfaces'][$ifdescr]['ipaddr'];
switch ($link_type) {
......
......@@ -47,6 +47,12 @@ parameters: %s
type:script_output
message:request pfsync info
[list.counters]
command:/usr/local/opnsense/scripts/filter/list_counters.py
parameters: %s
type:script_output
message:request pfctl byte/packet counters
[delete.table]
command:/usr/local/opnsense/scripts/filter/delete_table.py
parameters: %s %s
......
......@@ -64,8 +64,10 @@ include("head.inc");
<section class="col-xs-12">
<?php
$mac_man = json_decode(configd_run("interface list macdb json"), true);
$pfctl_counters = json_decode(configd_run("filter list counters json"), true);
foreach (get_configured_interface_with_descr(false, true) as $ifdescr => $ifname):
$ifinfo = get_interface_info($ifdescr);
$ifpfcounters = $pfctl_counters[$ifinfo['if']];
legacy_html_escape_form_data($ifinfo);
$ifdescr = htmlspecialchars($ifdescr);
$ifname = htmlspecialchars($ifname);
......@@ -392,20 +394,20 @@ include("head.inc");
endif; ?>
<tr>
<td><?= gettext("In/out packets") ?></td>
<td> <?= $ifinfo['inpkts'] ?> / <?= $ifinfo['outpkts'] ?>
(<?= format_bytes($ifinfo['inbytes']);?> / <?=format_bytes($ifinfo['outbytes']);?> )
<td> <?= $ifpfcounters['inpkts'] ?> / <?= $ifpfcounters['outpkts'] ?>
(<?= format_bytes($ifpfcounters['inbytes']);?> / <?=format_bytes($ifpfcounters['outbytes']);?> )
</td>
</tr>
<tr>
<td><?= gettext("In/out packets (pass)") ?></td>
<td> <?= $ifinfo['inpktspass'] ?> / <?= $ifinfo['outpktspass'] ?>
(<?= format_bytes($ifinfo['inbytespass']) ?> / <?= format_bytes($ifinfo['outbytespass']) ?> )
<td> <?= $ifpfcounters['inpktspass'] ?> / <?= $ifpfcounters['outpktspass'] ?>
(<?= format_bytes($ifpfcounters['inbytespass']) ?> / <?= format_bytes($ifpfcounters['outbytespass']) ?> )
</td>
</tr>
<tr>
<td><?= gettext("In/out packets (block)") ?></td>
<td> <?= $ifinfo['inpktsblock'] ?> / <?= $ifinfo['outpktsblock'] ?>
(<?= format_bytes($ifinfo['inbytesblock']) ?> / <?= format_bytes($ifinfo['outbytesblock']) ?> )
<td> <?= $ifpfcounters['inpktsblock'] ?> / <?= $ifpfcounters['outpktsblock'] ?>
(<?= format_bytes($ifpfcounters['inbytesblock']) ?> / <?= format_bytes($ifpfcounters['outbytesblock']) ?> )
</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