Install nixstatsagent manually

Dependecies

Nixstatsagent requires the following dependencies.

  • python 2.6 or 2.7
  • pip or easy_install
  • supervisor or a service script to run nixstatsagent on boot
Installing

First check which version of python is available on your system.

python -V
python2.7 -V

Now check if you have pip or easy_install available on your system.

pip -V
easy_install --version

pip is preferred above easy_install, you should only used easy_install if pip is not available or not working for you.

Install nixstatsagent by running

pip install nixstatsagent

or easy_install

easy_install nixstatsagent

Once the installation is completed we can download the default configuration file.

wget -O /etc/nixstats.ini https://nixstats.com/nixstats.ini

Now create a serverid so the server is registered at nixstats.com. You can find your usertoken at https://nixstats.com/servers/overview

nixstatshello yourusertoken /etc/nixstats-token.ini

This command should return a serverid and store it in /etc/nixstats-token.ini

To test if the nixstatsagent is working we can just run the nixstatsagent command in the foreground. Wait a couple of minutes for the agent to start sending data to our API data to be updated on your dashboard.

Run nixstatsagent as a service

There are two ways to run nixstatsagent as a service, you can create a service script or use a program like supervisord.

Supervisor

Follow the instruction here to install supervisor. After installing supervisor several service script are available here on github.

Add the following at the end of /etc/supervisor.conf file.

You can find the path to nixstatsagent by running which nixstatsagent

[program:nixstats]
command=/path/to/nixstatsagent
autostart=true
autorestart=true
startretries=3
stderr_logfile=/var/log/nixstats.err.log
stdout_logfile=/var/log/nixstats.out.log

Run the following commands to update supervisor with the changes.

supervisorctl reread
supervisorctl update

You can now start/stop/restart the service with the supervisorctl command.

supervisorctl stop nixstats
supervisorctl start nixstats
supervisorctl restart nixstats