summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authoralfred <alfred@FreeBSD.org>2003-12-26 18:47:41 +0000
committeralfred <alfred@FreeBSD.org>2003-12-26 18:47:41 +0000
commit31fadac6914236d1695ba1af8d3060ac428a5c20 (patch)
tree40c40b301aeb952fc2f25955047a754e18f6a962 /usr.bin
parent0c878eef027c8107cc08f8198c283e3abeb31c53 (diff)
downloadFreeBSD-src-31fadac6914236d1695ba1af8d3060ac428a5c20.zip
FreeBSD-src-31fadac6914236d1695ba1af8d3060ac428a5c20.tar.gz
Fix percentages by using long long to hold values for 'space',
overflow was breaking a bunch of the stats, specifically the percentage displayed for wired memory. Fix the output for current/peak/max lines, I forgot to output the types. 161/320/51200 (current/peak/max): -to- 639/25696/51200 mbufs in use (current/peak/max):
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/netstat/mbuf.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/usr.bin/netstat/mbuf.c b/usr.bin/netstat/mbuf.c
index 0e6e993..38a6c93 100644
--- a/usr.bin/netstat/mbuf.c
+++ b/usr.bin/netstat/mbuf.c
@@ -101,7 +101,9 @@ mbpr(u_long mbaddr, u_long mbtaddr __unused, u_long nmbcaddr, u_long nmbufaddr,
{
int i, j, nmbufs, nmbclusters, page_size, num_objs;
u_int mbuf_hiwm, clust_hiwm, mbuf_lowm, clust_lowm;
- u_long totspace[2], totused[2], gentotnum, gentotfree, totnum, totfree;
+ unsigned long long totspace[2];
+ u_long totused[2];
+ u_long gentotnum, gentotfree, totnum, totfree;
short nmbtypes;
size_t mlen;
long *mbtypes = NULL;
@@ -254,7 +256,7 @@ mbpr(u_long mbaddr, u_long mbtaddr __unused, u_long nmbcaddr, u_long nmbufaddr,
gentotnum - gentotfree, gentotnum);
} else {
/* XXX: peak is now wrong. */
- printf("%lu/%lu/%d (current/peak/max):\n",
+ printf("%lu/%lu/%d mbufs in use (current/peak/max):\n",
totused[0], totnum, nmbufs);
}
@@ -286,7 +288,7 @@ mbpr(u_long mbaddr, u_long mbtaddr __unused, u_long nmbcaddr, u_long nmbufaddr,
mbtypes[i], i);
}
if (cflag)
- printf("\t%lu%% of mbuf map consumed\n",
+ printf("\t%llu%% of mbuf map consumed\n",
((totspace[0] * 100) / (nmbufs * MSIZE)));
totnum = mbpstat[GENLST]->mb_clbucks * mbstat->m_clperbuck;
@@ -311,7 +313,7 @@ mbpr(u_long mbaddr, u_long mbtaddr __unused, u_long nmbcaddr, u_long nmbufaddr,
gentotnum - gentotfree, gentotnum);
} else {
/* XXX: peak is now wrong. */
- printf("%lu/%lu/%d (current/peak/max):\n",
+ printf("%lu/%lu/%d mbuf clusters in use (current/peak/max)\n",
totused[1], totnum, nmbclusters);
}
for (i = 0; cflag && i < (num_objs - 1); i++) {
@@ -330,12 +332,13 @@ mbpr(u_long mbaddr, u_long mbtaddr __unused, u_long nmbcaddr, u_long nmbufaddr,
#endif
}
if (cflag)
- printf("\t%lu%% of cluster map consumed\n",
+ printf("\t%llu%% of cluster map consumed\n",
((totspace[1] * 100) / (nmbclusters * MCLBYTES)));
-
- printf("%lu KBytes of wired memory reserved (%lu%% in use)\n",
- (totspace[0] + totspace[1]) / 1024, ((totused[0] * MSIZE +
- totused[1] * MCLBYTES) * 100) / (totspace[0] + totspace[1]));
+ printf("%llu KBytes allocated to network "
+ "(%lluK mbuf, %lluK mbuf cluster)\n",
+ (totspace[0] + totspace[1]) / 1024,
+ totspace[0] / 1024,
+ totspace[1] / 1024);
printf("%lu requests for memory denied\n", mbstat->m_drops);
printf("%lu requests for memory delayed\n", mbstat->m_wait);
printf("%lu calls to protocol drain routines\n", mbstat->m_drain);
OpenPOWER on IntegriCloud