Skip to main content

Monitoring Server Status

1. Enabling Status Module

Directive Description Default Notes
ExtendedStatus Enables extended status information Off Required for detailed status reporting
StatusIndex Enables status page display Off Must be enabled to view server status

Example: Enable Status Module

<IfModule mod_status.c>
    ExtendedStatus On
    <Location /server-status>
        SetHandler server-status
        Require host localhost
    </Location>
</IfModule>
Note: The /server-status endpoint is accessible only from localhost by default for security reasons.

2. Configuring Server Status Page

Directive Description Default Notes
ServerStatus Enables the server status page Off Must be enabled to view status information
ServerTokens Controls the level of information provided in server headers Full Can be set to Full, Major, Minor, Min, or Off
ServerSignature Controls whether the server name and version are displayed in error messages On Set to Off to hide server details

Example: Enabling Server Status Page

<IfModule mod_status.c>
    ExtendedStatus On
    <Location /server-status>
        SetHandler server-status
        Require host example.com
    </Location>
</IfModule>
Note: The ExtendedStatus directive must be enabled to get detailed per-request statistics.
Warning: Exposing the server status page publicly can reveal sensitive information about your server configuration and performance. Always restrict access to trusted hosts.

3. Accessing Status Page

Example: Enabling mod_status

<IfModule mod_status.c>
    ExtendedStatus On
    <Location /server-status>
        SetHandler server-status
        Require ip 127.0.0.1
    </Location>
</IfModule>
Directive Description Default
ExtendedStatus Enables extended status information Off
SetHandler Assigns the server-status handler None
Require ip Restricts access to specific IP addresses None
Note: The status page is only accessible when mod_status is loaded and properly configured.
Warning: Exposing the status page to external IPs can reveal sensitive server information. Always restrict access using Require directives.

4. Monitoring Active Connections

Directive Description Default Notes
ServerLimit Sets the maximum number of server processes that can be configured. 256 Must be set before MaxRequestWorkers
MaxRequestWorkers Maximum number of connections that can be handled simultaneously. 256 Also known as MaxClients
KeepAliveTimeout Number of seconds the server will wait for a subsequent request on a persistent connection. 5 Applies to HTTP/1.1 persistent connections
MaxKeepAliveRequests Maximum number of requests allowed per persistent connection. 100 Set to 0 for unlimited requests

Example: Configuring Active Connection Limits

<IfModule mod_reqtimeout.c>
    ReqTimeoutSection 10
</IfModule>

<IfModule mod_http2.c>
    H2MaxWorkers 100
</IfModule>

ServerLimit 512
MaxRequestWorkers 512
KeepAliveTimeout 10
MaxKeepAliveRequests 50
Note: The ServerLimit directive must be set before any directives that depend on it, such as MaxRequestWorkers. These settings affect server performance and resource usage.

Active Connection Monitoring Summary

  • ServerLimit controls the maximum server processes
  • MaxRequestWorkers sets the max concurrent connections
  • KeepAliveTimeout defines how long persistent connections last
  • MaxKeepAliveRequests limits requests per persistent connection

5. Using Info Module

Directive Description Default Notes
ModInfo Enables the mod_info module Off Must be enabled to access server info
InfoPath URL path for the info page /server-info Can be changed to avoid conflicts

Example: Enable mod_info and set InfoPath

<IfModule mod_info.c>
    ModInfo On
    InfoPath /my-server-info
</IfModule>
Note: The mod_info module provides detailed server information including loaded modules, configuration directives, and runtime statistics. It's primarily intended for debugging and monitoring purposes.
Warning: The server-info page exposes sensitive configuration details and should not be accessible in production environments without proper authentication.
Information Type Description Access Control
Loaded Modules List of all loaded Apache modules Visible to all users with access
Server Configuration Active server directives and settings Visible to all users with access
Runtime Statistics Current connections, request counts, etc. Visible to all users with access

Key Features of mod_info

  • Provides detailed server configuration overview
  • Displays loaded modules and their status
  • Shows runtime statistics for performance monitoring
  • Can be restricted to specific IP addresses or users

6. Analyzing Access and Error Logs

Log Type File Location Description Example Entry
Access Log /var/log/apache2/access.log Records every request made to the server 192.168.1.1 - - [10/Oct/2024:13:55:36 +0000] "GET /index.html HTTP/1.1" 200 2326
Error Log /var/log/apache2/error.log Records server errors, warnings, and other issues [Wed Oct 10 13:55:36.123456 2024] [core:error] [pid 12345] AH00025: Error retrieving file

Example: Log Rotation Configuration

