1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-10 06:47:55 -08:00

expose the interface queue drops in the interface view

by default qdrops and errors are combined in a number of failures.
the qdrops and errors can be viewed separately by using 'd' and 'e'
respectively, or the combined view again with 'f'.

ok claudio@ deraadt@
This commit is contained in:
dlg 2019-03-04 21:27:35 +00:00
parent e7742cb1e5
commit c5f96cb849
3 changed files with 119 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: if.c,v 1.23 2015/01/16 00:03:37 deraadt Exp $ */
/* $OpenBSD: if.c,v 1.24 2019/03/04 21:27:35 dlg Exp $ */
/*
* Copyright (c) 2004 Markus Friedl <markus@openbsd.org>
*
@ -56,6 +56,49 @@ static void showifstat(struct ifstat *);
static void showtotal(void);
static void rt_getaddrinfo(struct sockaddr *, int, struct sockaddr **);
const char ifails[] = "IFAILS";
const char ofails[] = "OFAILS";
#define IF_ERR_SUM 0
#define IF_ERR_ERRORS 1
#define IF_ERR_QDROPS 2
struct if_err_view {
const char *iname;
const char *oname;
uint64_t (*icount)(const struct ifcount *);
uint64_t (*ocount)(const struct ifcount *);
};
static uint64_t if_err_ifails(const struct ifcount *);
static uint64_t if_err_ofails(const struct ifcount *);
static uint64_t if_err_ierrors(const struct ifcount *);
static uint64_t if_err_oerrors(const struct ifcount *);
static uint64_t if_err_iqdrops(const struct ifcount *);
static uint64_t if_err_oqdrops(const struct ifcount *);
static const struct if_err_view if_err_views[] = {
[IF_ERR_SUM] = {
.iname = ifails,
.oname = ofails,
.icount = if_err_ifails,
.ocount = if_err_ofails,
},
[IF_ERR_ERRORS] = {
.iname = "IERRS",
.oname = "OERRS",
.icount = if_err_ierrors,
.ocount = if_err_oerrors,
},
[IF_ERR_QDROPS] = {
.iname = "IQDROPS",
.oname = "OQDROPS",
.icount = if_err_iqdrops,
.ocount = if_err_oqdrops,
},
};
static const struct if_err_view *if_err_view = &if_err_views[IF_ERR_SUM];
/* Define fields */
field_def fields_if[] = {
@ -63,10 +106,10 @@ field_def fields_if[] = {
{"STATE", 4, 6, 1, FLD_ALIGN_LEFT, -1, 0, 0, 0},
{"IPKTS", 5, 8, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0},
{"IBYTES", 5, 8, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0},
{"IERRS", 5, 8, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0},
{ifails, 5, 8, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0},
{"OPKTS", 5, 8, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0},
{"OBYTES", 5, 8, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0},
{"OERRS", 5, 8, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0},
{ofails, 5, 8, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0},
{"COLLS", 5, 8, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0},
{"DESC", 14, 64, 1, FLD_ALIGN_LEFT, -1, 0, 0, 0},
};
@ -264,9 +307,11 @@ fetchifstat(void)
UPDATE(ifc_ip, ifm_data.ifi_ipackets);
UPDATE(ifc_ib, ifm_data.ifi_ibytes);
UPDATE(ifc_ie, ifm_data.ifi_ierrors);
UPDATE(ifc_iq, ifm_data.ifi_iqdrops);
UPDATE(ifc_op, ifm_data.ifi_opackets);
UPDATE(ifc_ob, ifm_data.ifi_obytes);
UPDATE(ifc_oe, ifm_data.ifi_oerrors);
UPDATE(ifc_oq, ifm_data.ifi_oqdrops);
UPDATE(ifc_co, ifm_data.ifi_collisions);
ifs->ifs_cur.ifc_flags = ifm.ifm_flags;
ifs->ifs_cur.ifc_state = ifm.ifm_data.ifi_link_state;
@ -315,11 +360,11 @@ showifstat(struct ifstat *ifs)
print_fld_sdiv(FLD_IF_IBYTES, ifs->ifs_cur.ifc_ib * conv, div);
print_fld_size(FLD_IF_IPKTS, ifs->ifs_cur.ifc_ip);
print_fld_size(FLD_IF_IERRS, ifs->ifs_cur.ifc_ie);
print_fld_size(FLD_IF_IERRS, if_err_view->icount(&ifs->ifs_cur));
print_fld_sdiv(FLD_IF_OBYTES, ifs->ifs_cur.ifc_ob * conv, div);
print_fld_size(FLD_IF_OPKTS, ifs->ifs_cur.ifc_op);
print_fld_size(FLD_IF_OERRS, ifs->ifs_cur.ifc_oe);
print_fld_size(FLD_IF_OERRS, if_err_view->ocount(&ifs->ifs_cur));
print_fld_size(FLD_IF_COLLS, ifs->ifs_cur.ifc_co);
@ -336,11 +381,11 @@ showtotal(void)
print_fld_sdiv(FLD_IF_IBYTES, sum.ifc_ib * conv, div);
print_fld_size(FLD_IF_IPKTS, sum.ifc_ip);
print_fld_size(FLD_IF_IERRS, sum.ifc_ie);
print_fld_size(FLD_IF_IERRS, if_err_view->icount(&sum));
print_fld_sdiv(FLD_IF_OBYTES, sum.ifc_ob * conv, div);
print_fld_size(FLD_IF_OPKTS, sum.ifc_op);
print_fld_size(FLD_IF_OERRS, sum.ifc_oe);
print_fld_size(FLD_IF_OERRS, if_err_view->ocount(&sum));
print_fld_size(FLD_IF_COLLS, sum.ifc_co);
@ -348,12 +393,67 @@ showtotal(void)
}
static uint64_t
if_err_ifails(const struct ifcount *ifc)
{
return (ifc->ifc_ie + ifc->ifc_iq);
}
static uint64_t
if_err_ofails(const struct ifcount *ifc)
{
return (ifc->ifc_oe + ifc->ifc_oq);
}
static uint64_t
if_err_ierrors(const struct ifcount *ifc)
{
return (ifc->ifc_ie);
}
static uint64_t
if_err_oerrors(const struct ifcount *ifc)
{
return (ifc->ifc_oe);
}
static uint64_t
if_err_iqdrops(const struct ifcount *ifc)
{
return (ifc->ifc_iq);
}
static uint64_t
if_err_oqdrops(const struct ifcount *ifc)
{
return (ifc->ifc_oq);
}
static void
if_set_errs(unsigned int v)
{
if_err_view = &if_err_views[v];
FLD_IF_IERRS->title = if_err_view->iname;
FLD_IF_IERRS->title = if_err_view->oname;
gotsig_alarm = 1;
}
int
if_keyboard_callback(int ch)
{
struct ifstat *ifs;
switch (ch) {
case 'd':
if_set_errs(IF_ERR_QDROPS);
break;
case 'e':
if_set_errs(IF_ERR_ERRORS);
break;
case 'f':
if_set_errs(IF_ERR_SUM);
break;
case 'r':
for (ifs = ifstats; ifs < ifstats + nifs; ifs++)
ifs->ifs_old = ifs->ifs_now;

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: systat.1,v 1.110 2018/07/25 17:24:14 bluhm Exp $
.\" $OpenBSD: systat.1,v 1.111 2019/03/04 21:27:35 dlg Exp $
.\" $NetBSD: systat.1,v 1.6 1996/05/10 23:16:39 thorpej Exp $
.\"
.\" Copyright (c) 1985, 1990, 1993
@ -30,7 +30,7 @@
.\"
.\" @(#)systat.1 8.2 (Berkeley) 12/30/93
.\"
.Dd $Mdocdate: July 25 2018 $
.Dd $Mdocdate: March 4 2019 $
.Dt SYSTAT 1
.Os
.Sh NAME
@ -290,6 +290,13 @@ between display refreshes.
changes the counters to show the average per second over
the display refresh interval;
this is the default.
.Ic d
displays input and output queue drops.
.Ic e
displays input and output errors.
.Ic f
displays input and output queue drops plus errors.
This is the default view.
.It Ic iostat
Display statistics about disk throughput.
Statistics

View File

@ -1,4 +1,4 @@
/* $OpenBSD: systat.h,v 1.22 2018/05/30 13:43:51 krw Exp $ */
/* $OpenBSD: systat.h,v 1.23 2019/03/04 21:27:35 dlg Exp $ */
/* $NetBSD: systat.h,v 1.2 1995/01/20 08:52:14 jtc Exp $ */
/*-
@ -104,9 +104,11 @@ struct ifcount {
u_int64_t ifc_ib; /* input bytes */
u_int64_t ifc_ip; /* input packets */
u_int64_t ifc_ie; /* input errors */
u_int64_t ifc_iq; /* input qdrops */
u_int64_t ifc_ob; /* output bytes */
u_int64_t ifc_op; /* output packets */
u_int64_t ifc_oe; /* output errors */
u_int64_t ifc_oq; /* output qdrops */
u_int64_t ifc_co; /* collisions */
int ifc_flags; /* up / down */
int ifc_state; /* link state */