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.7 are available on the system for scripted installs. Python 2.7 is required for all source installs.
Sysstat should also be installed if possible as this will allow the agent to gather extra metrics.
Scripted Installation
Create an API token
- Log in to your Server Density account.
- Click your name in the top left, then click Preferences.
- 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".
- 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.2.0). Then update the line below to reflect the latest release number.
export AGENT_VER="2.2.X"
Navigate to the sd-agent-core-plugins Github repo to find out the latest release (eg: 2.2.0). Then update the line below to reflect the latest release number.
export PLUGIN_VER="2.2.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 $VENV_PIP_CMD install -r $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
Plugin Installation
Download & install plugins
sudo curl -k -L -o "$SD_HOME/plugins.tar.gz" "https://github.com/serverdensity/sd-agent-core-plugins/tarball/$PLUGIN_VER" sudo mkdir -p "$SD_HOME/agent/checks.d/" sudo mkdir -p "$SD_HOME/plugins" tar -xz -C "$SD_HOME"/plugins --strip-components 1 -f "$SD_HOME"/plugins.tar.gz for d in `ls $SD_HOME/plugins/*/check.py`; do name=${d#"$SD_HOME/plugins/"} name=${name%/check.py} sudo cp $d "$SD_HOME/agent/checks.d/$name.py" done for d in `ls $SD_HOME/plugins/*/conf.yaml.example`; do name=${d#"$SD_HOME/plugins/"} name=${name%/conf.yaml.example} sudo cp $d "$SD_HOME/agent/conf.d/$name.yaml.example" done for d in `ls $SD_HOME/plugins/*/conf.yaml.default`; do name=${d#"$SD_HOME/plugins/"} name=${name%/conf.yaml.default} sudo cp $d "$SD_HOME/agent/conf.d/$name.yaml.default" done
Install plugin requirements
for d in `ls $SD_HOME/plugins/*/requirements.txt`; do $VENV_PIP_CMD install -r "$d" done
Delete old archive and folder
rm -f "$SD_HOME"/plugins.tar.gz rm -rf "$SD_HOME"/plugins
In order to use a plugin you simply need to configure it per its relevant document.
Daemonize the agent
If you want the agent to run in the background you need to daemonize the agent.
init.d
For Linux distributions using init.d, follow these instructions.
rc.d
For FreeBSD systems using rc.d, follow these instructions.
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
Test the agent
cd $SD_HOME supervisord -c $SD_HOME/agent/supervisor.conf
Check your metrics
Login to your account and check your new device is receiving metrics.
Start the agent
cd $SD_HOME bin/agent start
Comments