Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
36
rated 0 times [  36] [ 0]  / answers: 1 / hits: 192827  / 1 Year ago, fri, april 14, 2023, 6:46:49

I am hosting quite a lot of virtual hosts using Apache in a basic LAMP set up with the help of Webmin/Virtualmin. I am looking for a top-like tool in which I can monitor current connections. The virtual hosting part seems to be giving me trouble here. Here's what I've tried:




  • netstat - I can see the connections, but they show me as if they're all using my primary domain, e.g. mydomain.com:www.

  • iftop - I like it a lot, but similar downside as netstat: does not show the virtual host.

  • apachetop - seems to be showing not information for all my virtual hosts. I'm logging to separate custom log files, which I'm suspecting is the cause for why it doesn't work.

  • ntop, darkstat, MRTG, bwm-ng, IPTraf - not working either.



So, basically, I'm looking for something similar to the current output of netstat, but to include the virtual host the request is for, e.g.: avirtualsite.com:www.


More From » apache2

 Answers
7

Andrea Corbellini's answer explains you why it won't work with the tools you're using and how Virtual Hosting works. Here's the most simple way I can think of to get it done in Apache...



mod_status will help you out.



Disclaimer: I can't tell how this is done in Webmin - I use bare configuration files to set up servers. Here's just a basic overview of the steps.



It's a top-like tool, but represented as a web page. It lists the current state directly queried from Apache, so it's not depending on parsing log files like apachetop does.




  1. Enable mod_status:



    sudo a2enmod status

  2. Grant yourself access.




    • Open /etc/apache2/mods-enabled/status.conf and edit:

    • Set ExtendedStatus to On (optional, but more awesomeness and a little slower)

    • Within the <Location /server-status>, append your IP address to the line with the Allow directive. Example:



      Allow from 127.0.0.1 ::1 66.77.88.99


  3. Restart Apache:



    sudo service apache2 restart

  4. Enjoy the tool in your browser, for example: http://1.2.3.4/server-status



    It will look like this example screenshot.


  5. Keep pressing F5 to get updates. Or get an awesome browser plugin and watch it being updated!







Webmin



addendum by the OP for future visitors



In Webmin, the basic steps about the Status module can be found here:




  • Servers -> Apache Webserver -> Configure Apache Modules

  • Select the Status module and click click Enable Selected Modules



enter image description here


[#33254] Saturday, April 15, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
allowiel

Total Points: 189
Total Questions: 103
Total Answers: 105

Location: Slovenia
Member since Thu, Mar 18, 2021
3 Years ago
;