summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sbin/pfctl/pfctl.c7
-rw-r--r--sbin/pfctl/pfctl.h4
-rw-r--r--sbin/pfctl/pfctl_qstats.c25
3 files changed, 29 insertions, 7 deletions
diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c
index 1bd82c67048..de7e271b5fa 100644
--- a/sbin/pfctl/pfctl.c
+++ b/sbin/pfctl/pfctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl.c,v 1.139 2003/01/21 19:12:08 camield Exp $ */
+/* $OpenBSD: pfctl.c,v 1.140 2003/01/24 11:11:17 henning Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -1479,7 +1479,8 @@ main(int argc, char *argv[])
pfctl_show_nat(dev, opts);
break;
case 'q':
- pfctl_show_altq(dev, opts & PF_OPT_VERBOSE);
+ pfctl_show_altq(dev, opts & PF_OPT_VERBOSE,
+ opts & PF_OPT_VERBOSE2);
break;
case 's':
pfctl_show_states(dev, 0, opts);
@@ -1496,7 +1497,7 @@ main(int argc, char *argv[])
case 'a':
pfctl_show_rules(dev, opts, 0);
pfctl_show_nat(dev, opts);
- pfctl_show_altq(dev, opts & PF_OPT_VERBOSE);
+ pfctl_show_altq(dev, opts & PF_OPT_VERBOSE, 0);
pfctl_show_states(dev, 0, opts);
pfctl_show_status(dev);
pfctl_show_rules(dev, opts, 1);
diff --git a/sbin/pfctl/pfctl.h b/sbin/pfctl/pfctl.h
index 2ac1ef54de4..4ad60ff3f07 100644
--- a/sbin/pfctl/pfctl.h
+++ b/sbin/pfctl/pfctl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl.h,v 1.8 2003/01/24 10:53:32 henning Exp $ */
+/* $OpenBSD: pfctl.h,v 1.9 2003/01/24 11:11:17 henning Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -58,7 +58,7 @@ int pfr_ina_define(struct pfr_table *, struct pfr_addr *, int, int *,
int pfctl_clear_tables(int);
int pfctl_show_tables(int);
int pfctl_command_tables(int, char *[], char *, char *, char *, int);
-int pfctl_show_altq(int, int);
+int pfctl_show_altq(int, int, int);
#ifndef DEFAULT_PRIORITY
#define DEFAULT_PRIORITY 1
diff --git a/sbin/pfctl/pfctl_qstats.c b/sbin/pfctl/pfctl_qstats.c
index 5e24097e0ac..96542ea977e 100644
--- a/sbin/pfctl/pfctl_qstats.c
+++ b/sbin/pfctl/pfctl_qstats.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl_qstats.c,v 1.9 2003/01/24 10:22:11 henning Exp $ */
+/* $OpenBSD: pfctl_qstats.c,v 1.10 2003/01/24 11:11:17 henning Exp $ */
/*
* Copyright (c) 2003 Henning Brauer
@@ -91,7 +91,7 @@ double calc_rate(u_int64_t, u_int64_t, double);
double calc_pps(u_int64_t, u_int64_t, double);
int
-pfctl_show_altq(int dev, int verbose)
+pfctl_show_altq(int dev, int verbose, int verbose2)
{
struct pf_altq_node *root = NULL, *node;
@@ -100,6 +100,15 @@ pfctl_show_altq(int dev, int verbose)
for (node = root; node != NULL; node = node->next)
pfctl_print_altq_node(dev, node, 0, verbose);
+
+ while (verbose2) {
+ printf("\n");
+ sleep(5);
+ if (pfctl_update_qstats(dev, &root))
+ return (-1);
+ for (node = root; node != NULL; node = node->next)
+ pfctl_print_altq_node(dev, node, 0, verbose);
+ }
pfctl_free_altq_node(root);
return (0);
}
@@ -260,6 +269,8 @@ pfctl_print_altq_nodestat(int dev, const struct pf_altq_node *a)
void
print_cbqstats(struct queue_stats cur, struct queue_stats last)
{
+ double interval;
+
printf("[ pkts: %10llu bytes: %10llu "
"dropped pkts: %6llu bytes: %6llu ]\n",
cur.data.cbq_stats.xmit_cnt.packets,
@@ -269,6 +280,16 @@ print_cbqstats(struct queue_stats cur, struct queue_stats last)
printf("[ qlength: %3d/%3d borrows: %6u suspends: %6u ]\n",
cur.data.cbq_stats.qcnt, cur.data.cbq_stats.qmax,
cur.data.cbq_stats.borrows, cur.data.cbq_stats.delays);
+
+ if (!last.valid)
+ return;
+
+ interval = calc_interval(&cur.timestamp, &last.timestamp);
+ printf("[ measured: %7.1f packets/s, %s/s ]\n",
+ calc_pps(cur.data.cbq_stats.xmit_cnt.packets,
+ last.data.cbq_stats.xmit_cnt.packets, interval),
+ rate2str(calc_rate(cur.data.cbq_stats.xmit_cnt.bytes,
+ last.data.cbq_stats.xmit_cnt.bytes, interval)));
}
void