Wednesday, October 23, 2019

Network Load Monitor Commad in EC2 Instance



Object :

To monitor the Instance In Out Network traffic in the EC2 instances.



Step:1
 
           First you need to install the "nload" RPM in your terminal using the below command.

sudo yum install nload

It will start the installation When you accept Yes.

Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main                                                | 2.1 kB     00:00
amzn-updates                                             | 2.5 kB     00:00
epel/x86_64/metalink                                     | 7.8 kB     00:00
1065 packages excluded due to repository priority protections
Resolving Dependencies
--> Running transaction check
---> Package nload.x86_64 0:0.7.4-1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package         Arch             Version                  Repository      Size
================================================================================
Installing:
 nload           x86_64           0.7.4-1.el6              epel            63 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 63 k
Installed size: 155 k
Is this ok [y/d/N]: y
Downloading packages:
nload-0.7.4-1.el6.x86_64.rpm                               |  63 kB   00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : nload-0.7.4-1.el6.x86_64                                     1/1
  Verifying  : nload-0.7.4-1.el6.x86_64                                     1/1

Installed:
  nload.x86_64 0:0.7.4-1.el6

Complete!


Command To Monitor the Network Load.

nload -U m (This command will show you in MB)
nload -U k (This command will show you in KB)
nload -U G (This command will show you in GB)

As per your Use case you might select the command.Thanks !!!

Tuesday, July 16, 2019

Build Your Apache logs by Unified Log rotate cycle In EC2 Instances.



Build Your Apache logs by Unified Log rotate cycle In EC2 Instances.

Log rotate by default configured in one of the EC2 instances for apache web server's access_log & error_log

Step:1

The below configuration was Actual entry (/etc/httpd/conf.d/example.com.conf)


<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/vhosts/example.com/httpdocs/public_html/public

    #CustomLog /var/www/vhosts/example.com/statistics/logs/access_log combined
    #CustomLog "|/usr/sbin/rotatelogs /var/www/vhosts/example.com/statistics/logs/access_log.%Y.%m.%d 86400" combined
    CustomLog "|/usr/sbin/rotatelogs /var/www/vhosts/example.com/statistics/logs/access_%d.%m.%Y.log 86400" combined
    ErrorLog  /var/www/vhosts/example.com/statistics/logs/error_log

    <Directory /var/www/vhosts/example.com/httpdocs/public_html/public>
        Options -Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:443>
        ServerName example.com
        ServerAlias www.example.com
        DocumentRoot /var/www/vhosts/example.com/httpdocs/public_html/public
        CustomLog "|/usr/sbin/rotatelogs /var/www/vhosts/example.com/statistics/logs/access_ssl_%d.%m.%Y.log 86400" combined
        ErrorLog  /var/www/vhosts/example.com/statistics/logs/error_ssl_log

        SSLEngine ON
        SSLCACertificateFile /etc/pki/tls/certs/example.com-ca.crt
        SSLCertificateKeyFile /etc/pki/tls/private/example.com.key
        SSLCertificateFile /etc/pki/tls/certs/example.com.crt


    <Directory /var/www/vhosts/example.com/httpdocs/public_html/public>
        Options -Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

Step:2
The entry you might rotate every 7 days based on your requirement you will have to change accordingly.

This entry has to be done in the file path

File: /etc/logrotate.d/vhostlogs

##########################################################################################
/var/www/vhosts/example.com/statistics/logs/*.log {
    daily
    rotate 2
    missingok
    notifempty
    nocreate
    compress
    postrotate
           find /var/www/vhosts/example.com/statistics/logs/ -name "*.gz" -mtime +7 -delete
    endscript
}
###########################################################################################

That's it you have done the Log rotate entry for Apache access logs!!!