summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2002-06-11 01:58:01 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2002-06-11 01:58:01 +0000
commite273e728b51194b7f79a3611cc50ca0ac5ce08d7 (patch)
tree3839ca911f319d1dd5e4745be5478826ac2298ac
parenta301008037443233d7cb25cfd4d4bb16dc52977d (diff)
rework pfctl statistics display
move FCNT_NAMES from pfvar.h to pfctl_parser.h, only used by pfctl some input by nick@ ok frantzen@, dhartmei@
-rw-r--r--sbin/pfctl/pfctl_parser.c86
-rw-r--r--sbin/pfctl/pfctl_parser.h10
-rw-r--r--sys/net/pf_ioctl.c3
-rw-r--r--sys/net/pfvar.h9
4 files changed, 68 insertions, 40 deletions
diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c
index f3c0b8974fd..c9c7d1d7f6c 100644
--- a/sbin/pfctl/pfctl_parser.c
+++ b/sbin/pfctl/pfctl_parser.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl_parser.c,v 1.85 2002/06/10 19:31:44 dhartmei Exp $ */
+/* $OpenBSD: pfctl_parser.c,v 1.86 2002/06/11 01:58:00 henning Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -537,48 +537,72 @@ char *pf_fcounters[FCNT_MAX+1] = FCNT_NAMES;
void
print_status(struct pf_status *s)
{
- time_t t = time(NULL);
+ time_t runtime;
int i;
+ char statline[80];
- printf("Status: %s Time: %u Since: %u Debug: ",
- s->running ? "Enabled" : "Disabled",
- t, s->since);
+ runtime = time(NULL) - s->since;
+
+ if ( s->running )
+ snprintf(statline, sizeof(statline),
+ "Status: Enabled for %us ", runtime);
+ else
+ snprintf(statline, sizeof(statline), "Status: Disabled");
+ printf("%-34s", statline);
switch (s->debug) {
case 0:
- printf("None");
+ printf("%25s\n\n", "Debug: None");
break;
case 1:
- printf("Urgent");
+ printf("%25s\n\n", "Debug: Urgent");
break;
case 2:
- printf("Misc");
+ printf("%25s\n\n", "Debug: Misc");
break;
}
- printf("\nBytes In IPv4: %-10llu Bytes Out: %-10llu\n",
- s->bcounters[0][PF_IN], s->bcounters[0][PF_OUT]);
- printf(" IPv6: %-10llu Bytes Out: %-10llu\n",
- s->bcounters[1][PF_IN], s->bcounters[1][PF_OUT]);
- printf("Inbound Packets IPv4: Passed: %-10llu Dropped: %-10llu\n",
- s->pcounters[0][PF_IN][PF_PASS],
- s->pcounters[0][PF_IN][PF_DROP]);
- printf(" IPv6: Passed: %-10llu Dropped: %-10llu\n",
- s->pcounters[1][PF_IN][PF_PASS],
- s->pcounters[1][PF_IN][PF_DROP]);
- printf("Outbound Packets IPv4: Passed: %-10llu Dropped: %-10llu\n",
- s->pcounters[0][PF_OUT][PF_PASS],
- s->pcounters[0][PF_OUT][PF_DROP]);
- printf(" IPv6: Passed: %-10llu Dropped: %-10llu\n",
- s->pcounters[1][PF_OUT][PF_PASS],
- s->pcounters[1][PF_OUT][PF_DROP]);
- printf("States: %u\n", s->states);
- printf("pf Counters\n");
- for (i = 0; i < FCNT_MAX; i++)
- printf("%-25s %-8lld\n", pf_fcounters[i],
- s->fcounters[i]);
+ if (s->ifname[0] != 0) {
+ printf("Interface Stats for %-16s %5s %16s\n",
+ s->ifname, "IPv4", "IPv6");
+ printf(" %-25s %14llu %16llu\n", "Bytes In",
+ s->bcounters[0][PF_IN], s->bcounters[1][PF_IN]);
+ printf(" %-25s %14llu %16llu\n", "Bytes Out",
+ s->bcounters[0][PF_OUT], s->bcounters[1][PF_OUT]);
+ printf(" Packets In\n");
+ printf(" %-23s %14llu %16llu\n", "Passed",
+ s->pcounters[0][PF_IN][PF_PASS],
+ s->pcounters[1][PF_IN][PF_PASS]);
+ printf(" %-23s %14llu %16llu\n", "Blocked",
+ s->pcounters[0][PF_IN][PF_DROP],
+ s->pcounters[1][PF_IN][PF_DROP]);
+ printf(" Packets Out\n");
+ printf(" %-23s %14llu %16llu\n", "Passed",
+ s->pcounters[0][PF_OUT][PF_PASS],
+ s->pcounters[1][PF_OUT][PF_PASS]);
+ printf(" %-23s %14llu %16llu\n\n", "Blocked",
+ s->pcounters[0][PF_OUT][PF_DROP],
+ s->pcounters[1][PF_OUT][PF_DROP]);
+ }
+ printf("%-27s %14s %16s\n", "State Table", "Total", "Rate");
+ printf(" %-25s %14u %14s\n", "current entries", s->states, "");
+ for (i = 0; i < FCNT_MAX; i++) {
+ printf(" %-25s %14lld ", pf_fcounters[i],
+ s->fcounters[i]);
+ if ( runtime > 0 )
+ printf("%14.1f/s\n",
+ (double)s->fcounters[i] / (double)runtime);
+ else
+ printf("%14s\n", "");
+ }
printf("Counters\n");
- for (i = 0; i < PFRES_MAX; i++)
- printf("%-25s %-8lld\n", pf_reasons[i],
+ for (i = 0; i < PFRES_MAX; i++) {
+ printf(" %-25s %14lld ", pf_reasons[i],
s->counters[i]);
+ if ( runtime > 0 )
+ printf("%14.1f/s\n",
+ (double)s->counters[i] / (double)runtime);
+ else
+ printf("%14s\n", "");
+ }
}
void
diff --git a/sbin/pfctl/pfctl_parser.h b/sbin/pfctl/pfctl_parser.h
index 0d1c6e092d7..3498c3adb81 100644
--- a/sbin/pfctl/pfctl_parser.h
+++ b/sbin/pfctl/pfctl_parser.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl_parser.h,v 1.20 2002/06/08 21:09:59 dhartmei Exp $ */
+/* $OpenBSD: pfctl_parser.h,v 1.21 2002/06/11 01:58:00 henning Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -43,6 +43,14 @@
#define PF_TH_ALL 0xFF
+#define FCNT_NAMES { \
+ "searches", \
+ "inserts", \
+ "removals", \
+ NULL \
+}
+
+
struct pfctl {
int dev;
int opts;
diff --git a/sys/net/pf_ioctl.c b/sys/net/pf_ioctl.c
index b2b4723ea6b..68fc6cac57f 100644
--- a/sys/net/pf_ioctl.c
+++ b/sys/net/pf_ioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf_ioctl.c,v 1.4 2002/06/10 18:52:44 dhartmei Exp $ */
+/* $OpenBSD: pf_ioctl.c,v 1.5 2002/06/11 01:58:00 henning Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -1324,6 +1324,7 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
error = EINVAL;
else
status_ifp = ifp;
+ strlcpy(pf_status.ifname, ifp->if_xname, IFNAMSIZ);
break;
}
diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h
index 39abee4967c..0cac8668da4 100644
--- a/sys/net/pfvar.h
+++ b/sys/net/pfvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfvar.h,v 1.82 2002/06/09 20:20:58 dhartmei Exp $ */
+/* $OpenBSD: pfvar.h,v 1.83 2002/06/11 01:58:00 henning Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -432,12 +432,6 @@ struct pf_pdesc {
#define FCNT_STATE_REMOVALS 2
#define FCNT_MAX 3
-#define FCNT_NAMES { \
- "state searches", \
- "state inserts", \
- "state removals", \
- NULL \
-}
#define ACTION_SET(a, x) \
do { \
@@ -462,6 +456,7 @@ struct pf_status {
u_int32_t states;
u_int32_t since;
u_int32_t debug;
+ char ifname[IFNAMSIZ];
};
#define PFFRAG_FRENT_HIWAT 5000 /* Number of fragment entries */