# /etc/logrotate.d/apache2
/var/log/apache2/*.log {
    daily
    missingok
    rotate 52
    compress
    delaycompress
    notifempty
    create 640 root adm
}
Note: Log files can grow very large. Regular rotation is recommended to manage disk space and maintain performance.

Key Log Fields

  • IP Address: Client's IP address
  • Timestamp: Date and time of the request
  • Request: HTTP method, path, and protocol
  • Status Code: Response status (e.g., 200, 404)
  • Bytes Sent: Size of the response

7. Monitoring System Resources

Resource Description Monitoring Method Notes
CPU Usage Percentage of CPU time used by the server process top, htop, ps aux | grep httpd High CPU usage may indicate performance bottlenecks or misconfigurations
Memory Usage Amount of RAM consumed by the Apache process free -h, ps aux | grep httpd Excessive memory usage can lead to swapping and degraded performance
Disk I/O Read/write operations on disk by the server iostat, iotop High I/O can indicate slow disk or inefficient file handling
Network Usage Data transfer in and out of the server iftop, ss -tuln, netstat Unusual network patterns may suggest DDoS or misconfigured proxies

Example: Check Apache Process Memory Usage

ps aux | grep httpd

Example: Monitor CPU Usage Over Time

top -p $(pgrep httpd)
Note: Use htop for a more interactive and user-friendly view of system resources.
Warning: Monitoring tools like htop or iostat may require root privileges to show accurate data.

8. Using Apache Bench

Apache Bench (ab) is a command-line tool for benchmarking Apache HTTP Server and other web servers. It sends multiple HTTP requests to a specified URL and measures server performance.

Option Values Description
-n 1000 Total number of requests to send
-c 10 Number of concurrent requests
-t 30 Maximum time in seconds to spend sending requests
-p post-data.txt File containing data to POST
-T application/json Content-type header for POST data
-v 3 Verbosity level (0-4)

Example: Basic Apache Bench Test

ab -n 1000 -c 10 http://example.com/

Example: POST Request with Data

ab -n 100 -c 5 -p post-data.json -T "application/json" http://example.com/api
Note: Apache Bench is designed for simple benchmarking and does not support HTTPS or complex authentication. For more advanced load testing, consider using tools like JMeter or Locust.

9. Configuring Load Test Parameters

Parameter Description Default Value Notes
LoadFactor Defines the load factor for the server 1.0 Used in calculating server load for performance tuning
MaxRequestsPerChild Maximum number of requests a child process will handle 0 (unlimited) Set to prevent memory leaks in long-running processes
ServerLimit Maximum number of server processes allowed 256 Must be set before starting the server
MaxRequestWorkers Maximum number of worker processes that can handle requests 150 Controls concurrent request handling capacity
ThreadsPerChild Number of threads per child process in the thread-based MPM 64 Only relevant for thread-based MPMs like worker or event

Example: Setting Load Test Parameters in httpd.conf

<IfModule mpm_prefork_module>
    ServerLimit 256
    MaxRequestWorkers 150
    MaxRequestsPerChild 10000
</IfModule>

<IfModule mpm_worker_module>
    ServerLimit 256
    MaxRequestWorkers 150
    ThreadsPerChild 64
</IfModule>
Note: Adjust MaxRequestsPerChild to prevent memory leaks in long-running processes. Set ServerLimit before starting the server to avoid runtime errors.

10. Using External Monitoring Tools

Tool Description Integration Method Supported Metrics
Nagios Open-source monitoring system with plugins for Apache check_http plugin Response time, status code, content checks
Zabbix Enterprise-grade monitoring with web scenario support Web scenario, HTTP agent, custom scripts Response time, error rate, uptime
Prometheus Time-series database with Grafana integration Apache exporter, node_exporter Request count, response time, memory usage
Datadog Cloud-based monitoring and analytics platform APM, logs, metrics Performance, errors, throughput
New Relic Full-stack APM with infrastructure monitoring Browser, server agents, custom integrations Transaction time, error rate, user experience

Example: Zabbix Web Scenario Setup

zabbix_agentd.conf:
UserParameter=apache.status[*],curl -s -o /tmp/apache_status.txt http://$1/server-status?auto
Note: Ensure proper permissions and security settings when integrating external tools with Apache.

Key Integration Points

  • Use mod_status for status page access
  • Implement authentication for sensitive endpoints
  • Set up proper alerting thresholds based on performance data

11. Setting Up Real-Time Metrics

Example: Enable mod_status for real-time metrics

<Location /server-status>
    SetHandler server-status
    Require ip 127.0.0.1
</Location>
Directive Description Default Notes
SetHandler Assigns the server-status handler to a location None Required for status page access
Require Controls access to the status page None Security best practice to restrict access
Note: The /server-status endpoint provides real-time server metrics including requests per second, bytes served, and active connections.
Warning: Exposing the server status page to external IPs can reveal sensitive system information. Always restrict access using Require.

Configuration Summary

  • Handler: server-status
  • Location: /server-status
  • Access Control: Requires IP restriction (e.g., Require ip 127.0.0.1)
  • Metrics Available: Requests per second, bytes served, active connections

12. Creating Performance Baselines

Example: Measuring baseline response times

ab -n 1000 -c 10 http://example.com/index.html
Metric Description Typical Range Notes
Requests per second Number of requests handled per second 100–5000+ Higher is better for performance
Time per request Average time to process a single request 10ms–500ms Lower is better for responsiveness
Connection times Time to establish a connection 1ms–50ms Can indicate network or server issues
Transfer rate Data transfer speed in bytes/sec 10KB/s–5MB/s+ Depends on content size and bandwidth
Note: Baseline metrics should be collected under typical load conditions to ensure accuracy.

Comparison: Tools for Performance Baseline Creation

  • ab (Apache Bench): Simple, built-in, good for basic load testing
  • JMeter: Feature-rich, supports complex scenarios and reporting
  • Locust: Python-based, scalable for large test scenarios
  • Gatling: High-performance, good for detailed analysis and reporting

Was this article helpful?