Output statistics as unsigned in the -w section.

Look at error return of kread() and stop on error.
Fix warning in kread() to not output "kvm_read:" twice.
Killed PCB cache misses stat as we no longer have it.
This commit is contained in:
David Greenman 1995-07-29 22:34:15 +00:00
parent 61a65662e5
commit 3aa80b1d81
3 changed files with 26 additions and 18 deletions

View File

@ -340,19 +340,19 @@ loop:
continue; continue;
} }
if (ip == interesting) { if (ip == interesting) {
printf("%8d %5d ", printf("%8u %5u ",
ifnet.if_ipackets - ip->ift_ip, ifnet.if_ipackets - ip->ift_ip,
ifnet.if_ierrors - ip->ift_ie); ifnet.if_ierrors - ip->ift_ie);
if (bflag) if (bflag)
printf("%10d ", ifnet.if_ibytes - ip->ift_ib); printf("%10u ", ifnet.if_ibytes - ip->ift_ib);
printf("%8d %5d ", printf("%8u %5u ",
ifnet.if_opackets - ip->ift_op, ifnet.if_opackets - ip->ift_op,
ifnet.if_oerrors - ip->ift_oe); ifnet.if_oerrors - ip->ift_oe);
if (bflag) if (bflag)
printf("%10d ", ifnet.if_obytes - ip->ift_ob); printf("%10u ", ifnet.if_obytes - ip->ift_ob);
printf("%5d", ifnet.if_collisions - ip->ift_co); printf("%5u", ifnet.if_collisions - ip->ift_co);
if (dflag) if (dflag)
printf(" %5d", printf(" %5u",
ifnet.if_snd.ifq_drops - ip->ift_dr); ifnet.if_snd.ifq_drops - ip->ift_dr);
} }
ip->ift_ip = ifnet.if_ipackets; ip->ift_ip = ifnet.if_ipackets;
@ -374,19 +374,19 @@ loop:
off = (u_long) ifnet.if_next; off = (u_long) ifnet.if_next;
} }
if (lastif - iftot > 0) { if (lastif - iftot > 0) {
printf(" %8d %5d", printf(" %8u %5u",
sum->ift_ip - total->ift_ip, sum->ift_ip - total->ift_ip,
sum->ift_ie - total->ift_ie); sum->ift_ie - total->ift_ie);
if (bflag) if (bflag)
printf(" %10d", sum->ift_ib - total->ift_ib); printf(" %10u", sum->ift_ib - total->ift_ib);
printf(" %8d %5d", printf(" %8u %5u",
sum->ift_op - total->ift_op, sum->ift_op - total->ift_op,
sum->ift_oe - total->ift_oe); sum->ift_oe - total->ift_oe);
if (bflag) if (bflag)
printf(" %10d", sum->ift_ob - total->ift_ob); printf(" %10u", sum->ift_ob - total->ift_ob);
printf(" %5d", sum->ift_co - total->ift_co); printf(" %5u", sum->ift_co - total->ift_co);
if (dflag) if (dflag)
printf(" %5d", sum->ift_dr - total->ift_dr); printf(" %5u", sum->ift_dr - total->ift_dr);
} }
*total = *sum; *total = *sum;
putchar('\n'); putchar('\n');

View File

@ -100,16 +100,25 @@ protopr(off, name)
prev = (struct inpcb *)off; prev = (struct inpcb *)off;
for (next = head.lh_first; next != NULL; next = inpcb.inp_list.le_next) { for (next = head.lh_first; next != NULL; next = inpcb.inp_list.le_next) {
kread((u_long)next, (char *)&inpcb, sizeof (inpcb)); if (kread((u_long)next, (char *)&inpcb, sizeof (inpcb))) {
printf("???\n");
break;
}
if (!aflag && if (!aflag &&
inet_lnaof(inpcb.inp_laddr) == INADDR_ANY) { inet_lnaof(inpcb.inp_laddr) == INADDR_ANY) {
prev = next; prev = next;
continue; continue;
} }
kread((u_long)inpcb.inp_socket, (char *)&sockb, sizeof (sockb)); if (kread((u_long)inpcb.inp_socket, (char *)&sockb, sizeof (sockb))) {
printf("???\n");
break;
};
if (istcp) { if (istcp) {
kread((u_long)inpcb.inp_ppcb, if (kread((u_long)inpcb.inp_ppcb,
(char *)&tcpcb, sizeof (tcpcb)); (char *)&tcpcb, sizeof (tcpcb))) {
printf("???\n");
break;
};
} }
if (first) { if (first) {
printf("Active Internet connections"); printf("Active Internet connections");
@ -227,7 +236,6 @@ tcp_stats(off, name)
p(tcps_keepdrops, "\t\t%d connection%s dropped by keepalive\n"); p(tcps_keepdrops, "\t\t%d connection%s dropped by keepalive\n");
p(tcps_predack, "\t%d correct ACK header prediction%s\n"); p(tcps_predack, "\t%d correct ACK header prediction%s\n");
p(tcps_preddat, "\t%d correct data packet header prediction%s\n"); p(tcps_preddat, "\t%d correct data packet header prediction%s\n");
p3(tcps_pcbcachemiss, "\t%d PCB cache miss%s\n");
#undef p #undef p
#undef p2 #undef p2
#undef p3 #undef p3

View File

@ -431,7 +431,7 @@ kread(addr, buf, size)
{ {
if (kvm_read(kvmd, addr, buf, size) != size) { if (kvm_read(kvmd, addr, buf, size) != size) {
warnx("kvm_read: %s", kvm_geterr(kvmd)); warnx("%s", kvm_geterr(kvmd));
return (-1); return (-1);
} }
return (0); return (0);