Poll

Apache Staus - Access

Useful: should be added to main menus
2 (50%)
Nope: will never use it
1 (25%)
Where's the Tylenol?
1 (25%)
None of the above
0 (0%)

Total Members Voted: 4

Voting closed: April 15, 2020, 02:12:36 PM

Author Topic: Apache Status - Accesses  (Read 18025 times)

0 Members and 1 Guest are viewing this topic.

Apache Status - Accesses
« on: February 15, 2020, 02:10:42 PM »
Following my feature request, I have now integrated it in CWP, so for the benefit of others..

1. Create /usr/local/cwpsrv/htdocs/resources/admin/modules/apache_status.php with the following contents (I use vi but you may prefer nano or File Manager)
Code: [Select]
<?php
$apache_status 
shell_exec("/usr/local/apache/bin/apachectl fullstatus | grep \"GET\" | grep -v \"server-status\" | sed 's/[[:space:]]*$//' | cut -d\" \" -f\"5,14-\" " );
echo 
"<h3>Apache Status - Accesses</h3>";
echo 
"<pre>".$apache_status."</pre>";
?>



2. Append (add to the end) the following to /usr/local/cwpsrv/htdocs/resources/admin/include/3rdparty.php
Code: [Select]
<li><a href="index.php?module=apache_status"><span class="icon16 icomoon-icon-arrow-right-3"></span>Apache Status - Accesses</a></li>

3. Refresh your CWP admin screen.

Re: Apache Status - Accesses
« Reply #1 on: February 15, 2020, 03:14:44 PM »
Updated module, with column headers and improved the output.
I'm sure developers could do a neater job of this.  ???

Code: [Select]
<?php
// Apache Status - Accesses v0.3
$apache_status shell_exec("/usr/local/apache/bin/apachectl fullstatus | grep \"GET\" | grep -v \"127.0.0.1\" | sed 's/[[:space:]]*$//' | cut -d\" \" -f\"5,14-\" | sort -r -k1" );
echo 
"<h3>Apache Status - Accesses</h3>";
echo 
"<p>&nbsp;CPU&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Child&nbsp;&nbsp;&nbsp;&nbsp;Slot";
echo 
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Type&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
echo 
"Domain&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Request</p>";                     
echo 
"<pre>".$apache_status."</pre>";
echo 
"<p>";
echo 
"CPU   CPU usage, number of seconds<br>";
echo 
"Child Megabytes transferred this child<br>";
echo 
"Slot  Total megabytes transferred this slot<br>";
echo 
"</p>";
?>



Typical application: periodically monitor activity and spot the rogue crawlers/hackers IP addresses. Then use CSF to block 'em, or complete subnets/Countries. Use an IP checker and make sure you don't block customers and/or the (more) useful search engines.
« Last Edit: February 15, 2020, 03:33:52 PM by ejsolutions »

Offline
****
Re: Apache Status - Accesses
« Reply #2 on: February 15, 2020, 03:27:30 PM »
To Add under webservers instead of Developer Options
/usr/local/cwpsrv/htdocs/resources/admin/include/3rdparty.php
<script type="text/javascript">
        $(document).ready(function() {
                var newButtons = ''
                +' <li>'
                +' <a href="?module=apache_status"><span aria-hidden="true" class="icon16 icomoon-icon-switch"></span>Apache Status - Accesses</span></a>'
                +'</li>';
                $("ul#mn-3-sub").prepend(newButtons);
        });
</script>
« Last Edit: February 15, 2020, 03:41:37 PM by rcschaff »
Google Hangouts:  rcschaff82@gmail.com

Re: Apache Status - Accesses
« Reply #3 on: February 15, 2020, 03:34:40 PM »
Brilliant! Many thanks.

Re: Apache Status - Accesses
« Reply #4 on: February 18, 2020, 10:48:13 AM »
Warning: it looks as though posting this is against the rules!

