Bash script to view Apache RAM consumption statistics

 All of us who manage web servers are always after some new tool or tweak, either to have more information about our hardware resources or to reduce consumption 😀

Here I will leave you a script that they put a while ago in Crystalb precisely for thisTo measure Apache's memory consumption, I leave you an example of the data it provides:

=========================================
Apache processes and memory usage.
=========================================
Total installed memory: 4.09Gb
Availiable memory: 3.31Gb
Free percentile: 80.00%
Status bar:
| +++++++++ —————————– |
=========================================
Current Usage
=========================================
Current processes: 28
Average memory: 76Mb
Maximum memory: 80Mb
Overall memory: 1.99Gb
=========================================
Projected usage
=========================================
Concurrent best: 446 more connection (s)
Concurrent worst: 424 more connection (s)
=========================================

As you can see, it tells us the number of connections to Apache that are in progress, amount of memory occupied, available memory, etc 🙂

Download the .sh Script

Quite useful or not?

Even with just a few more minutes we could make this information reach us by email, that is, we would first put in crontab that every X time (1 hour for example) make this report, print the report in a file (stat.info) and then send us the file by email using some method that we have explained here before.

It would be:

1. Put in crontab run every hour
2. What will be executed would be:

/root/./script.sh >> /root/stat.info && mail -s "Server's Stats" kzkggaara@mail.com < /root/stat.info

DO NOT forget to give execute permissions (chmod + x apache-stats.sh) so they can run it

And voila, it should work without problems 😀
Well nothing ... another tip that I hope will be useful 😉

regards


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Algave said

    This script can be very useful to me, thanks for sharing it 🙂

  2.   RAW-Basic said

    OT: Sandy, you can stop crying in the corners that no one was commenting on about the post .. xD

    Thanks for sharing it, it's good for me to pass them on to some people that will surely suit them like a glove ..

  3.   David valverde said

    We have been very excited to find this article, it has been a long time since we wrote it and we expected some more enthusiasm from Cristalab readers. Maybe it wasn't the right place to post it 🙂

    If you are interested in articles of this type, do not hesitate to say so and we will be doing tutorials and utilities in bash.

    Greetings from Grafitto!

    1.    KZKG ^ Gaara said

      Thank you very much for reading us, for commenting and for sharing 🙂
      If you want to make more scripts to automate tasks, for 'something' that you think may be interesting or useful... do not hesitate to contact me (kzkggaara[at]desdelinux[dot]net).

      Thanks once again for your work

      regards

      1.    David valverde said

        I am doing a small job that requires connection to the database from bash and something else. It's simple, but I'll put it on a tutorial plan, let's see if you like it.

        Thanks for the welcome!

  4.   Yagi said

    hi, maybe the script is not available ?? I couldn't download it
    If you can check it out, it would be great, I'm interested
    greetings, thanks for sharing