Solved

Connection analysis

Posted on 2009-04-09
23
254 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
  • 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
 
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
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 

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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now