Index: head/usr.bin/systat/fetch.c =================================================================== --- head/usr.bin/systat/fetch.c (revision 340360) +++ head/usr.bin/systat/fetch.c (revision 340361) @@ -1,140 +1,139 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1980, 1992, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #ifdef lint static const char sccsid[] = "@(#)fetch.c 8.1 (Berkeley) 6/6/93"; #endif #include #include #include #include #include #include #include "systat.h" #include "extern.h" int kvm_ckread(void *a, void *b, int l) { if (kvm_read(kd, (u_long)a, b, l) != l) { if (verbose) error("error reading kmem at %p", a); return (0); } else return (1); } void getsysctl(const char *name, void *ptr, size_t len) { size_t nlen = len; if (sysctlbyname(name, ptr, &nlen, NULL, 0) != 0) { error("sysctl(%s...) failed: %s", name, strerror(errno)); } if (nlen != len) { - error("sysctl(%s...) expected %lu, got %lu", name, - (unsigned long)len, (unsigned long)nlen); - } + error("sysctl(%s...) expected %zu, got %zu", name, len, nlen); + } } /* * Read sysctl data with variable size. Try some times (with increasing * buffers), fail if still too small. * This is needed sysctls with possibly raplidly increasing data sizes, * but imposes little overhead in the case of constant sizes. * Returns NULL on error, or a pointer to freshly malloc()'ed memory that holds * the requested data. * If szp is not NULL, the size of the returned data will be written into *szp. */ /* Some defines: Number of tries. */ #define SD_NTRIES 10 /* Percent of over-allocation (initial) */ #define SD_MARGIN 10 /* * Factor for over-allocation in percent (the margin is increased by this on * any failed try). */ #define SD_FACTOR 50 /* Maximum supported MIB depth */ #define SD_MAXMIB 16 char * sysctl_dynread(const char *n, size_t *szp) { char *rv = NULL; int mib[SD_MAXMIB]; size_t mibsz = SD_MAXMIB; size_t mrg = SD_MARGIN; size_t sz; int i; /* cache the MIB */ if (sysctlnametomib(n, mib, &mibsz) == -1) { if (errno == ENOMEM) { error("XXX: SD_MAXMIB too small, please bump!"); } return NULL; } for (i = 0; i < SD_NTRIES; i++) { /* get needed buffer size */ if (sysctl(mib, mibsz, NULL, &sz, NULL, 0) == -1) break; sz += sz * mrg / 100; if ((rv = (char *)malloc(sz)) == NULL) { error("Out of memory!"); return NULL; } if (sysctl(mib, mibsz, rv, &sz, NULL, 0) == -1) { free(rv); rv = NULL; if (errno == ENOMEM) { mrg += mrg * SD_FACTOR / 100; } else break; } else { /* success */ if (szp != NULL) *szp = sz; break; } } return rv; } Index: head/usr.bin/systat/icmp6.c =================================================================== --- head/usr.bin/systat/icmp6.c (revision 340360) +++ head/usr.bin/systat/icmp6.c (revision 340361) @@ -1,280 +1,281 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1980, 1992, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #ifdef lint static char sccsid[] = "@(#)mbufs.c 8.1 (Berkeley) 6/6/93"; #endif /* From: "Id: mbufs.c,v 1.5 1997/02/24 20:59:03 wollman Exp" */ #ifdef INET6 #include #include #include #include #include #include +#include #include #include #include #include "systat.h" #include "extern.h" #include "mode.h" static struct icmp6stat icmp6stat, initstat, oldstat; /*- --0 1 2 3 4 5 6 7 --0123456789012345678901234567890123456789012345678901234567890123456789012345 00 ICMPv6 Input ICMPv6 Output 01999999999 total messages 999999999 total messages 02999999999 with bad code 999999999 errors generated 03999999999 with bad length 999999999 suppressed - original too short 04999999999 with bad checksum 999999999 suppressed - original was ICMP 05999999999 with insufficient data 999999999 responses sent 06 07 Input Histogram Output Histogram 08999999999 echo response 999999999 echo response 09999999999 echo request 999999999 echo request 10999999999 destination unreachable 999999999 destination unreachable 11999999999 redirect 999999999 redirect 12999999999 time-to-live exceeded 999999999 time-to-line exceeded 13999999999 parameter problem 999999999 parameter problem 14999999999 neighbor solicitation 999999999 neighbor solicitation 15999999999 neighbor advertisement 999999999 neighbor advertisement 16999999999 router advertisement 999999999 router solicitation 17 18 --0123456789012345678901234567890123456789012345678901234567890123456789012345 --0 1 2 3 4 5 6 7 */ WINDOW * openicmp6(void) { return (subwin(stdscr, LINES-3-1, 0, MAINWIN_ROW, 0)); } void closeicmp6(WINDOW *w) { if (w == NULL) return; wclear(w); wrefresh(w); delwin(w); } void labelicmp6(void) { wmove(wnd, 0, 0); wclrtoeol(wnd); #define L(row, str) mvwprintw(wnd, row, 10, str) #define R(row, str) mvwprintw(wnd, row, 45, str); L(0, "ICMPv6 Input"); R(0, "ICMPv6 Output"); L(1, "total messages"); R(1, "total messages"); L(2, "with bad code"); R(2, "errors generated"); L(3, "with bad length"); R(3, "suppressed - original too short"); L(4, "with bad checksum"); R(4, "suppressed - original was ICMP"); L(5, "with insufficient data"); R(5, "responses sent"); L(7, "Input Histogram"); R(7, "Output Histogram"); #define B(row, str) L(row, str); R(row, str) B(8, "echo response"); B(9, "echo request"); B(10, "destination unreachable"); B(11, "redirect"); B(12, "time-to-live exceeded"); B(13, "parameter problem"); B(14, "neighbor solicitation"); B(15, "neighbor advertisement"); L(16, "router advertisement"); R(16, "router solicitation"); #undef L #undef R #undef B } static void domode(struct icmp6stat *ret) { const struct icmp6stat *sub; int i, divisor = 1; switch(currentmode) { case display_RATE: sub = &oldstat; divisor = (delay > 1000000) ? delay / 1000000 : 1; break; case display_DELTA: sub = &oldstat; break; case display_SINCE: sub = &initstat; break; default: *ret = icmp6stat; return; } #define DO(stat) ret->stat = (icmp6stat.stat - sub->stat) / divisor DO(icp6s_error); DO(icp6s_tooshort); DO(icp6s_canterror); for (i = 0; i <= ICMP6_MAXTYPE; i++) { DO(icp6s_outhist[i]); } DO(icp6s_badcode); DO(icp6s_tooshort); DO(icp6s_checksum); DO(icp6s_badlen); DO(icp6s_reflect); for (i = 0; i <= ICMP6_MAXTYPE; i++) { DO(icp6s_inhist[i]); } #undef DO } void showicmp6(void) { struct icmp6stat stats; - u_long totalin, totalout; + uint64_t totalin, totalout; int i; memset(&stats, 0, sizeof stats); domode(&stats); for (i = totalin = totalout = 0; i <= ICMP6_MAXTYPE; i++) { totalin += stats.icp6s_inhist[i]; totalout += stats.icp6s_outhist[i]; } totalin += stats.icp6s_badcode + stats.icp6s_badlen + stats.icp6s_checksum + stats.icp6s_tooshort; - mvwprintw(wnd, 1, 0, "%9lu", totalin); - mvwprintw(wnd, 1, 35, "%9lu", totalout); + mvwprintw(wnd, 1, 0, "%9"PRIu64, totalin); + mvwprintw(wnd, 1, 35, "%9"PRIu64, totalout); #define DO(stat, row, col) \ - mvwprintw(wnd, row, col, "%9lu", stats.stat) + mvwprintw(wnd, row, col, "%9"PRIu64, stats.stat) DO(icp6s_badcode, 2, 0); DO(icp6s_badlen, 3, 0); DO(icp6s_checksum, 4, 0); DO(icp6s_tooshort, 5, 0); DO(icp6s_error, 2, 35); DO(icp6s_tooshort, 3, 35); DO(icp6s_canterror, 4, 35); DO(icp6s_reflect, 5, 35); #define DO2(type, row) DO(icp6s_inhist[type], row, 0); DO(icp6s_outhist[type], \ row, 35) DO2(ICMP6_ECHO_REPLY, 8); DO2(ICMP6_ECHO_REQUEST, 9); DO2(ICMP6_DST_UNREACH, 10); DO2(ND_REDIRECT, 11); DO2(ICMP6_TIME_EXCEEDED, 12); DO2(ICMP6_PARAM_PROB, 13); DO2(ND_NEIGHBOR_SOLICIT, 14); DO2(ND_NEIGHBOR_ADVERT, 15); DO(icp6s_inhist[ND_ROUTER_SOLICIT], 16, 0); DO(icp6s_outhist[ND_ROUTER_ADVERT], 16, 35); #undef DO #undef DO2 } int initicmp6(void) { size_t len; int name[4]; name[0] = CTL_NET; name[1] = PF_INET6; name[2] = IPPROTO_ICMPV6; name[3] = ICMPV6CTL_STATS; len = 0; if (sysctl(name, 4, 0, &len, 0, 0) < 0) { error("sysctl getting icmp6stat size failed"); return 0; } if (len > sizeof icmp6stat) { error("icmp6stat structure has grown--recompile systat!"); return 0; } if (sysctl(name, 4, &initstat, &len, 0, 0) < 0) { error("sysctl getting icmp6stat size failed"); return 0; } oldstat = initstat; return 1; } void reseticmp6(void) { size_t len; int name[4]; name[0] = CTL_NET; name[1] = PF_INET6; name[2] = IPPROTO_ICMPV6; name[3] = ICMPV6CTL_STATS; len = sizeof initstat; if (sysctl(name, 4, &initstat, &len, 0, 0) < 0) { error("sysctl getting icmp6stat size failed"); } oldstat = initstat; } void fetchicmp6(void) { int name[4]; size_t len; oldstat = icmp6stat; name[0] = CTL_NET; name[1] = PF_INET6; name[2] = IPPROTO_ICMPV6; name[3] = ICMPV6CTL_STATS; len = sizeof icmp6stat; if (sysctl(name, 4, &icmp6stat, &len, 0, 0) < 0) return; } #endif Index: head/usr.bin/systat/ip.c =================================================================== --- head/usr.bin/systat/ip.c (revision 340360) +++ head/usr.bin/systat/ip.c (revision 340361) @@ -1,341 +1,342 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1980, 1992, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #ifdef lint static const char sccsid[] = "@(#)mbufs.c 8.1 (Berkeley) 6/6/93"; #endif /* From: "Id: mbufs.c,v 1.5 1997/02/24 20:59:03 wollman Exp" */ #include #include #include #include #include #include #include #include #include #include +#include #include #include #include #include "systat.h" #include "extern.h" #include "mode.h" struct stat { struct ipstat i; struct udpstat u; }; static struct stat curstat, initstat, oldstat; /*- --0 1 2 3 4 5 6 7 --0123456789012345678901234567890123456789012345678901234567890123456789012345 00 IP Input IP Output 01999999999 total packets received 999999999 total packets sent 02999999999 - with bad checksums 999999999 - generated locally 03999999999 - too short for header 999999999 - output drops 04999999999 - too short for data 999999999 output fragments generated 05999999999 - with invalid hlen 999999999 - fragmentation failed 06999999999 - with invalid length 999999999 destinations unreachable 07999999999 - with invalid version 999999999 packets output via raw IP 08999999999 - jumbograms 09999999999 total fragments received UDP Statistics 10999999999 - fragments dropped 999999999 total input packets 11999999999 - fragments timed out 999999999 - too short for header 12999999999 - packets reassembled ok 999999999 - invalid checksum 13999999999 packets forwarded 999999999 - no checksum 14999999999 - unreachable dests 999999999 - invalid length 15999999999 - redirects generated 999999999 - no socket for dest port 16999999999 option errors 999999999 - no socket for broadcast 17999999999 unwanted multicasts 999999999 - socket buffer full 18999999999 delivered to upper layer 999999999 total output packets --0123456789012345678901234567890123456789012345678901234567890123456789012345 --0 1 2 3 4 5 6 7 */ WINDOW * openip(void) { return (subwin(stdscr, LINES-3-1, 0, MAINWIN_ROW, 0)); } void closeip(WINDOW *w) { if (w == NULL) return; wclear(w); wrefresh(w); delwin(w); } void labelip(void) { wmove(wnd, 0, 0); wclrtoeol(wnd); #define L(row, str) mvwprintw(wnd, row, 10, str) #define R(row, str) mvwprintw(wnd, row, 45, str); L(0, "IP Input"); R(0, "IP Output"); L(1, "total packets received"); R(1, "total packets sent"); L(2, "- with bad checksums"); R(2, "- generated locally"); L(3, "- too short for header"); R(3, "- output drops"); L(4, "- too short for data"); R(4, "output fragments generated"); L(5, "- with invalid hlen"); R(5, "- fragmentation failed"); L(6, "- with invalid length"); R(6, "destinations unreachable"); L(7, "- with invalid version"); R(7, "packets output via raw IP"); L(8, "- jumbograms"); L(9, "total fragments received"); R(9, "UDP Statistics"); L(10, "- fragments dropped"); R(10, "total input packets"); L(11, "- fragments timed out"); R(11, "- too short for header"); L(12, "- packets reassembled ok"); R(12, "- invalid checksum"); L(13, "packets forwarded"); R(13, "- no checksum"); L(14, "- unreachable dests"); R(14, "- invalid length"); L(15, "- redirects generated"); R(15, "- no socket for dest port"); L(16, "option errors"); R(16, "- no socket for broadcast"); L(17, "unwanted multicasts"); R(17, "- socket buffer full"); L(18, "delivered to upper layer"); R(18, "total output packets"); #undef L #undef R } static void domode(struct stat *ret) { const struct stat *sub; int divisor = 1; switch(currentmode) { case display_RATE: sub = &oldstat; divisor = (delay > 1000000) ? delay / 1000000 : 1; break; case display_DELTA: sub = &oldstat; break; case display_SINCE: sub = &initstat; break; default: *ret = curstat; return; } #define DO(stat) ret->stat = (curstat.stat - sub->stat) / divisor DO(i.ips_total); DO(i.ips_badsum); DO(i.ips_tooshort); DO(i.ips_toosmall); DO(i.ips_badhlen); DO(i.ips_badlen); DO(i.ips_fragments); DO(i.ips_fragdropped); DO(i.ips_fragtimeout); DO(i.ips_forward); DO(i.ips_cantforward); DO(i.ips_redirectsent); DO(i.ips_noproto); DO(i.ips_delivered); DO(i.ips_localout); DO(i.ips_odropped); DO(i.ips_reassembled); DO(i.ips_fragmented); DO(i.ips_ofragments); DO(i.ips_cantfrag); DO(i.ips_badoptions); DO(i.ips_noroute); DO(i.ips_badvers); DO(i.ips_rawout); DO(i.ips_toolong); DO(i.ips_notmember); DO(u.udps_ipackets); DO(u.udps_hdrops); DO(u.udps_badsum); DO(u.udps_nosum); DO(u.udps_badlen); DO(u.udps_noport); DO(u.udps_noportbcast); DO(u.udps_fullsock); DO(u.udps_opackets); #undef DO } void showip(void) { struct stat stats; - u_long totalout; + uint64_t totalout; domode(&stats); totalout = stats.i.ips_forward + stats.i.ips_localout; #define DO(stat, row, col) \ - mvwprintw(wnd, row, col, "%9lu", stats.stat) + mvwprintw(wnd, row, col, "%9"PRIu64, stats.stat) DO(i.ips_total, 1, 0); - mvwprintw(wnd, 1, 35, "%9lu", totalout); + mvwprintw(wnd, 1, 35, "%9"PRIu64, totalout); DO(i.ips_badsum, 2, 0); DO(i.ips_localout, 2, 35); DO(i.ips_tooshort, 3, 0); DO(i.ips_odropped, 3, 35); DO(i.ips_toosmall, 4, 0); DO(i.ips_ofragments, 4, 35); DO(i.ips_badhlen, 5, 0); DO(i.ips_cantfrag, 5, 35); DO(i.ips_badlen, 6, 0); DO(i.ips_noroute, 6, 35); DO(i.ips_badvers, 7, 0); DO(i.ips_rawout, 7, 35); DO(i.ips_toolong, 8, 0); DO(i.ips_fragments, 9, 0); DO(i.ips_fragdropped, 10, 0); DO(u.udps_ipackets, 10, 35); DO(i.ips_fragtimeout, 11, 0); DO(u.udps_hdrops, 11, 35); DO(i.ips_reassembled, 12, 0); DO(u.udps_badsum, 12, 35); DO(i.ips_forward, 13, 0); DO(u.udps_nosum, 13, 35); DO(i.ips_cantforward, 14, 0); DO(u.udps_badlen, 14, 35); DO(i.ips_redirectsent, 15, 0); DO(u.udps_noport, 15, 35); DO(i.ips_badoptions, 16, 0); DO(u.udps_noportbcast, 16, 35); DO(i.ips_notmember, 17, 0); DO(u.udps_fullsock, 17, 35); DO(i.ips_delivered, 18, 0); DO(u.udps_opackets, 18, 35); #undef DO } int initip(void) { size_t len; int name[4]; name[0] = CTL_NET; name[1] = PF_INET; name[2] = IPPROTO_IP; name[3] = IPCTL_STATS; len = 0; if (sysctl(name, 4, 0, &len, 0, 0) < 0) { error("sysctl getting ipstat size failed"); return 0; } if (len > sizeof curstat.i) { error("ipstat structure has grown--recompile systat!"); return 0; } if (sysctl(name, 4, &initstat.i, &len, 0, 0) < 0) { error("sysctl getting ipstat failed"); return 0; } name[2] = IPPROTO_UDP; name[3] = UDPCTL_STATS; len = 0; if (sysctl(name, 4, 0, &len, 0, 0) < 0) { error("sysctl getting udpstat size failed"); return 0; } if (len > sizeof curstat.u) { error("ipstat structure has grown--recompile systat!"); return 0; } if (sysctl(name, 4, &initstat.u, &len, 0, 0) < 0) { error("sysctl getting udpstat failed"); return 0; } oldstat = initstat; return 1; } void resetip(void) { size_t len; int name[4]; name[0] = CTL_NET; name[1] = PF_INET; name[2] = IPPROTO_IP; name[3] = IPCTL_STATS; len = sizeof initstat.i; if (sysctl(name, 4, &initstat.i, &len, 0, 0) < 0) { error("sysctl getting ipstat failed"); } name[2] = IPPROTO_UDP; name[3] = UDPCTL_STATS; len = sizeof initstat.u; if (sysctl(name, 4, &initstat.u, &len, 0, 0) < 0) { error("sysctl getting udpstat failed"); } oldstat = initstat; } void fetchip(void) { int name[4]; size_t len; oldstat = curstat; name[0] = CTL_NET; name[1] = PF_INET; name[2] = IPPROTO_IP; name[3] = IPCTL_STATS; len = sizeof curstat.i; if (sysctl(name, 4, &curstat.i, &len, 0, 0) < 0) return; name[2] = IPPROTO_UDP; name[3] = UDPCTL_STATS; len = sizeof curstat.u; if (sysctl(name, 4, &curstat.u, &len, 0, 0) < 0) return; } Index: head/usr.bin/systat/ip6.c =================================================================== --- head/usr.bin/systat/ip6.c (revision 340360) +++ head/usr.bin/systat/ip6.c (revision 340361) @@ -1,302 +1,303 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1980, 1992, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #ifdef lint static const char sccsid[] = "@(#)mbufs.c 8.1 (Berkeley) 6/6/93"; #endif /* From: "Id: mbufs.c,v 1.5 1997/02/24 20:59:03 wollman Exp" */ #ifdef INET6 #include #include #include #include #include #include #include #include +#include #include #include #include #include "systat.h" #include "extern.h" #include "mode.h" static struct ip6stat curstat, initstat, oldstat; /*- --0 1 2 3 4 5 6 7 --0123456789012345678901234567890123456789012345678901234567890123456789012345 00 IPv6 Input IPv6 Output 019999999 total packets received 999999999 total packets sent 029999999 - too short for header 999999999 - generated locally 039999999 - too short for data 999999999 - output drops 049999999 - with invalid version 999999999 output fragments generated 059999999 total fragments received 999999999 - fragmentation failed 069999999 - fragments dropped 999999999 destinations unreachable 079999999 - fragments timed out 999999999 packets output via raw IP 089999999 - fragments overflown 099999999 - packets reassembled ok Input next-header histogram 109999999 packets forwarded 999999999 - destination options 119999999 - unreachable dests 999999999 - hop-by-hop options 129999999 - redirects generated 999999999 - IPv4 139999999 option errors 999999999 - TCP 149999999 unwanted multicasts 999999999 - UDP 159999999 delivered to upper layer 999999999 - IPv6 169999999 bad scope packets 999999999 - routing header 179999999 address selection failed 999999999 - fragmentation header 18 999999999 - ICMP6 19 999999999 - none --0123456789012345678901234567890123456789012345678901234567890123456789012345 --0 1 2 3 4 5 6 7 */ WINDOW * openip6(void) { return (subwin(stdscr, LINES-3-1, 0, MAINWIN_ROW, 0)); } void closeip6(WINDOW *w) { if (w == NULL) return; wclear(w); wrefresh(w); delwin(w); } void labelip6(void) { wmove(wnd, 0, 0); wclrtoeol(wnd); #define L(row, str) mvwprintw(wnd, row, 10, str) #define R(row, str) mvwprintw(wnd, row, 45, str); L(0, "IPv6 Input"); R(0, "IPv6 Output"); L(1, "total packets received"); R(1, "total packets sent"); L(2, "- too short for header"); R(2, "- generated locally"); L(3, "- too short for data"); R(3, "- output drops"); L(4, "- with invalid version"); R(4, "output fragments generated"); L(5, "total fragments received"); R(5, "- fragmentation failed"); L(6, "- fragments dropped"); R(6, "destinations unreachable"); L(7, "- fragments timed out"); R(7, "packets output via raw IP"); L(8, "- fragments overflown"); L(9, "- packets reassembled ok"); R(9, "Input next-header histogram"); L(10, "packets forwarded"); R(10, " - destination options"); L(11, "- unreachable dests"); R(11, " - hop-by-hop options"); L(12, "- redirects generated"); R(12, " - IPv4"); L(13, "option errors"); R(13, " - TCP"); L(14, "unwanted multicasts"); R(14, " - UDP"); L(15, "delivered to upper layer"); R(15, " - IPv6"); L(16, "bad scope packets"); R(16, " - routing header"); L(17, "address selection failed"); R(17, " - fragmentation header"); R(18, " - ICMP6"); R(19, " - none"); #undef L #undef R } static void domode(struct ip6stat *ret) { const struct ip6stat *sub; int divisor = 1, i; switch(currentmode) { case display_RATE: sub = &oldstat; divisor = (delay > 1000000) ? delay / 1000000 : 1; break; case display_DELTA: sub = &oldstat; break; case display_SINCE: sub = &initstat; break; default: *ret = curstat; return; } #define DO(stat) ret->stat = (curstat.stat - sub->stat) / divisor DO(ip6s_total); DO(ip6s_tooshort); DO(ip6s_toosmall); DO(ip6s_fragments); DO(ip6s_fragdropped); DO(ip6s_fragtimeout); DO(ip6s_fragoverflow); DO(ip6s_forward); DO(ip6s_cantforward); DO(ip6s_redirectsent); DO(ip6s_delivered); DO(ip6s_localout); DO(ip6s_odropped); DO(ip6s_reassembled); DO(ip6s_fragmented); DO(ip6s_ofragments); DO(ip6s_cantfrag); DO(ip6s_badoptions); DO(ip6s_noroute); DO(ip6s_badvers); DO(ip6s_rawout); DO(ip6s_notmember); for (i = 0; i < 256; i++) DO(ip6s_nxthist[i]); DO(ip6s_badscope); DO(ip6s_sources_none); #undef DO } void showip6(void) { struct ip6stat stats; - u_long totalout; + uint64_t totalout; domode(&stats); totalout = stats.ip6s_forward + stats.ip6s_localout; #define DO(stat, row, col) \ - mvwprintw(wnd, row, col, "%9lu", stats.stat) + mvwprintw(wnd, row, col, "%9"PRIu64, stats.stat) DO(ip6s_total, 1, 0); - mvwprintw(wnd, 1, 35, "%9lu", totalout); + mvwprintw(wnd, 1, 35, "%9"PRIu64, totalout); DO(ip6s_tooshort, 2, 0); DO(ip6s_localout, 2, 35); DO(ip6s_toosmall, 3, 0); DO(ip6s_odropped, 3, 35); DO(ip6s_badvers, 4, 0); DO(ip6s_ofragments, 4, 35); DO(ip6s_fragments, 5, 0); DO(ip6s_cantfrag, 5, 35); DO(ip6s_fragdropped, 6, 0); DO(ip6s_noroute, 6, 35); DO(ip6s_fragtimeout, 7, 0); DO(ip6s_rawout, 7, 35); DO(ip6s_fragoverflow, 8, 0); DO(ip6s_reassembled, 9, 0); DO(ip6s_forward, 10, 0); DO(ip6s_nxthist[IPPROTO_DSTOPTS], 10, 35); DO(ip6s_cantforward, 11, 0); DO(ip6s_nxthist[IPPROTO_HOPOPTS], 11, 35); DO(ip6s_redirectsent, 12, 0); DO(ip6s_nxthist[IPPROTO_IPV4], 12, 35); DO(ip6s_badoptions, 13, 0); DO(ip6s_nxthist[IPPROTO_TCP], 13, 35); DO(ip6s_notmember, 14, 0); DO(ip6s_nxthist[IPPROTO_UDP], 14, 35); DO(ip6s_delivered, 15, 0); DO(ip6s_nxthist[IPPROTO_IPV6], 15, 35); DO(ip6s_badscope, 16, 0); DO(ip6s_nxthist[IPPROTO_ROUTING], 16, 35); DO(ip6s_sources_none, 17, 0); DO(ip6s_nxthist[IPPROTO_FRAGMENT], 17, 35); DO(ip6s_nxthist[IPPROTO_ICMPV6], 18, 35); DO(ip6s_nxthist[IPPROTO_NONE], 19, 35); #undef DO } int initip6(void) { size_t len; int name[4]; name[0] = CTL_NET; name[1] = PF_INET6; name[2] = IPPROTO_IPV6; name[3] = IPV6CTL_STATS; len = 0; if (sysctl(name, 4, 0, &len, 0, 0) < 0) { error("sysctl getting ip6stat size failed"); return 0; } if (len > sizeof curstat) { error("ip6stat structure has grown--recompile systat!"); return 0; } if (sysctl(name, 4, &initstat, &len, 0, 0) < 0) { error("sysctl getting ip6stat failed"); return 0; } oldstat = initstat; return 1; } void resetip6(void) { size_t len; int name[4]; name[0] = CTL_NET; name[1] = PF_INET6; name[2] = IPPROTO_IPV6; name[3] = IPV6CTL_STATS; len = sizeof initstat; if (sysctl(name, 4, &initstat, &len, 0, 0) < 0) { error("sysctl getting ipstat failed"); } oldstat = initstat; } void fetchip6(void) { int name[4]; size_t len; oldstat = curstat; name[0] = CTL_NET; name[1] = PF_INET6; name[2] = IPPROTO_IPV6; name[3] = IPV6CTL_STATS; len = sizeof curstat; if (sysctl(name, 4, &curstat, &len, 0, 0) < 0) return; } #endif Index: head/usr.bin/systat/tcp.c =================================================================== --- head/usr.bin/systat/tcp.c (revision 340360) +++ head/usr.bin/systat/tcp.c (revision 340361) @@ -1,329 +1,330 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1980, 1992, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #if 0 #ifndef lint /* From: */ static char sccsid[] = "@(#)mbufs.c 8.1 (Berkeley) 6/6/93"; static const char rcsid[] = "Id: mbufs.c,v 1.5 1997/02/24 20:59:03 wollman Exp"; #endif /* not lint */ #endif #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include #include #include #include #include +#include #include #include #include #include "systat.h" #include "extern.h" #include "mode.h" static struct tcpstat curstat, initstat, oldstat; /*- --0 1 2 3 4 5 6 7 --0123456789012345678901234567890123456789012345678901234567890123456789012345 00 TCP Connections TCP Packets 01999999999999 connections initiated 999999999999 total packets sent 02999999999999 connections accepted 999999999999 - data 03999999999999 connections established 999999999999 - data (retransmit by dupack) 04999999999999 connections dropped 999999999999 - data (retransmit by sack) 05999999999999 - in embryonic state 999999999999 - ack-only 06999999999999 - on retransmit timeout 999999999999 - window probes 07999999999999 - by keepalive 999999999999 - window updates 08999999999999 - from listen queue 999999999999 - urgent data only 09 999999999999 - control 10 999999999999 - resends by PMTU discovery 11 TCP Timers 999999999999 total packets received 12999999999999 potential rtt updates 999999999999 - in sequence 13999999999999 - successful 999999999999 - completely duplicate 14999999999999 delayed acks sent 999999999999 - with some duplicate data 15999999999999 retransmit timeouts 999999999999 - out-of-order 16999999999999 persist timeouts 999999999999 - duplicate acks 17999999999999 keepalive probes 999999999999 - acks 18999999999999 - timeouts 999999999999 - window probes 19 999999999999 - window updates 20 999999999999 - bad checksum --0123456789012345678901234567890123456789012345678901234567890123456789012345 --0 1 2 3 4 5 6 7 */ WINDOW * opentcp(void) { return (subwin(stdscr, LINES-3-1, 0, MAINWIN_ROW, 0)); } void closetcp(WINDOW *w) { if (w == NULL) return; wclear(w); wrefresh(w); delwin(w); } void labeltcp(void) { wmove(wnd, 0, 0); wclrtoeol(wnd); #define L(row, str) mvwprintw(wnd, row, 13, str) #define R(row, str) mvwprintw(wnd, row, 51, str); L(0, "TCP Connections"); R(0, "TCP Packets"); L(1, "connections initiated"); R(1, "total packets sent"); L(2, "connections accepted"); R(2, "- data"); L(3, "connections established"); R(3, "- data (retransmit by dupack)"); L(4, "connections dropped"); R(4, "- data (retransmit by sack)"); L(5, "- in embryonic state"); R(5, "- ack-only"); L(6, "- on retransmit timeout"); R(6, "- window probes"); L(7, "- by keepalive"); R(7, "- window updates"); L(8, "- from listen queue"); R(8, "- urgent data only"); R(9, "- control"); R(10, "- resends by PMTU discovery"); L(11, "TCP Timers"); R(11, "total packets received"); L(12, "potential rtt updates"); R(12, "- in sequence"); L(13, "- successful"); R(13, "- completely duplicate"); L(14, "delayed acks sent"); R(14, "- with some duplicate data"); L(15, "retransmit timeouts"); R(15, "- out-of-order"); L(16, "persist timeouts"); R(16, "- duplicate acks"); L(17, "keepalive probes"); R(17, "- acks"); L(18, "- timeouts"); R(18, "- window probes"); R(19, "- window updates"); R(20, "- bad checksum"); #undef L #undef R } static void domode(struct tcpstat *ret) { const struct tcpstat *sub; int divisor = 1; switch(currentmode) { case display_RATE: sub = &oldstat; divisor = (delay > 1000000) ? delay / 1000000 : 1; break; case display_DELTA: sub = &oldstat; break; case display_SINCE: sub = &initstat; break; default: *ret = curstat; return; } #define DO(stat) ret->stat = (curstat.stat - sub->stat) / divisor DO(tcps_connattempt); DO(tcps_accepts); DO(tcps_connects); DO(tcps_drops); DO(tcps_conndrops); DO(tcps_closed); DO(tcps_segstimed); DO(tcps_rttupdated); DO(tcps_delack); DO(tcps_timeoutdrop); DO(tcps_rexmttimeo); DO(tcps_persisttimeo); DO(tcps_keeptimeo); DO(tcps_keepprobe); DO(tcps_keepdrops); DO(tcps_sndtotal); DO(tcps_sndpack); DO(tcps_sndbyte); DO(tcps_sndrexmitpack); DO(tcps_sack_rexmits); DO(tcps_sndacks); DO(tcps_sndprobe); DO(tcps_sndurg); DO(tcps_sndwinup); DO(tcps_sndctrl); DO(tcps_rcvtotal); DO(tcps_rcvpack); DO(tcps_rcvbyte); DO(tcps_rcvbadsum); DO(tcps_rcvbadoff); DO(tcps_rcvshort); DO(tcps_rcvduppack); DO(tcps_rcvdupbyte); DO(tcps_rcvpartduppack); DO(tcps_rcvpartdupbyte); DO(tcps_rcvoopack); DO(tcps_rcvoobyte); DO(tcps_rcvpackafterwin); DO(tcps_rcvbyteafterwin); DO(tcps_rcvafterclose); DO(tcps_rcvwinprobe); DO(tcps_rcvdupack); DO(tcps_rcvacktoomuch); DO(tcps_rcvackpack); DO(tcps_rcvackbyte); DO(tcps_rcvwinupd); DO(tcps_pawsdrop); DO(tcps_predack); DO(tcps_preddat); DO(tcps_pcbcachemiss); DO(tcps_cachedrtt); DO(tcps_cachedrttvar); DO(tcps_cachedssthresh); DO(tcps_usedrtt); DO(tcps_usedrttvar); DO(tcps_usedssthresh); DO(tcps_persistdrop); DO(tcps_badsyn); DO(tcps_mturesent); DO(tcps_listendrop); #undef DO } void showtcp(void) { struct tcpstat stats; memset(&stats, 0, sizeof stats); domode(&stats); #define DO(stat, row, col) \ - mvwprintw(wnd, row, col, "%12lu", stats.stat) + mvwprintw(wnd, row, col, "%12"PRIu64, stats.stat) #define L(row, stat) DO(stat, row, 0) #define R(row, stat) DO(stat, row, 38) L(1, tcps_connattempt); R(1, tcps_sndtotal); L(2, tcps_accepts); R(2, tcps_sndpack); L(3, tcps_connects); R(3, tcps_sndrexmitpack); L(4, tcps_drops); R(4, tcps_sack_rexmits); L(5, tcps_conndrops); R(5, tcps_sndacks); L(6, tcps_timeoutdrop); R(6, tcps_sndprobe); L(7, tcps_keepdrops); R(7, tcps_sndwinup); L(8, tcps_listendrop); R(8, tcps_sndurg); R(9, tcps_sndctrl); R(10, tcps_mturesent); R(11, tcps_rcvtotal); L(12, tcps_segstimed); R(12, tcps_rcvpack); L(13, tcps_rttupdated); R(13, tcps_rcvduppack); L(14, tcps_delack); R(14, tcps_rcvpartduppack); L(15, tcps_rexmttimeo); R(15, tcps_rcvoopack); L(16, tcps_persisttimeo); R(16, tcps_rcvdupack); L(17, tcps_keepprobe); R(17, tcps_rcvackpack); L(18, tcps_keeptimeo); R(18, tcps_rcvwinprobe); R(19, tcps_rcvwinupd); R(20, tcps_rcvbadsum); #undef DO #undef L #undef R } int inittcp(void) { size_t len; int name[4]; name[0] = CTL_NET; name[1] = PF_INET; name[2] = IPPROTO_TCP; name[3] = TCPCTL_STATS; len = 0; if (sysctl(name, 4, 0, &len, 0, 0) < 0) { error("sysctl getting tcpstat size failed"); return 0; } if (len > sizeof curstat) { error("tcpstat structure has grown--recompile systat!"); return 0; } if (sysctl(name, 4, &initstat, &len, 0, 0) < 0) { error("sysctl getting tcpstat failed"); return 0; } oldstat = initstat; return 1; } void resettcp(void) { size_t len; int name[4]; name[0] = CTL_NET; name[1] = PF_INET; name[2] = IPPROTO_TCP; name[3] = TCPCTL_STATS; len = sizeof initstat; if (sysctl(name, 4, &initstat, &len, 0, 0) < 0) { error("sysctl getting tcpstat failed"); } oldstat = initstat; } void fetchtcp(void) { int name[4]; size_t len; oldstat = curstat; name[0] = CTL_NET; name[1] = PF_INET; name[2] = IPPROTO_TCP; name[3] = TCPCTL_STATS; len = sizeof curstat; if (sysctl(name, 4, &curstat, &len, 0, 0) < 0) return; } Index: head/usr.bin/systat/zarc.c =================================================================== --- head/usr.bin/systat/zarc.c (revision 340360) +++ head/usr.bin/systat/zarc.c (revision 340361) @@ -1,221 +1,222 @@ /*- * Copyright (c) 2014 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include #include +#include #include #include "systat.h" #include "extern.h" struct zfield{ uint64_t arcstats; uint64_t arcstats_demand_data; uint64_t arcstats_demand_metadata; uint64_t arcstats_prefetch_data; uint64_t arcstats_prefetch_metadata; uint64_t zfetchstats; uint64_t arcstats_l2; uint64_t vdev_cache_stats; }; static struct zarcstats { struct zfield hits; struct zfield misses; } curstat, initstat, oldstat; static void getinfo(struct zarcstats *ls); WINDOW * openzarc(void) { return (subwin(stdscr, LINES-3-1, 0, MAINWIN_ROW, 0)); } void closezarc(WINDOW *w) { if (w == NULL) return; wclear(w); wrefresh(w); delwin(w); } void labelzarc(void) { wmove(wnd, 0, 0); wclrtoeol(wnd); mvwprintw(wnd, 0, 31+1, "%4.4s %7.7s %7.7s %12.12s %12.12s", "rate", "hits", "misses", "total hits", "total misses"); #define L(row, str) mvwprintw(wnd, row, 5, str); \ mvwprintw(wnd, row, 31, ":"); \ mvwprintw(wnd, row, 31+4, "%%") L(1, "arcstats"); L(2, "arcstats.demand_data"); L(3, "arcstats.demand_metadata"); L(4, "arcstats.prefetch_data"); L(5, "arcstats.prefetch_metadata"); L(6, "zfetchstats"); L(7, "arcstats.l2"); L(8, "vdev_cache_stats"); #undef L } static int calc(uint64_t hits, uint64_t misses) { if( hits ) return 100 * hits / ( hits + misses ); else return 0; } static void domode(struct zarcstats *delta, struct zarcstats *rate) { #define DO(stat) \ delta->hits.stat = (curstat.hits.stat - oldstat.hits.stat); \ delta->misses.stat = (curstat.misses.stat - oldstat.misses.stat); \ rate->hits.stat = calc(delta->hits.stat, delta->misses.stat) DO(arcstats); DO(arcstats_demand_data); DO(arcstats_demand_metadata); DO(arcstats_prefetch_data); DO(arcstats_prefetch_metadata); DO(zfetchstats); DO(arcstats_l2); DO(vdev_cache_stats); DO(arcstats); DO(arcstats_demand_data); DO(arcstats_demand_metadata); DO(arcstats_prefetch_data); DO(arcstats_prefetch_metadata); DO(zfetchstats); DO(arcstats_l2); DO(vdev_cache_stats); #undef DO } void showzarc(void) { struct zarcstats delta, rate; memset(&delta, 0, sizeof delta); memset(&rate, 0, sizeof rate); domode(&delta, &rate); #define DO(stat, row, col, fmt) \ mvwprintw(wnd, row, col, fmt, stat) -#define R(row, stat) DO(rate.hits.stat, row, 31+1, "%3lu") -#define H(row, stat) DO(delta.hits.stat, row, 31+1+5, "%7lu"); \ - DO(curstat.hits.stat, row, 31+1+5+8+8, "%12lu") -#define M(row, stat) DO(delta.misses.stat, row, 31+1+5+8, "%7lu"); \ - DO(curstat.misses.stat, row, 31+1+5+8+8+13, "%12lu") +#define R(row, stat) DO(rate.hits.stat, row, 31+1, "%3"PRIu64) +#define H(row, stat) DO(delta.hits.stat, row, 31+1+5, "%7"PRIu64); \ + DO(curstat.hits.stat, row, 31+1+5+8+8, "%12"PRIu64) +#define M(row, stat) DO(delta.misses.stat, row, 31+1+5+8, "%7"PRIu64); \ + DO(curstat.misses.stat, row, 31+1+5+8+8+13, "%12"PRIu64) #define E(row, stat) R(row, stat); H(row, stat); M(row, stat); E(1, arcstats); E(2, arcstats_demand_data); E(3, arcstats_demand_metadata); E(4, arcstats_prefetch_data); E(5, arcstats_prefetch_metadata); E(6, zfetchstats); E(7, arcstats_l2); E(8, vdev_cache_stats); #undef DO #undef E #undef M #undef H #undef R } int initzarc(void) { getinfo(&initstat); curstat = oldstat = initstat; return 1; } void resetzarc(void) { initzarc(); } static void getinfo(struct zarcstats *ls) { size_t size = sizeof( ls->hits.arcstats ); if ( sysctlbyname("kstat.zfs.misc.arcstats.hits", &ls->hits.arcstats, &size, NULL, 0 ) != 0 ) return; GETSYSCTL("kstat.zfs.misc.arcstats.misses", ls->misses.arcstats); GETSYSCTL("kstat.zfs.misc.arcstats.demand_data_hits", ls->hits.arcstats_demand_data); GETSYSCTL("kstat.zfs.misc.arcstats.demand_data_misses", ls->misses.arcstats_demand_data); GETSYSCTL("kstat.zfs.misc.arcstats.demand_metadata_hits", ls->hits.arcstats_demand_metadata); GETSYSCTL("kstat.zfs.misc.arcstats.demand_metadata_misses", ls->misses.arcstats_demand_metadata); GETSYSCTL("kstat.zfs.misc.arcstats.prefetch_data_hits", ls->hits.arcstats_prefetch_data); GETSYSCTL("kstat.zfs.misc.arcstats.prefetch_data_misses", ls->misses.arcstats_prefetch_data); GETSYSCTL("kstat.zfs.misc.arcstats.prefetch_metadata_hits", ls->hits.arcstats_prefetch_metadata); GETSYSCTL("kstat.zfs.misc.arcstats.prefetch_metadata_misses", ls->misses.arcstats_prefetch_metadata); GETSYSCTL("kstat.zfs.misc.zfetchstats.hits", ls->hits.zfetchstats); GETSYSCTL("kstat.zfs.misc.zfetchstats.misses", ls->misses.zfetchstats); GETSYSCTL("kstat.zfs.misc.arcstats.l2_hits", ls->hits.arcstats_l2); GETSYSCTL("kstat.zfs.misc.arcstats.l2_misses", ls->misses.arcstats_l2); GETSYSCTL("kstat.zfs.misc.vdev_cache_stats.hits", ls->hits.vdev_cache_stats); GETSYSCTL("kstat.zfs.misc.vdev_cache_stats.misses", ls->misses.vdev_cache_stats); } void fetchzarc(void) { oldstat = curstat; getinfo(&curstat); }