Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Win32 NetStat Process Interface

by vbrtrmn (Pilgrim)
on Aug 06, 2003 at 02:29 UTC ( [id://281247]=CUFP: print w/replies, xml ) Need Help??

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://281247]
Approved by phydeauxarff
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-19 20:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found