Control Web Panel
Developers => I can build it => Topic started by: ejsolutions 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)
<?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
<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.
-
Updated module, with column headers and improved the output.
I'm sure developers could do a neater job of this. ???
<?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> CPU Child Slot";
echo " IP Type ";
echo "Domain 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.
-
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>
-
Brilliant! Many thanks.
-
Warning: it looks as though posting this is against the rules!
-
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.
-
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
-
This would be better and show more info:
<?php
// Apache Status - Accesses v0.4
$url = "http://localhost/server-status";
$ch_session = curl_init();
curl_setopt($ch_session, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch_session, CURLOPT_URL, $url);
$result_url = curl_exec($ch_session);
echo $result_url;
?>