Solved

Connection analysis

Posted on 2009-04-09
23
265 Views
Last Modified: 2012-05-06
I am writing to get a code , that will display in HTML format , list of IP addresses that are connected to my server (SMPP) over a port. I would appreciate any help with sample code or a reference link where similar problem has been solved.

Thanks expert
0
Comment
Question by:opensourcenija
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 12
  • 11
23 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 24131295
could you pleas post an example of the command output with the IP in question
0
 

Author Comment

by:opensourcenija
ID: 24136471
I dont understand what you mean ahoffmann.

I have a Windows Sever 2003 and installed and SMPP Server installled so that clients can connect over a port.

Just like wireeshark or ethereal monitor . I want to be able to check logs over http , for clients who are connected to me on that server
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 24146058
if you have awk or gwak installed you can use something like
(all in one line)
where 4242 is the port the clients are connected too.
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 51

Expert Comment

by:ahoffmann
ID: 24146062
if you have awk or gwak installed you can use something like:
(all in one line)
where 4242 is the port the clients are connected too.
netstat -an | awk 'BEGIN{print "<html><body><ul>"}/ESTABL/{if($4~/:4242$/){print "<li>",substr($4,0,index($4,":")-1),"</li>"}}END{print "</ul></body></html>"}' > connected_IP.html

Open in new window

0
 

Author Comment

by:opensourcenija
ID: 24148837
installed gwak from http://sourceforge.net/project/downloading.php?groupname=gnuwin32&filename=gawk-3.1.6-1-setup.exe&use_mirror=switch for windows server 2003

when i execute the command ( I get the following )

netstat -an | awk 'BEGIN{print "<html><body><ul>"}/ESTABL/{if($4~/:4242$/){print "<li>",substr($4,0,index($4,":")-1),"</li>"}}END{print "</ul></body></html>"}' > connected_IP.html

'awk' is not recognised as and internal or external command
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 24153763
> .. 'awk' is not recognised
you have to replace awk by gawk or even gawk.exe
if gawk.exe is not found in the directories specified in PATH environment variable, you have to use a full path for dawk.exe

BTW, as I don'z have M$ netstat available, my suggestion might be söighlly incorrect, in that case please post a netstat's output line containing the ESTABLISHED information
0
 

Author Comment

by:opensourcenija
ID: 24155286
sorry it didnt work. any other solution . Thanks
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 24156645
It does work.
If you  experiance something else, then please post what did and what you get. Please post commands and results verbatim.
0
 

Author Comment

by:opensourcenija
ID: 24156681
C:\Program Files\GnuWin32\bin>netstat -an | awk 'BEGIN{print "<html><body><ul>"}/ESTABL/{if($4~/:4242$/){print "<li>",substr($4,0,index($4,":")-1),"</li>"}}END{print "</ul></body></html>"}' > connected_IP.html

awk: 'BEGIN{print
awk: ^ invalid char ''' in expressio

C:\Program Files\GnuWin32\bin>
0
 

Author Comment

by:opensourcenija
ID: 24156712
The html file was created but it is blank.

No record on it , I couldn't get any log file from it Thanks
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 24165187
> awk: 'BEGIN{print

sounds like you work with cmd.exe or something like that, then you have to exchange ' with " and vice versa
0
 

Author Comment

by:opensourcenija
ID: 24165569
Thanks ahoffmann for your response , I think this looks like something that would work out but still yet after i replaced it , It still didnt work , below is the output of this command :


C:\Program Files\GnuWin32\bin>netstat -an | awk "BEGIN{print "<html><body><ul>"}
/ESTABL/{if($4~/:4242$/){print "<li>",substr($4,0,index($4,":")-1),"</li>"}}END{
print "</ul></body></html>"}" > connected_IP.html
< was unexpected at this time.

Yes I am using cmd.exe

I really appreciate your support
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 24175376
sorry can't test with stupid cmd.exe, please write the awk script in a file, i.e. ip.awk:

then call it like:
netstat -an | awk -f ip.awk > connected_IP.html
BEGIN{print "<html><body><ul>"}/ESTABL/{if($4~/:4242$/){print "<li>",substr($4,0,index($4,":")-1),"</li>"}}END{print "</ul></body></html>"}

Open in new window

0
 

Author Comment

by:opensourcenija
ID: 24201831
Thanks for the input . I was able to run the program that way . But looking at the HTML file that was created, there is no log on clients connected.

what else can be done .

Thanks
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 24223513
> .. looking at the HTML file that was created,
does the  netstat -an  command list connected clients?
0
 

Author Comment

by:opensourcenija
ID: 24223707
Didn't understand your question
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 24223738
please issue the command
   netstat -an
then post all line marked ESTABLESHED
0
 

Author Comment

by:opensourcenija
ID: 24223799
TCP    0.0.0.0:11000          0.0.0.0:0              LISTENING
 TCP    127.0.0.1:135          127.0.0.1:1994         ESTABLISHED
 TCP    127.0.0.1:1026         127.0.0.1:1995         ESTABLISHED
 TCP    192.168.0.172:3389     192.168.0.254:2623     ESTABLISHED
 TCP    192.168.0.172:11000    192.168.0.171:4301     ESTABLISHED
 TCP    192.168.0.182:4190     192.168.0.182:1433     ESTABLISHED


enabled a single connection from  my local server for testing.

0
 

Author Comment

by:opensourcenija
ID: 24223819
Then i now executed the command.

netstat -an | awk -f ip.awk > connected_IP.html

and now i checked the connected_IP.html and nothing is there
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 24224861
what do you get for following:

echo "TCP    192.168.0.172:11000    192.168.0.171:4301     ESTABLISHED" |awk -f p.awk
0
 

Author Comment

by:opensourcenija
ID: 24225845
where do i execute the command. Please can u state answer clearing . Thanks
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 250 total points
ID: 24237032
in a cmd.exe
0
 

Author Closing Comment

by:opensourcenija
ID: 31568622
It did partially solve my problems
0

Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
What You Need to Know when Searching for a Webhost Provider
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question