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

7 minute read
1

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 and SAR monitoring tools to collect granular data about process usage.

Short description

ATOP and SAR monitoring tools aren't configured on standard Amazon Machine Images (AMIs). However, you can install the monitoring tools on distributions based on Amazon Linux, RHEL, CentOS, SUSE Linux Enterprise Server (SLES), or Ubuntu Linux.

By default, ATOP and SAR monitoring tools collect metrics in 10-minute intervals and retain history for 30 days. To collect more granular data, you can reconfigure the collection time to 1-minute intervals.

Resolution

Install ATOP and SAR monitoring based on the operating system (OS) that your distribution runs.

AL2023

Amazon Linux 2023 (AL2023) includes the sysstat package by default. If your system doesn't have the sysstat package, then complete the following steps:

  1. To install the monitoring tools, run the following command:

    sudo yum -y install sysstat atop
  2. To change the log collection interval, run the following commands:

    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. To activate and restart services, run the following commands:

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

AL2

To install the ATOP and SAR monitoring tools on Amazon Linux 2 (AL2), complete the following steps:

  1. To install the Extra Packages for Linux (EPEL) release package for RHEL 7, run the following command:

    sudo amazon-linux-extras install epel
  2. To install the monitoring tools, run the following command:

    sudo yum -y install sysstat atop --enablerepo=epel
  3. To change the log collection interval, run the following commands:

    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. To activate and restart services, run the following commands:

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

Amazon Linux AMI

To install the ATOP and SAR monitoring tools, complete the following steps:

  1. To install the monitoring tools and change the log collection interval, run the following commands:
    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
    Note: Amazon Linux has the EPEL repository installed by default.
  2. To activate and restart services, run the following commands:
    for _service in atop crond sysstat; do sudo chkconfig ${_service} on; sudo service ${_service} start; done

RHEL and CentOS

Note: The following configuration steps are the same for each major release of RHEL and CentOS.

To install the ATOP and SAR monitoring tools, complete the following steps:

  1. To install the EPEL release package, run the following command based on your RHEL or CentOS version:
    RHEL 8, RHEL 9, CentOS 8, and CentOS Stream 9:

    source /etc/os-release
    sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-${VERSION_ID%.*}.noarch.rpm -y

    RHEL 7 and CentOS 7:

    sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

    RHEL 6 and CentOS 6:

    sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
  2. To install the monitoring tools, run the following command:

    sudo dnf -y install sysstat atop --enablerepo=epel
  3. To change the log collection interval, run the following commands based on your RHEL or CentOS version:
    RHEL 8, RHEL 9, CentOS 8, and CentOS Stream 9:

    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

    RHEL 7 and CentOS 7:

    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

    RHEL 6 and CentOS 6:

    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. To activate and restart services, run the following commands based on your RHEL or CentOS version:
    RHEL 8, RHEL 9, CentOS 8, and CentOS Stream 9:

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

    RHEL 7 and CentOS 7:

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

    RHEL 6 and CentOS 6:

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

Ubuntu

To install the ATOP and SAR monitoring tools, complete the following steps:

  1. To install the monitoring tools, run the following command:

    sudo apt-get update
    sudo apt-get -y install atop sysstat
  2. To change the log collection interval, run the following commands based on your Ubuntu version:
    Ubuntu 24.04 and Ubuntu 22.04:

    sudo sed -i 's/^LOGINTERVAL=600.*/LOGINTERVAL=60/' /etc/default/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 bash -c "echo 'SA1_OPTIONS=\"-S XALL\"' >> /etc/default/sysstat"
    sudo sed -i 's|ENABLED="false"|ENABLED="true"|' /etc/default/sysstat

    Ubuntu 20.04:

    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"
    sudo sed -i 's|ENABLED="false"|ENABLED="true"|' /etc/default/sysstat

    Ubuntu 18.04 and Ubuntu 16.04:

    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. To activate and restart services, run the following commands based on your Ubuntu version:
    Ubuntu 24.04 and Ubuntu 22.04:

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

    Ubuntu 20.04:

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

    Ubuntu 18.04 and Ubuntu 16.04:

    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

SLES and SLES for SAP

To install the ATOP and SAR monitoring tools, complete the following steps:

  1. To activate PackageHub, run the following command based on your SLES version.
    SLES15:

    source /etc/os-release
    sudo SUSEConnect -p PackageHub/$VERSION_ID/x86_64
    sudo zypper ref -s

    SLES12:

    source /etc/os-release
    sudo SUSEConnect -p PackageHub/$VERSION_ID/x86_64
    sudo zypper addrepo https://download.opensuse.org/repositories/server:monitoring/SLE_12_SP5/server:monitoring.repo
    sudo zypper ref -s

    Note: For SLES12, you also add the OpenSUSE server monitoring repository.

  2. To install SAR and ATOP, run the following command:

    sudo zypper in sysstat atop atop-daemon
  3. To change the log collection interval, run the following commands based on your SLES version:
    SLES15:

    sudo sed -i 's/^LOGINTERVAL=600.*/LOGINTERVAL=60/' /etc/default/atop
    sudo sed -i -e 's|*/10|*/1|' -e 's|every 10 minutes|every 1 minute|' /etc/sysstat/sysstat.cron
    sudo sed -i 's/^SADC_OPTIONS=.*/SADC_OPTIONS=" -S XALL"/' /etc/sysstat/sysstat

    SLES12:

    sudo sed -i 's/^LOGINTERVAL=600.*/LOGINTERVAL=60/' /usr/share/atop/atop.daily
    sudo sed -i -e 's|*/10|*/1|' -e 's|every 10 minutes|every 1 minute|' /etc/sysstat/sysstat.cron
    sudo sed -i 's/^SADC_OPTIONS=.*/SADC_OPTIONS=" -S XALL"/' /etc/sysstat/sysstat
  4. To activate and restart services, run the following commands:

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

Related information

Add repositories on an AL2 instance

Amazon Linux 2 FAQs

Extra Packages for Enterprise Linux (EPEL) on the Fedora Project website

AWS OFFICIAL
AWS OFFICIALUpdated 17 days ago
3 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 2 years ago

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

profile pictureAWS
MODERATOR
replied 2 years ago

Where multiple commands are shown per single step it is all shown on one line instead of new lines. This result in commands failing with invalid command when copy and paste is done as next command begins with no space. Maybe consider using ";" in between, or do over multiple lines as intended.

Example where next command "sudo mkdir" simply begins under RHEL steps:

sudo sed -i 's/^LOGINTERVAL=600.*/LOGINTERVAL=60/' /etc/sysconfig/atopsudo mkdir

AWS
replied 9 months ago