Help EC2 CloudWatch and agent integration Linux agent deployment for EC2 instance

Linux agent installation

Compatability and prerequisites

Supported operating Systems

  • Our Linux monitoring agent supports the following Linux flavours – Debian, Ubuntu, CentOS, RedHat, Madriva, Fedora, and Suse.

Processor architecture

  • Linux - 32-bit and 64-bit architecture

Agent version

  • Linux agent: version 16.1.0 and above

Installation

Connect to your EC2 instance

First connect to your Linux instance using SSH. Specify the path of the .pem file (the private key you create when you launch the instance), the user name and the public DNS name of the instance. The user name can be different for various flavours of Linux, check with your AMI provider, before you proceed.

For example:

ssh -i /path/my-key-pair.pem ec2-user@ec2-198-51-100-1.compute-1.amazonaws.com

/path/my-key-pair .pem (path to the private key .pem file in your machine)

ec2-user (user name for the Linux instance)

ec2-198-51-100-1.compute-1.amazonaws.com  (public DNS for the instance)

Configure the Linux agent

Use the license key to authenticate the agent deployment. The agent will use this license key to associate the metrics gathered from the EC2 instance to your account. Know more.

One step installation

  • Execute the following command in the Linux terminal (independent of the OS architecture: 32-bit or 64-bit) to download and deploy the linux agent on your EC2 instance.
    sudo -E bash -c "$(curl -sL https://staticdownloads.site24x7.com/server/Site24x7InstallScript.sh)" readlink -i -key=<Device Key>

Linux agent installation steps

Now execute the following commands in the terminal

  1. [64-bit:] 
    sudo wget https://plus.site24x7.com//sagent//Site24x7_Linux_64bit.install
    sudo chmod 755 Site24x7_Linux_64bit.install
    sudo ./Site24x7_Linux_64bit.install -i -key=<DEVICE_KEY>

    To install the agent using organizational proxy:
    sudo wget https://plus.site24x7.com//sagent//Site24x7_Linux_64bit.install
    sudo chmod 755 Site24x7_Linux_64bit.install 
    sudo ./Site24x7_Linux_64bit.install -i -key=<DEVICE_KEY> -proxy=user:password@proxyhost:proxyport
    or
    sudo ./Site24x7_Linux_64bit.install -i -key=<DEVICE_KEY> -proxy=user@host:port
  2. [32-bit:]
    sudo wget https://plus.site24x7.com//sagent//Site24x7_Linux_32bit.install
    sudo chmod 755 Site24x7_Linux_32bit.install
    sudo ./Site24x7_Linux_32bit.install -i -key=<DEVICE_KEY>

    To install the agent using organizational proxy:
    sudo wget https://plus.site24x7.com//sagent//Site24x7_Linux_32bit.install
    sudo chmod 755 Site24x7_Linux_32bit.install 
    sudo ./Site24x7_Linux_32bit.install -i -key=<DEVICE_KEY> -proxy=user:password@proxyhost:proxyport
    or
    sudo ./Site24x7_Linux_32bit.install -i -key=<DEVICE_KEY> -proxy=user@host:port
    or
    sudo ./Site24x7_Linux_32bit.install -i -key=<DEVICE_KEY> -proxy=host:port

Install Linux agent While launching an already created Amazon Machine Image (AMI)

When you launch an instance using the Amazon EC2 management console, you have the option of running a configuration script on the Linux instance by passing user data. You can pass two types of user data to Amazon EC2; shell scripts and cloud-init directives. Download our Linux agent shell script "InstallSite24x7LinuxAgent.sh", append the Device key and pass it as user data. The commands will be executed on the Linux instance at launch.

To pass the agent shell script to an instance with user data, follow the below mentioned steps.

  • Download and save the file InstallSite24x7LinuxAgent.sh in your local machine.
  • Edit the script file to include your DEVICE Key in DEVICE_KEY="
    Device key can be obtained from Admin > Developer > Device Key. 
  • Now login to your AWS account, navigate to the EC2 management console</>li
  • In the Create instance section, select launch instance.
  • Under the choose AMI tab, select the type of AMI to use.
  • Under the “Configure instance tab” select “Advance details” to expand the section.
  • Under the “User data” field, select the “As file” option
  • Click on the “choose file” option to upload the InstallSite24x7LinuxAgent.sh file that is saved in your local machine.
  • Once you are done, review and launch the instance.
If you are launching more than one instance at a time, then the user data will be a available for all instances that are getting launched in that group

Installing the Linux agent while creating a new Amazon Machine Image (AMI)

You can add the below given agent installation script to the /etc/rc.local file on your Linux EC2 instance. Once done, the script will be executed at boot time and the Linux agent will be dowloaded and installed on your instance.

