How do I configure the ATOP Monitoring and SAR monitoring tools for my EC2 instance running Amazon Linux, RHEL, CentOS, or Ubuntu?

6 minute read
0

I have an Amazon Elastic Compute Cloud (Amazon EC2) instance that runs Amazon Linux, Red Hat Enterprise Linux (RHEL), CentOS, or Ubuntu. I want to configure the ATOP Monitoring and AWS Serverless Application Repository monitoring tools to collect granular data about process utilization.

Short description

ATOP Monitoring and AWS Serverless Application Repository monitoring tools aren't configured on standard Amazon Machine Images (AMIs). You can install these monitoring tools on Amazon Linux, RHEL, CentOS, or Ubuntu Linux-based distributions. Turning on ATOP Monitoring and SAR monitoring provides a granular view into the instance's process utilization with a 30-day retention history.

By default, ATOP Monitoring and SAR monitoring tools collect metrics in 10-minutes intervals. You can reconfigure the interval from the default value to 1 minute intervals to collect more granular data.

Resolution

Amazon Linux 2023

  1. Install the monitoring tools:

    $ sudo yum -y install sysstat atop
  2. Change the log collection interval:

    $ sudo sed -i 's/^LOGINTERVAL=600.*/LOGINTERVAL=60/' /etc/sysconfig/atop
    $ sudo mkdir -v /etc/systemd/system/sysstat-collect.timer.d/
    $ sudo bash -c "sed -e 's|every 10 minutes|every 1 minute|g' -e '/^OnCalendar=/ s|/10$|/1|' /usr/lib/systemd/system/sysstat-collect.timer > /etc/systemd/system/sysstat-collect.timer.d/override.conf"
    $ sudo sed -i 's|^SADC_OPTIONS=.*|SADC_OPTIONS=" -S XALL"|' /etc/sysconfig/sysstat
  3. Activate and restart services:

    $ sudo systemctl enable atop.service sysstat-collect.timer sysstat.service
    $ sudo systemctl restart atop.service sysstat-collect.timer sysstat.service

Amazon Linux 2

  1. Install the Extra Packages for Enterprise Linux (EPEL) release package for RHEL 7 using the amazon-linux-extras command:

    sudo amazon-linux-extras install epel
  2. Install the monitoring tools:

    sudo yum -y install sysstat atop --enablerepo=epel
  3. Change the log collection interval:

    sudo sed -i 's/^LOGINTERVAL=600.*/LOGINTERVAL=60/' /etc/sysconfig/atop
    sudo sed -i -e 's|*/10|*/1|' -e 's|every 10 minutes|every 1 minute|' /etc/cron.d/sysstat
  4. Activate and restart services:

    sudo systemctl enable atop.service crond.service sysstat.service
    sudo systemctl restart atop.service crond.service sysstat.service

Amazon Linux AMI

  1. Install the monitoring tools.

    Note: Amazon Linux already has the EPEL repository installed.

    sudo yum -y install sysstat atop --enablerepo=epel
    sudo sed -i 's/^INTERVAL=600.*/INTERVAL=60/' /etc/sysconfig/atop
    sudo sed -i -e 's|*/10|*/1|' -e 's|every 10 minutes|every 1 minute|' /etc/cron.d/sysstat
  2. Activate and restart services:

    for _service in atop crond sysstat; do sudo chkconfig ${_service} on; sudo service ${_service} start; done

RHEL and CentOS

These configuration steps are the same for each major release of RHEL and CentOS.

RHEL 9

  1. Install the EPEL release package for RHEL 9, and then activate the CodeReady Linux Builder repository:

    $ sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
    $ sudo dnf config-manager --set-enabled codeready-builder-for-rhel-9-rhui-rpms
  2. Install the monitoring tools:

    $ sudo dnf -y install sysstat atop --enablerepo=epel
  3. Change the log collection interval:

    $sudo sed -i 's/^LOGINTERVAL=600.*/LOGINTERVAL=60/' /etc/sysconfig/atop
    $sudo mkdir -v /etc/systemd/system/sysstat-collect.timer.d/
    $sudo bash -c "sed -e 's|every 10 minutes|every 1 minute|g' -e '/^OnCalendar=/ s|/10$|/1|' /usr/lib/systemd/system/sysstat-collect.timer > /etc/systemd/system/sysstat-collect.timer.d/override.conf"
    $sudo sed -i 's|^SADC_OPTIONS=.*|SADC_OPTIONS=" -S XALL"|' /etc/sysconfig/sysstat
  4. Activate and restart services

    $ sudo systemctl enable atop.service crond.service sysstat.service
    $ sudo systemctl restart atop.service crond.service sysstat.service

RHEL 8 and CentOS 8:

  1. Install the EPEL release package for RHEL 8:

    sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y
  2. Install the monitoring tools:

    sudo dnf -y install sysstat atop --enablerepo=epel
  3. Change the log collection interval:

    sudo sed -i 's/^LOGINTERVAL=600.*/LOGINTERVAL=60/' /etc/sysconfig/atop
    sudo mkdir -v /etc/systemd/system/sysstat-collect.timer.d/
    sudo bash -c "sed -e 's|every 10 minutes|every 1 minute|g' -e '/^OnCalendar=/ s|/10$|/1|' /usr/lib/systemd/system/sysstat-collect.timer > /etc/systemd/system/sysstat-collect.timer.d/override.conf"
    sudo sed -i 's|^SADC_OPTIONS=.*|SADC_OPTIONS=" -S XALL"|' /etc/sysconfig/sysstat
  4. Activate and restart services:

    sudo systemctl enable atop.service crond.service sysstat.service
    sudo systemctl restart atop.service crond.service sysstat.service

