Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 267
  • Last Modified:

Connection analysis

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
opensourcenija
Asked:
opensourcenija
  • 12
  • 11
1 Solution
 
ahoffmannCommented:
could you pleas post an example of the command output with the IP in question
0
 
opensourcenijaAuthor Commented:
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
 
ahoffmannCommented:
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
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 
ahoffmannCommented:
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
 
opensourcenijaAuthor Commented:
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
 
ahoffmannCommented:
> .. '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
 
opensourcenijaAuthor Commented:
sorry it didnt work. any other solution . Thanks
0
 
ahoffmannCommented:
It does work.
If you  experiance something else, then please post what did and what you get. Please post commands and results verbatim.
0
 
opensourcenijaAuthor Commented:
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
 
opensourcenijaAuthor Commented:
The html file was created but it is blank.

No record on it , I couldn't get any log file from it Thanks
0
 
ahoffmannCommented:
> awk: 'BEGIN{print

sounds like you work with cmd.exe or something like that, then you have to exchange ' with " and vice versa
0
 
opensourcenijaAuthor Commented:
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
 
ahoffmannCommented:
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
 
opensourcenijaAuthor Commented:
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
 
ahoffmannCommented:
> .. looking at the HTML file that was created,
does the  netstat -an  command list connected clients?
0
 
opensourcenijaAuthor Commented:
Didn't understand your question
0
 
ahoffmannCommented:
please issue the command
   netstat -an
then post all line marked ESTABLESHED
0
 
opensourcenijaAuthor Commented:
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
 
opensourcenijaAuthor Commented:
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
 
ahoffmannCommented:
what do you get for following:

echo "TCP    192.168.0.172:11000    192.168.0.171:4301     ESTABLISHED" |awk -f p.awk
0
 
opensourcenijaAuthor Commented:
where do i execute the command. Please can u state answer clearing . Thanks
0
 
ahoffmannCommented:
in a cmd.exe
0
 
opensourcenijaAuthor Commented:
It did partially solve my problems
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

  • 12
  • 11
Tackle projects and never again get stuck behind a technical roadblock.
Join Now