Solved

Connection analysis

Posted on 2009-04-09
23
249 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
Comment Utility
could you pleas post an example of the command output with the IP in question
0
 

Author Comment

by:opensourcenija
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
> .. '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
Comment Utility
sorry it didnt work. any other solution . Thanks
0
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
> awk: 'BEGIN{print

sounds like you work with cmd.exe or something like that, then you have to exchange ' with " and vice versa
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:opensourcenija
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
> .. looking at the HTML file that was created,
does the  netstat -an  command list connected clients?
0
 

Author Comment

by:opensourcenija
Comment Utility
Didn't understand your question
0
 
LVL 51

Expert Comment

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

Author Comment

by:opensourcenija
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
where do i execute the command. Please can u state answer clearing . Thanks
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 250 total points
Comment Utility
in a cmd.exe
0
 

Author Closing Comment

by:opensourcenija
Comment Utility
It did partially solve my problems
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Convert websphere application server default chained Certificates from 1024 to 2048 keysize or higher size and also you can change signatureAlgorithm . Please make sure Websphere Application Server fixpack 7.0.0.23 or Above. The following steps a…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

744 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

16 Experts available now in Live!

Get 1:1 Help Now