Offline
*****
Re: Apache Status - Accesses
« Reply #5 on: February 18, 2020, 10:51:56 AM »
its not against rule developing module/themes are not prohibited, you can't modify CWP scripts and packages which comes with it, package configs can be modified.

Offline
*
Re: Apache Status - Accesses
« Reply #6 on: October 01, 2020, 06:33:49 PM »
tried this but et 404 files not found
issuing command
#/usr/local/apache/bin/apachectl fullstatus
give me 404 ngnix error

I configure webserver with ngnix/varnish/apache

Offline
*
Re: Apache Status - Accesses
« Reply #7 on: June 24, 2023, 07:36:41 PM »
This would be better and show more info:

Code: [Select]
<?php
// Apache Status - Accesses v0.4

$url "http://localhost/server-status";
$ch_session curl_init();
curl_setopt($ch_sessionCURLOPT_RETURNTRANSFER1);
curl_setopt($ch_sessionCURLOPT_URL$url);
$result_url curl_exec($ch_session);
echo 
$result_url;

?>

Offline
***
Re: Apache Status - Accesses
« Reply #8 on: September 26, 2024, 06:26:28 PM »
In case the server is configured to use the webserver config like: Nginx+Apache, Nginx+Varnish+Apache then the script must be changed to:

Code: [Select]
<?php
// Apache Status - Accesses v0.4

$url "http://localhost:8181/server-status";
$ch_session curl_init();
curl_setopt($ch_sessionCURLOPT_RETURNTRANSFER1);
curl_setopt($ch_sessionCURLOPT_URL$url);
$result_url curl_exec($ch_session);
echo 
$result_url;

?>

Additionally, to see the reals IPs of the visitors the module mod_rpaf should be replaced with the module mod_remoteip in the main apache config and configured accordingly. In other case the main IP address of the server will be shown as the visitor's IP.

Offline
*
Re: Apache Status - Accesses
« Reply #9 on: November 25, 2024, 02:36:45 PM »
I have enabled the mod_remoteip, only uncommented the  line "LoadModule remoteip_module modules/mod_remoteip.so" on httpd.conf

but how to configure it to show the real remote ip? the /apache-status is only showing the local server ip

Offline
***
Re: Apache Status - Accesses
« Reply #10 on: November 25, 2024, 04:24:51 PM »
Put the following content into the file:

/usr/local/apache/conf.d/remoteip.conf

Code: [Select]
RemoteIPHeader X-Forwarded-For
RemoteIPProxiesHeader CF-Connecting-IP
RemoteIPInternalProxy 127.0.0.1 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 XXX.XXX.XXX.XXX

RemoteIPTrustedProxy 173.245.48.0/20
RemoteIPTrustedProxy 103.21.244.0/22
RemoteIPTrustedProxy 103.22.200.0/22
RemoteIPTrustedProxy 103.31.4.0/22
RemoteIPTrustedProxy 141.101.64.0/18
RemoteIPTrustedProxy 108.162.192.0/18
RemoteIPTrustedProxy 190.93.240.0/20
RemoteIPTrustedProxy 188.114.96.0/20
RemoteIPTrustedProxy 197.234.240.0/22
RemoteIPTrustedProxy 198.41.128.0/17
RemoteIPTrustedProxy 162.158.0.0/15
RemoteIPTrustedProxy 104.16.0.0/13
RemoteIPTrustedProxy 104.24.0.0/14
RemoteIPTrustedProxy 172.64.0.0/13
RemoteIPTrustedProxy 131.0.72.0/22

Replace XXX.XXX.XXX.XXX with the main IP address of your server/VPS.

Please note it will show the real IP addresses of the visitors if some site is configured to be proxied via CloudFlare.

Offline
*
Re: Apache Status - Accesses
« Reply #11 on: November 26, 2024, 07:53:54 PM »
As I don't use CloudFlare:

Code: [Select]
RemoteIPHeader X-Forwarded-For
RemoteIPInternalProxy xxx.xxx.xxx.xxx

and worked!

thank you @cyberspace