-2

I have the following question. On a CentOS machine I run an application which connects to another system. I am interested in finding out on which ports (input/output) the communication happened. The application runs only for a second or so and I cannot get its pid. Is there a way to start a network monitoring of my application? Logging all the ports that were used?

I am not root on the CentOS machine.

Extra info:

  • The application is a java wrapper while the basic functionalities are coded in C.
  • I cannot use tcpdump/wireshark.
  • Since my application is the only one using the remote server, a monitoring based on the remote IP address would be fine too.

Thanks in advance!

5
  • The best solution is probably to modify the application itself to log it.
    – kasperd
    Aug 27, 2014 at 22:47
  • See the related: askubuntu.com/questions/11709/…
    – Zoredache
    Aug 27, 2014 at 23:35
  • I cannot modify my application, it is just a java wrapper and all basic functionalities are implemented in C.
    – johnx
    Aug 28, 2014 at 7:40
  • Your not being root is a problem you can work around: can't you just build yourself a CentOS virtual machine and test the application there?
    – pqnet
    Aug 29, 2014 at 11:25
  • no, I cannot do that because the Sever accepts only requests from that particular CentOS machine (only its IP address).
    – johnx
    Aug 30, 2014 at 18:23

2 Answers 2

2

Try running it through strace. Of course this isn't a trivial tool to use since you need to know the various system calls for name resolution, and opening sockets, and other network communications.

A simpler solution might be to just run tcpdump/wireshark. Stop, any other application from accessing the network you can first.

3
  • strace looks full of information... difficult to understand:( The remote server is used only by my application, so probably it would be easier to monitor the connection to the server IP. Could you suggest me how to do that with tcpdump? I saw that tcpdump is available to my user.
    – johnx
    Aug 28, 2014 at 7:41
  • UPDATE: I cannot run tcpdump... no suitable device found!
    – johnx
    Aug 28, 2014 at 7:51
  • it must be ran with root privileges.
    – Zoredache
    Aug 28, 2014 at 15:34
0

Try

strace -e trace=connect,socket,bind,accept,listen -f /path/to/myapp

This will only log syscalls that are relevant to your interests.

You can also try

strace -e trace=network -f /path/to/myapp

This will also log syscalls related to network communication, not just connection establishment.

1
  • It looks a bit simpler, I will give it a deeper look :) Thanks!
    – johnx
    Aug 30, 2014 at 18:24

Not the answer you're looking for? Browse other questions tagged .