Solved

Connection analysis

Posted on 2009-04-09
23
260 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
Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

 
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

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

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

Suggested Solutions

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

820 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