Date: Tue, 22 Aug 1995 04:40:56 +0800 (CST) From: jdli@csie.nctu.edu.tw (Chien-Ta Lee) To: freebsd-hackers@FreeBSD.ORG Subject: How to get network traffic ? Message-ID: <199508212041.EAA01661@phoenix.csie.nctu.edu.tw>
next in thread | raw e-mail | index | archive | help
Hi : Question One : I am writing a system monitor - xsysinfo, may anyone tell me how to get my subnet's network traffic ( ?? k/s ) ? Currently I use this code to get packets come in and out of my host, how can I get the total load (K/s) about my subnet ?! getkval(nl[N_IFNET].n_value, (int *) &ifnetaddr, sizeof(ifnetaddr), "_ifnet"); old_packets = packets; packets.in_out = packets.collisions = 0; while (ifnetaddr) { kvm_read(kd, ifnetaddr, &ifnet, sizeof ifnet ); packets.in_out += ((ifnet.if_ipackets + ifnet.if_opackets) >> 2); packets.collisions += ifnet.if_collisions; ifnetaddr = (u_long) ifnet.if_next; } pkt_in_out = packets.in_out - old_packets.in_out; collisions = packets.collisions - old_packets.collisions; (code from xprform++) Question Two : What are Active, Inactive, Wired memory displayed by top ? How to get Total Memory, Used Memory, and Shared Memory ?! Currently I suspect that TotalMem = Act + Inact + Wired + Cache + Free UsedMem = Act + Inact SharedMem = Wired Is that correct ? ps. xsysinfo-0.1 is available at ftp.cdrom.com/pub/FreeBSD/incoming Thanks a lot. -- 不知何時, FreeBSD 悄悄的溜進了我可愛的小電腦.. 李 建 達 (Adonis) 交大資工 穩穩地生根了下來, 讓我心愛的PC魚躍翻身變成龍.. Mail: jdli@csie.nctu.edu.tw
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199508212041.EAA01661>