How To Check statistics of Apache Web Server (httpd) on CentOS/RHEL and Ubuntu
How To Check statistics of Apache Web Server (httpd) on CentOS/RHEL and Ubuntu
Apache is a world’s most popular, cross platform HTTP web server that is commonly used in Linux and Unix platforms to deploy and run web applications or websites. "uptime" is used to check the uptime of the Linux system, how long the system has been running. If you want to do so for the applications then how to do it, Let's find out:
The "ps" Command:
ps is a program which displays the currently-running processes. This utility shows information concerning a selection of the active processes running on a Linux system, we can use it with grep command to check Apache service uptime as follows. It shows when the parent process started and how long the service runs with the [DD:HH:MM:SS] format.On Ubuntu /Debian
The sample output below shows that the Apache2 service has been running for 10 hours, 30 minutes and 5 seconds considering the one run as root.
# ps -eo comm,etime,user | grep apache2
apache2 10:30:05 root
apache2 10:13:59 www-data
apache2 10:13:59 www-data
# ps -eo comm,etime,user | grep root | grep apache2
apache2 10:30:18 root
apache2 10:30:05 root
apache2 10:13:59 www-data
apache2 10:13:59 www-data
# ps -eo comm,etime,user | grep root | grep apache2
apache2 10:30:18 root
On CentOS/RHEL
The sample output below shows that Apache service has been running for 3 days, 5 hours, 53 minutes and 17 seconds considering the one run as root.
# ps -eo comm,etime,user | grep httpd
httpd 3-05:53:17 root
httpd 13:07:49 apache
httpd 13:07:49 apache
httpd 13:07:49 apache
httpd 13:07:49 apache
httpd 13:07:49 apache
httpd 09:19:24 apache
# ps -eo comm,etime,user | grep root | grep httpd
httpd 2-05:53:17 root
httpd 3-05:53:17 root
httpd 13:07:49 apache
httpd 13:07:49 apache
httpd 13:07:49 apache
httpd 13:07:49 apache
httpd 13:07:49 apache
httpd 09:19:24 apache
# ps -eo comm,etime,user | grep root | grep httpd
httpd 2-05:53:17 root
Here, the flags:
Systemctl Utility
Systemctl is a utility for controlling the systemd system and service manager. It is used it to start, restart, stop services.Check Apache Status Using Systemctl
[root@monitor ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since Tue 2019-12-10 06:50:28 GMT; 1 months 4 days ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 204063 ExecReload=/usr/sbin/httpd $OPTIONS -k graceful (code=exited, status=0/SUCCESS)
Main PID: 133437 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
Tasks: 11
Memory: 147.9M
CGroup: /system.slice/httpd.service
├─ 71444 /usr/sbin/httpd -DFOREGROUND
├─ 79161 /usr/sbin/httpd -DFOREGROUND
├─ 79168 /usr/sbin/httpd -DFOREGROUND
├─ 79190 /usr/sbin/httpd -DFOREGROUND
├─ 80381 /usr/sbin/httpd -DFOREGROUND
├─110758 /usr/sbin/httpd -DFOREGROUND
├─133437 /usr/sbin/httpd -DFOREGROUND
├─166961 /usr/sbin/httpd -DFOREGROUND
├─169099 /usr/sbin/httpd -DFOREGROUND
├─204097 /usr/sbin/httpd -DFOREGROUND
└─409824 /usr/sbin/httpd -DFOREGROUND
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since Tue 2019-12-10 06:50:28 GMT; 1 months 4 days ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 204063 ExecReload=/usr/sbin/httpd $OPTIONS -k graceful (code=exited, status=0/SUCCESS)
Main PID: 133437 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
Tasks: 11
Memory: 147.9M
CGroup: /system.slice/httpd.service
├─ 71444 /usr/sbin/httpd -DFOREGROUND
├─ 79161 /usr/sbin/httpd -DFOREGROUND
├─ 79168 /usr/sbin/httpd -DFOREGROUND
├─ 79190 /usr/sbin/httpd -DFOREGROUND
├─ 80381 /usr/sbin/httpd -DFOREGROUND
├─110758 /usr/sbin/httpd -DFOREGROUND
├─133437 /usr/sbin/httpd -DFOREGROUND
├─166961 /usr/sbin/httpd -DFOREGROUND
├─169099 /usr/sbin/httpd -DFOREGROUND
├─204097 /usr/sbin/httpd -DFOREGROUND
└─409824 /usr/sbin/httpd -DFOREGROUND
Apachectl Utility
Apachectl is a front-end control interface for Apache HyperText Transfer Protocol (HTTP) server. It is designed to assist the administrators to control the functioning of the Apache daemon. This method requires the mod_status module to be installed and enabled in the server to make it function as required. However, it is disabled by default and must be enabled to use the feature.The Apache “mod_status” module displays the following useful information about the Apache Web server.
- Apache Web server built & version information
- Web server last restart & uptime information
- Total number of incoming requests
- Idle workers
- Server load & Web server CPU usage
- Total traffic (Bandwidth usage)
- Average number of requests per second
- Average number of bytes per request
- and many more
Install and Enable Apache’s mod_status Module
By default, the Apache “mod_status” module is installed on Apache. But reports are disabled and you have to un-comment it to access it.RHEL/CentOS
To enable server-status component, create a file "/etc/httpd/conf.d/server-status.conf" and write following code into it.Save the file and close it. Then restart the web server.
# systemctl restart httpd
Debian/Ubuntu:
For Debian/Ubuntu systems, open /etc/apache2/mods-enabled/status.conf file and uncomment the below codes.
Save and close the file and restart the Apache web server service.
Use the below commands to restart the Apache (httpd) server :
Debian based systems.
#systemctl restart apache2.service
URL to access the server status webpage:http://Server IP/server-status
No comments