RHEL 7 and CentOS 7:

  1. Install the EPEL release package for RHEL 7:

    sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
  2. Install the monitoring tools:

    sudo yum -y install sysstat atop --enablerepo=epel
  3. Change the log collection interval:

    sudo sed -i 's/^LOGINTERVAL=600.*/LOGINTERVAL=60/' /etc/sysconfig/atop
    sudo sed -i -e 's|*/10|*/1|' -e 's|every 10 minutes|every 1 minute|' /etc/cron.d/sysstat
  4. Activate and restart services:

    sudo systemctl enable atop.service crond.service sysstat.service
    sudo systemctl restart atop.service crond.service sysstat.service

RHEL 6 and CentOS 6:

  1. Install the EPEL release package for RHEL 6:

    sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
  2. Install the monitoring tools:

    sudo yum -y install sysstat atop --enablerepo=epel
  3. Change the log collection interval:

    sudo sed -i 's/^INTERVAL=600.*/INTERVAL=60/' /etc/sysconfig/atop
    sudo sed -i -e 's|*/10|*/1|' -e 's|every 10 minutes|every 1 minute|' /etc/cron.d/sysstat
  4. Activate and restart services:

    for _service in atop crond sysstat; do sudo chkconfig ${_service} on; sudo service ${_service} start; done

Ubuntu

Ubuntu 22.04 and 20.04:

  1. Install the monitoring tools:

    sudo apt-get update
    sudo apt-get -y install atop sysstat
  2. Change the log collection interval and configure sysstat to report disk and inodes usage by adding -S XALL in the configuration file:

    sudo sed -i 's/^LOGINTERVAL=600.*/LOGINTERVAL=60/' /usr/share/atop/atop.daily
    sudo sed -i -e 's|5-55/10|*/1|' -e 's|every 10 minutes|every 1 minute|' -e 's|debian-sa1|debian-sa1 -S XALL|g' /etc/cron.d/sysstat
    sudo bash -c "echo 'SA1_OPTIONS=\"-S XALL\"' >> /etc/default/sysstat"
  3. Activate and restart services:

    sudo sed -i 's|ENABLED="false"|ENABLED="true"|' /etc/default/sysstat
    sudo systemctl enable atop.service cron.service sysstat.service
    sudo systemctl restart atop.service cron.service sysstat.service

Ubuntu 18.04:

  1. Install the monitoring tools:

    sudo apt-get update
    sudo apt-get -y install atop sysstat
  2. Change the log collection interval and configure sysstat to report disk and inodes usage by adding -S XALL in the configuration file:

    sudo sed -i 's/^INTERVAL=600.*/INTERVAL=60/' /usr/share/atop/atop.daily
    sudo sed -i -e 's|5-55/10|*/1|' -e 's|every 10 minutes|every 1 minute|' -e 's|debian-sa1|debian-sa1 -S XALL|g' /etc/cron.d/sysstat
    sudo bash -c "echo 'SA1_OPTIONS=\"-S XALL\"' >> /etc/default/sysstat"
  3. Activate and restart services:

    sudo sed -i 's|ENABLED="false"|ENABLED="true"|' /etc/default/sysstat
    sudo systemctl enable atop.service cron.service sysstat.service
    sudo systemctl restart atop.service cron.service sysstat.service

Ubuntu 16.04:

  1. Install the monitoring tools:

    sudo apt-get update
    sudo apt-get -y install atop sysstat
  2. Change the log collection interval and configure sysstat to report disk and inodes usage. Add -S XALL in the configuration file:

    sudo sed -i 's/^INTERVAL=600.*/INTERVAL=60/' /etc/default/atop
    sudo sed -i -e 's|5-55/10|*/1|' -e 's|every 10 minutes|every 1 minute|' -e 's|debian-sa1|debian-sa1 -S XALL|g' /etc/cron.d/sysstat
    sudo bash -c "echo 'SA1_OPTIONS=\"-S XALL\"' >> /etc/default/sysstat"
  3. Activate and restart services:

    sudo sed -i 's|ENABLED="false"|ENABLED="true"|' /etc/default/sysstat
    sudo systemctl enable atop.service cron.service sysstat.service
    sudo systemctl restart atop.service cron.service sysstat.service

Related information

Adding repositories on an Amazon Linux instance

Extras library (Amazon Linux 2)

Amazon Linux 2 FAQs

EPEL website

systemd.timer -- Timer unit configuration on the FreeDesktop website

AWS OFFICIAL
AWS OFFICIALUpdated 6 months ago
2 Comments

$ sudo systemctl restart atop.service crond.service sysstat.service Failed to get D-Bus connection: Operation not permitted Can't restart Amazon Linux 2 Any ideas?

replied 5 months ago

Thank you for your comment. We'll review and update the Knowledge Center article as needed.

profile pictureAWS
MODERATOR
replied 5 months ago