Agent Installation from Source

For customers who are not running Red Hat or Ubuntu based linux distributions we offer a source install option. There are two options available, a scripted install and a manual install. An update script is also available for users to update their source installs easily.

You must ensure that bash, curl and python 2.6 or 2.7 are available on the system for scripted installs.

Sysstat should also be installed if possible as this will allow the agent to gather extra metrics.

Scripted Installation

Create an API token

  1. Log in to your Server Density account.
  2. Click your name in the top left, then click Preferences.
  3. Go to the Security tab then in the bottom right, enter a name for the API application you're building so you can easily recognise it in the future e.g. "install.sh".
  4. Press Enter and your API token will be shown as a 32 character ID.

Execute the script

Download the installer script and then execute with your account name, the API token you created above and, optionally, a group name to create the device in: 

curl http://archive.serverdensity.com/agent-install-source.sh | sudo bash -s -- -a ACCOUNT -t API_TOKEN

If you have already created the device in Server Density, you can pass the agent key without the API token:

curl http://archive.serverdensity.com/agent-install-source.sh | sudo bash -s -- -a ACCOUNT -k AGENT_KEY

Executing the script will start the installation and you will not be prompted further. The agent will be installed to $HOME/.sd-agent of the user executing the script which will be root as the script requires sudo, however this location can be changed by setting the required location with the -l option, like in the following example which will install the agent at /etc/sd-agent: 

curl http://archive.serverdensity.com/agent-install-source.sh | sudo bash -s -- -a ACCOUNT -k AGENT_KEY -l /etc/sd-agent

Optional arguments can be passed to group the device, assign a tag or create a device with the relevant provider information for cloud provider sync.

 -g: Group to add the new device into.
 -T: Tag this device - multiple tags not supported.
 -p: Hosting provider (e.g. amazon)
 -i: Provider ID (requires provider). Cloud device ID (instance ID for EC2 devices)
 -A: Automatically get the Amazon Web Services instance ID and provider
 -G: Automatically get the Google Cloud instance ID and provider 
-l: Set the install location

Manual Installation

Check for the latest release and define release version 

Navigate to the sd-agent Github repo to find out the latest release (eg: 2.1.0). Then update the line below to reflect the latest release number. 

export AGENT_VER="2.0.X"

Define a location for the agent and logs

export SD_HOME="$HOME/.sd-agent"
sudo mkdir $SD_HOME
sudo mkdir /var/log/sd-agent

Download and install the agent virtual environment

sudo curl -k -L -o $SD_HOME/virtualenv.py https://raw.githubusercontent.com/pypa/virtualenv/1.11.6/virtualenv.py
sudo python $SD_HOME/virtualenv.py --no-pip --no-setuptools $SD_HOME/venv
sudo rm -f "$SD_HOME/virtualenv.py" sudo rm -f "$SD_HOME/virtualenv.pyc"

Activate the virtual environment

source "$SD_HOME/venv/bin/activate"

Set virtual environment commands

export VENV_PYTHON_CMD="$SD_HOME/venv/bin/python"
export VENV_PIP_CMD="$SD_HOME/venv/bin/pip"

Install ez_setup in the virtual environment

sudo curl -k -L -o $SD_HOME/ez_setup.py https://bootstrap.pypa.io/ez_setup.py 
sudo $VENV_PYTHON_CMD $SD_HOME/ez_setup.py --version="20.9.0"
sudo rm -f "$SD_HOME/ez_setup.py"
sudo rm -f "$SD_HOME/ez_setup.pyc"

Install pip in the virtual environment

sudo curl -k -L -o $SD_HOME/get-pip.py https://bootstrap.pypa.io/get-pip.py
sudo $VENV_PYTHON_CMD $SD_HOME/get-pip.py
sudo $VENV_PIP_CMD install "pip==8.1.1"
sudo rm -f "$SD_HOME/get-pip.py"
sudo rm -f "$SD_HOME/get-pip.pyc"

Install virtual environment requirements

sudo curl -k -L -o $SD_HOME/requirements.txt https://raw.githubusercontent.com/serverdensity/sd-agent/master/requirements.txt
sudo $VENV_PIP_CMD install -r "$SD_HOME/requirements.txt"
sudo rm -f "$SD_HOME/requirements.txt"

Download agent

sudo mkdir -p $SD_HOME/agent
sudo curl -k -L -o $SD_HOME/agent.tar.gz https://github.com/serverdensity/sd-agent/tarball/$AGENT_VER
sudo tar -xz -C $SD_HOME/agent --strip-components 1 -f $SD_HOME/agent.tar.gz
sudo rm -rf $SD_HOME/agent.tar.gz

Install optional requirements

sudo sh $SD_HOME/agent/utils/pip-allow-failures.sh $SD_HOME/agent/requirements-opt.txt

Configure the agent

sudo mv $SD_HOME/agent/config.cfg.example $SD_HOME/agent/config.cfg
sudo nano $SD_HOME/agent/config.cfg 

With your favourite text editor add your account name and agent_key to sd_account and agent_key respectively.

Copy init scripts

sudo mkdir -p "$SD_HOME/bin"
sudo cp "$SD_HOME/agent/packaging/source/agent" "$SD_HOME/bin/agent"
sudo chmod +x "$SD_HOME/bin/agent"

Setup supervisord

sudo $VENV_PIP_CMD install "supervisor==3.1.3"
sudo curl -k -L -o $SD_HOME/agent/supervisor.conf https://raw.githubusercontent.com/serverdensity/sd-agent/master/packaging/source/supervisor.conf
sudo mkdir -p $SD_HOME/run

Test the agent

cd $SD_HOME
sudo supervisord -c $SD_HOME/agent/supervisor.conf

Check your metrics

Login to your account and check your new device is receiving metrics.

(Optional) Create an sd-agent user and start a screen

useradd sd-agent
su sd-agent
screen -S sd-agent

Start the agent

cd  $SD_HOME
bin/agent start

Plugin Usage

The agent can also make use of the official plugins that are available. These do not need installing as they are already present in the tar so are installed when the source install occurs. 

In order to use a plugin you simply need to configure it per it's relevant document.

Update Script

You can use our update script to update your source install:

curl http://archive.serverdensity.com/agent-update-source.sh | sudo bash -s -- -l /agent/install/location 

The -l option is not required. If it is not given the script will use the default location of

$HOME/.sd-agent
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Monday  —  Friday.

10am  —  6pm UK.

Dedicated Support.