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 17712 times)

0 Members and 2 Guests 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.