Apache Server Performance Monitoring

Source: Internet
Author: User
Tags apache log file apache log

Apache server performance monitoring

1, using the self-mod_status module monitoring

1) Load mod_status.so module

Open LoadModule status_module modules/mod_status.so in httpd.conf

2) Modify the httpd.conf profile Add (delete Note #) as follows:

<Location/server-status>
SetHandler Server-status
Order Deny,allow
Deny from all
Allow from all
</Location>
Extendedstatus on

The name <location/server-status>:server-status can be modified.
Deny from: Represents the forbidden access address, nothing means no forbidden address.
Allow from: Represents the allowed address access; All means that all addresses are accessible.
Extendedstatus on: Displays additional information, including the response information for the sub-httpd process.
Order Deny,allow: Priority order, deny---deny, allow--allowed.

Access in the browser after restarting the Apache server: Http://serverip/server-status or Http://serverip/server-status?refresh=N (refresh time) or/HTTP// Serverip/server-status/auto (Simple status table)

Key indicators:

    • Total accesses: The number of online received by Apache so far
    • Total Kbytes: Number of bytes Received
    • Uptime: Total time the server is running (in s)
    • Cpuload: CPU currently consumed by the Apache server
    • Reqpersec: Average number of requests per second, that is, hit HPS
    • Bytespersec: Average number of bytes sent per second
    • Bytesperreq: Average number of bytes sent per request
    • Busyworkers: Number of threads serving, working number
    • Idleworkers: Number of idle threads

2, using the self-mod_info module monitoring

Relative to the server state information provided by the Mod_status module, Mod_info primarily provides configuration information for the server and cannot be dynamically updated

Modify the Httpd.conf profile Add (delete Note #) as follows:

<Location/server-info>
SetHandler Server-info
Order Deny,allow
Deny from all
Allow from all
</Location>

After restarting the Apache server in the browser access: Http://serverip/server-info, you can use the following query parameters:

Config display Apache configuration file

?<module-name> Display module Related information

List shows all the modules in use

? server displays basic server information

Hooks show the list of hooks each module belongs to

In addition, the Mod_info module provides addmoduleinfo instructions to add additional custom information to the modules displayed by the Server-info.

Apache's own mod_status and mod_info modules provide poor monitoring capabilities and may also pose security concerns, so it is generally recommended to remove these module features and use third-party tools for monitoring.

3, third-party tool monitoring

Zabbix: An enterprise-class solution for Distributed system monitoring and network monitoring capabilities based on PHP scripts, as well as monitoring Apache servers.

Nagios: A monitoring system that monitors system health and network information, and provides web-based administration pages like Zabbix

4. LR Monitoring Apache Server

to turn on the Mod_status module function, locate the Apache Resource Graph in the LR controller and right-click to add a measure, such as:

Add the Apache server IP address, select the system platform, and add the counters that need to be monitored for monitoring.

There may be an issue where the counters provided by the Apache version are inconsistent with the LR default counters, which need to be resolved by modifying the Apache.cfg configuration file under \dat\monitors in the LR installation directory.

5. Using apachetop tools to monitor Apache logs

Apachetop displays the statistics of Apache's access log in real-time, like the top command, and after installing the Apachetop tool, run the following command:

Apachetop-f/usr/local/apache2/logs/access_log (Apache log file directory)

6. Other Practical monitoring commands

1) Use PS to see the number of httpd processes

PS aux | grep httpd | Wc-l

2) Use Netstat to see the current number of connections

Netstat-ant | grep ": 80" | Wc-l

3) Real-time detection of httpd connections

Watch-n 1-d "Pgrep httpd | Wc-l "

4) Calculate the average number of memory httpd processes occupy

PS aux|grep-v Grep|awk '/httpd/{sum+=$6}; End{print sum/n} '

5) View the number of concurrent requests and TCP connection status of Apache

Netstat-n | awk '/^tcp/{++s[$NF]} END {for (a in S) print A, s[a]} '

Examples of returned results:
Last_ack 5
SYN_RECV 30
Established 1597
Fin_wait1 51
Fin_wait2 504
Time_wait 1057

• The SYN_RECV indicates the number of requests that are waiting to be processed; established indicates normal data transfer status; Time_wait indicates the number of requests that have been processed, waiting for the end of the timeout.

Status: Description
closed: No connection is active
Listen: The server is waiting to enter the call
SYN_RECV: A connection request has arrived, waiting for confirmation
syn_sent: Application has started, open a connection
established: Normal data transfer status
fin_wait1: Application says it's done
Fin_wait2: The other side has agreed to release
itmed_wait: Waiting for all packets to die
closing: Both sides try to close simultaneously
time_wait: The other side has initialized a release
Last_ack: Waiting for all packets to die

Apache Server Performance Monitoring

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.