A tool to see active connections to port 80

Discussion in 'Web Design and Development' started by mds1256, Apr 9, 2011.

  1. mds1256 macrumors regular

    Joined:
    Apr 9, 2011
    #1
    Hi, currently running a test site from my macbook pro using MAMP, would like to see how many users are currently connected to it.

    Is there any easy way to see these connections
     
  2. displaced macrumors 65816

    displaced

    Joined:
    Jun 23, 2003
    Location:
    Gravesend, United Kingdom
    #2
    Try visiting http://localhost:80/server-status on your MacBook Pro that's serving the site.

    It depends on mod_status being enabled on your Apache installation (I don't know if it is by default - it's definitely enabled on my OS X Server installation).

    Note that also this page can only be accessed via localhost. If after entering the above URL your browser resolves the 'localhost' to something else (e.g. http://yourdomain.com/) then you'll more than likely see a Forbidden error. Instead, try visiting http://127.0.0.1:80/server-status

    Cheers,
    Chris
     
  3. jb27 macrumors newbie

    Joined:
    Mar 4, 2010
    #3
    I would use netstat from the terminal and grep on established and on 80 to see how many connections are in the established state. You can wrap a while command and/or a sleep command to see this info at certain intervals.
     
  4. mds1256 thread starter macrumors regular

    Joined:
    Apr 9, 2011
    #4
    Thanks but came back as a 404



     
  5. mds1256 thread starter macrumors regular

    Joined:
    Apr 9, 2011
    #5
    Have you got an example of the commands i need to type in for this?

    not sure how to tie netstat and grep together
    Thanks

     
  6. jb27 macrumors newbie

    Joined:
    Mar 4, 2010
    #6
    No way to test this command right now, but try this:

    Netstat -an | grep -i est | grep -i 80


    If you run netstat -an you can see a good amount of info, but it won't be filtered. If you want just a specific count of connections, you can then pipe the above command to wc like this:

    Netstat -an | grep -i est | grep -i 80 | wc -l

    Use it after verifying that what comes back from the first command.

    You can also try netstat -anp to get the process information as well (http). For more info, you can just look at the man page: man netstat

    This *should* get you what you want, again, no way for me to test right now. Let us know how it goes.
     
  7. mds1256, Apr 12, 2011
    Last edited: Apr 12, 2011

    mds1256 thread starter macrumors regular

    Joined:
    Apr 9, 2011
    #7
    That works a treat!! :)

    Ok one other question and I wont bother you again :cool:

    How can i create a while loop to run this, not familiar with terminal at all but I know it will be possibly something like this:

    while(1=1)
    {
    Netstat -an | grep -i est | grep -i 80
    }


    but not sure how to script this up etc.

    Can you also limit the results to show inbound requests only?

    Thanks again!


     
  8. jb27 macrumors newbie

    Joined:
    Mar 4, 2010
    #8
    While true; do Netstat -an | grep -i est | grep -i 80; sleep 5

    (Sleeps for number of seconds)

    I think that syntax is right. If not, just do a search for while true in google, plenty of examples will come up.

    For your second question, type "man netstat" in the terminal and see if there are any other switches of use to you. You will also see that netstat has a switch in there to have nestat display connection information on an interval (-c or delay).

    Let us know how you make out.
     
  9. mds1256 thread starter macrumors regular

    Joined:
    Apr 9, 2011
    #9
    cool, the syntax was:

    while true; do netstat -an | grep -i est | grep -i 80; sleep 5; done;

    thanks again, will keep looking to see if i can get inbound only.



     

Share This Page