View Full Version : Which domains are being viewed?
hi ,
I am curious to know which domains are being accessed in apache ' live' . Is there any sort of web-based or SSH way to know the current connections.
I have used netstat , but that only give me the connections, it doesnt give any details on the websites being viewed by visitors.
PvUtrix
05-14-2005, 05:47 AM
If you have Cpanel, try "WHM>Server Status >Apache Server Status"
There are several easy ways to do this from the shell. Eg. tcpdump. SSH to the shell. Find out the name of your interfaces using ipconfig. Then run tcpdump -i venet0 port 80 This will give you a listing of all the packets to port 80 of venet0. This is the name of my shared IP.
An other easy way ist just to run 'watch netstat'. Eventually with some filtering options.
I sometimes use a program called iptraf on our office server. This is a Linux consol application which gives you a lot of filter options. If you put this into a 'GNU screen' window, you might even keep it running when logged out.
Erich
An easy variation of netstat is:
watch "netstat | grep :"
Erich
Thanks ESC , the last command : watch "netstat | grep :" is pretty cool.
It does show all the IP's / Ports and LIVE connections to the server.
But what i actually want to see it , What domains in apache are being accessed LIVE.
Like if i or someone opens his browser and visits the domain "thisisadomain.com" which is hosted on my server, Can i see in some sort of interface that thisisadomain.com is currently being visited?
If you have Cpanel, try "WHM>Server Status >Apache Server Status"
PvUtrix , this does give me good status , but they are static, i want similar , stats but they should be LIVE.
Sorry, I’ve overread some details in your first posting.
How to do this task with a shell command or script might depend on the structure of your server logs. I’m on a Plesk account and here the default configuration is ‘separate Apache logs for separate domains’. I think this is the default for WHM/CPanel too. If everything is written into one access log things are much easier.
In the latter case I would suggest to use some combination of the watch and tail commands (you have to insert your correct file path of course), like:
watch tail /var/log/httpd/access_logIf you have several access logs, one for each site, things are obviously more complicated and demand for a little script to read the last lines of each access_log file, merge them, sort them by the access time and pipe this through watch and tail. Eventually you might pipe the output through some filters too, stripping away unnecessary details, to make it more readable.
Erich
Sorry, I’ve overread some details in your first posting.
How to do this task with a shell command or script might depend on the structure of your server logs. I’m on a Plesk account and here the default configuration is ‘separate Apache logs for separate domains’. I think this is the default for WHM/CPanel too. If everything is written into one access log things are much easier.
In the latter case I would suggest to use some combination of the watch and tail commands (you have to insert your correct file path of course), like:
watch tail /var/log/httpd/access_logIf you have several access logs, one for each site, things are obviously more complicated and demand for a little script to read the last lines of each access_log file, merge them, sort them by the access time and pipe this through watch and tail. Eventually you might pipe the output through some filters too, stripping away unnecessary details, to make it more readable.
Erich
Hi Erich,
Thanks for the details, Im sure the scripting you mentioned at the end will help me. But :( im a newbie and dont know much Nix commands/Scripting. Can you help me here or give me some usefull websites where i can learn. ( i am a good learner BTW)
Regards.
Hi W3S,
Here're some commented links about shell scripting, notably form the Linux Documentation Project. I'm sorry that I cannot help you directly. My shell scripting abilities are very poor and I would need probably a considerable time which I do not have by now to get this running. Anyway, a somewhat good server administrator should probably have this scripting knowledge in her/his tools pack and creating this script should be a 5 minutes task - OK, definitely not for me, but I’ve put those references (again) on my reading list. :D
BASH Programming - Introduction HOW-TO
Mike G Mikkey
Cit: "This article intends to help you to start programming basic-intermediate shell scripts. It does not intend to be an advanced document (see the title). I am NOT an expert nor guru shell programmer. I decided to write this because I'll learn a lot and it might be useful to other people. Any feedback will be apreciated, specially in the patch form :)"
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
Bash Guide for Beginners
Machtelt Garrels
Cit: "The Bash Guide for Beginners gets you started with Bash scripting and bridges the gap between the Bash HOWTO and the Advanced Bash Scripting Guide. Everybody who wants to make life easier on themselves, power users and sysadmins alike, can benefit from reading this practical course. The guide contains lots of examples and exercises at the end of each chapter, demonstrating the theory and helping you practice. Bash is available on a wide variety of UNIX, Linux, MS Windows and other systems."
http://www.tldp.org/LDP/Bash-Beginners-Guide/html/index.html
http://www.tldp.org/LDP/Bash-Beginners-Guide/Bash-Beginners-Guide.pdf
Advanced Bash-Scripting Guide
Mendel Cooper
Cit.: "This document is both a tutorial and a reference on shell scripting with Bash. It assumes no previous knowledge of scripting or programming, but progresses rapidly toward an intermediate/advanced level of instruction. The exercises and heavily-commented examples invite active reader participation. Still, it is a work in progress. The intention is to add much supplementary material in future updates to this document, as it evolves into a comprehensive book that matches or surpasses any of the shell scripting manuals in print."
http://www.tldp.org/LDP/abs/html/
http://www.tldp.org/LDP/abs/abs-guide.pdf
Learning the shell
William Shotts, Jr.
A wonderful web site dedicated to the learning of Linux shell commands and to the Open Source idea. The site contains among others a selected and handpicked list of online references, online tutorials and books.
http://linuxcommand.org
Erich
fus1on
05-17-2005, 06:53 AM
Paste:
Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from .example.com
</Location>
ExtendedStatus On
- into /etc/httpd/conf.d/status.conf, changing .example.com to either localhost (to view from shell) or to your own domain to view locally from your web browser.
Then you can locally run 'apachectl fullstatus' or visit http://yourdomain.com/server-status and you should see a list of connections together with the domains.
*note this is all from memory, and I may have mistaken something!
Thanks for the details Erich and Fus1on, I will concider these and try to implement them. Well appreciated.
Thanks once again.
W3S
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.