Append the device key to the below script and add it to the /etc/rc.local file

  1. [64-bit:AMI]
    if [ ! -f /etc/init.d/site24x7monagent ]; then
    wget https://plus.site24x7.com//sagent//Site24x7_Linux_64bit.install
    chmod 755 Site24x7_Linux_64bit.install
    ./Site24x7_Linux_64bit.install -i -key=<DEVICE_KEY>
    fi
  2. [32-bit:AMI]
    if [ ! -f /etc/init.d/site24x7monagent ]; then
    wget https://plus.site24x7.com//sagent//Site24x7_Linux_32bit.install
    chmod 755 Site24x7_Linux_32bit.install
    ./Site24x7_Linux_64bit.install -i -key=<DEVICE_KEY>
    fi

Linux agent installtion via CloudFormation templates

Using the Cloud Formation template you can automatically configure the Linux agent without connecting to the instance

Add the following commands to the user data property in the CloudFormation scripts. The user data property runs the necessary actions to install the Linux agent at the launch of the template.

  • "UserData" :{
    "Fn::Base64" : {
    "Fn::Join" : [ ",", [
    "#!/bin/bash\n",
    "sudo wget https://plus.site24x7.com//sagent//Site24x7_Linux_64bit.install\n",
    "sudo chmod 755 Site24x7_Linux_64bit.install\n",
    "sudo ./Site24x7_Linux_64bit.install -i -key=<DEVICE_KEY>\n"]]
    }
    }

Agent installation during AutoScaling

Create an AutoScaling launch configuration template and assign it to the AutoScaling group. This template will be used to launch EC2 instances. The launch configuration template will contain information about the EC2 instance - ID of the instance AMI, instance type, security group, etc. This is the same information you provide when you launch an EC2 instance, here again you have the option of passing the Linux agent shell script as user data.

Download our Linux agent shell script "InstallSite24x7LinuxAgent.sh", append the Device key and pass it as user data to run the script when the instance starts.

  • Download and save the file InstallSite24x7LinuxAgent.sh in your local machine.
  • Edit the script file to include your DEVICE Key in DEVICE_KEY="
    Device key can be obtained from Admin > Developer > Device Key. 
  • Login into your AWS account and navigate to the EC2 management console
  • In the navigation pane under Auto Scaling select “Launch configuration” and click on “Create launch configuration”.
  • Under the “Choose AMI tab”, select the AMI you want to use, under the “Configure details” tab, select advanced details to expand the section
  • Select the “As file” option in the “User data” field. Browse and upload the InstallSite24x7LinuxAgent.sh file that is saved in your local disk.
  • Now review and launch the newly created configuration, once done you can apply the launch configuration to your AutoScaling group.

You can also create and assign an launch configuration to a group using the AWS CLI (Command line interface)

The following steps will help you install agent during AWS Autoscaling:

  • To create launch configuration :
    as-create-launch-config <CONFIG_NAME> --image-id <AMI_ID> --instance-type <INSTANCE_TYPE> --user-data-file InstallSite24x7LinuxAgent.sh
    For example
    as-create-launch-config TestLaunchConfig --image-id ami-bd4ed56f --instance-type t1.micro --user-data-file InstallSite24x7LinuxAgent.sh
  • To assign the configuration to an Autoscaling group:
    as-update-auto-scaling-group <GROUP_NAME> --launch-configuration <CONFIG_NAME>
    For example
    as-update-auto-scaling-group TestAutoScalingGroup --launch-configuration TestLaunchConfig
  • Scaling down in AWS:

    If an integrated EC2 instance is stopped/terminated by an autoscaling group, both the EC2 instance and the server agent won't alert it as Down.

Installation via AWS Command Line Interface (CLI)

If you have already set up and installed the AWS command line interface in your machine, then you can:

  • Download and save the file InstallSite24x7LinuxAgent.sh in your machine.
  • Edit the script file to include your DEVICE Key in DEVICE_KEY="
  • Run the following command in your CLI
    ec2-run-instances --key KEYPAIR --user-data-file InstallSite24x7LinuxAgent.sh ami-bf5eb9d6
    For instructions on how to install AWS CLI refer here.

Configuration management tools

You can also use configuration management tools like Chef to bulk install the Linux agent on your EC2 instance.

Restart the Agent

Connect to your instance and type in the below mentioned command in the terminal to restart the Linux agent.

sudo /etc/init.d/site24x7monagent restart

Uninstall the Linux agent

Connect to your instance and type in the below mentioned command in the terminal to uninstall the agent from your instance.

sudo /opt/site24x7/monagent/bin/uninstall

Execute our out-of-the box Linux plugins

Monitor critical metrics for various application services running in your AWS stack. Execute our out-of-the box plugins to monitor the performance of Apache, NGINX, MySQL, Memcached and 30 other application services, running on your Linux EC2 instance.

Was this document helpful?
Thanks for taking the time to share your feedback. We’ll use your feedback to improve our online help resources.

Help EC2 CloudWatch and agent integration Linux agent deployment for EC2 instance