• Welcome to Valhalla Legends Archive.
 

IP Statistics

Started by Arta, October 07, 2003, 09:31 AM

Previous topic - Next topic

Arta

I'm trying to write a small service to monitor network usage on my server. It should add results, polled every minute, to a MySQL database which is then used by a PHP script to draw a graph of network use vs RTT to my ISP's default gateway.

The problem is this: My server has 2 interfaces - one public and one private - and I only want to monitor the public interface. The functions I've been looking at (GetIpStatisticsEx, GetTcpStatisticsEx, GetUdpStatisticsEx) don't provide an option for or mention which adapter they return information about, so I assume they return aggregated data about all of them. Does anyone know of a way to get separate statistics for each adapter? Similarly to taskmgr.exe?

Adron

One way would be to write a ndis intermediary driver, which could have several filter rules and packet / byte counts for matches for each rule...

Skywing

#2
Quote from: Adron on October 07, 2003, 11:46 AM
One way would be to write a ndis intermediary driver, which could have several filter rules and packet / byte counts for matches for each rule...
Actually, that's pretty much going overboard.  Most (all?) NICs implement many of the statistics OIDs, which taskmgr queries.  You can use WMI for this, or you can use the performance counter interface (poke around in Network with perfmon to find these).  The best would probably be to use WMI, because IIRC you need special privileges to do performance monitoring, but taskmgr (and the link notification area icon) seem to have no trouble displaying stats when run under a limited user account.

Edit:
It looks like you can also query this by requesting an OID directly via IOCTL_NDIS_QUERY_GLOBAL_STATS.  I looked around in the WMI SDK some time, and I never found out how to request OIDs through it despite things saying you could.  Oh well.

Arta


Banana fanna fo fanna

Here's my guess:

windows monitoring interface

Here's my 5 second google:

http://www.ndis.com/faq/QA01050301/default.htm

Skywing

Quote from: Arta[vL] on October 07, 2003, 06:07 PM
WMI?
Windows Management Instrumentation.  Be ware that it uses COM, BSTRs, and VARIANTs extensively.