I was checking out my bandwidth consumption on one of my workstations the other day and noticed that I was sending a lot of traffic (400MB in 14 days). This program basically checks the PIDs of the applications using bandwidth, allows you to drill down into those PIDs and figure out exactally what is going on.

I haven't developed this very far, it currently runs on:

Windows 2000
Apache 1.3
Perl 5.8.0

There are massive security holes, if you run this on your server, so I highly recommend that you don't. The program calls netstat.exe, tlist.exe, and kill.exe. The tlist & kill programs are available in the Windows NT 4.0 Resource Kit Support Tools.

#!perl.exe use strict; use CGI qw(:all); use CGI::Carp('fatalsToBrowser'); print header(); print "<pre>"; print "<b>Netstat Viewer</b>\n"; print <<HTMLEND; <a href="?netstat=allconnections">All Connections</a> | <a href="?nets +tat=ethernetstats">Ethernet Statistics</a> | <a href="?netstat=routin +gtable">Routing Table</a> HTMLEND if (param('netstat') eq "allconnections") { # All Connections my @netstats = `netstat.exe -o -a -n `; map { chomp $_; s|(\d+)\r|<a href=\"?tlist=$1\">$1</a>\r|i; print $_; } @netstats; } elsif (param('netstat') eq "routingtable") { # Routing Table print `netstat.exe -r`; } elsif (param('netstat') eq "ethernetstats") { # Ethernet Statistics print `netstat.exe -e -s`; } elsif (param('tlist')) { my $pid = param('tlist'); my @tlist = `tlist $pid`; if (@tlist) { print "<a href=\"?kill=$pid\">kill this process!</a>\n\n"; print @tlist; } } elsif (param('kill')) { my $pid = param('kill'); print `kill -f $pid`; } exit;

--
paul


In reply to Win32 NetStat Process Interface by vbrtrmn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.