How Trafikito monitoring work?

Lukas Liesis
4 min readFeb 12, 2019

--

Trafikito is a cloud-based service which can monitor the output of any command running on a Linux machine.

By default, it will monitor the output of most popular commands such as free, uptime, df, vmstat, ps. But you can monitor the output of any command you have available on your Linux machine.

Trafikito is made of couple parts

  1. Dashboard where you can see charts, edit layout, commands you want to track, notifications, variables etc.
  2. The open source POSIX agent which runs on your Linux machine. It has a file called available_commands.sh which must contain all the available commands. You can add any just keep in mind that it has to run and die. Don’t add continuous commands like tail -f /some/file

Open source POSIX agent running on your machine

During installation you will download agent files and depending on your system it will use the available mechanism (systemd, system V or openRC) to run the agent once per minute. It will create a configuration file with Trafikito.com credentials used to identify the server:

/opt/trafikito/etc/trafikito.cfg

If you don’t want to use the default configuration, you can run the agent with crontab or anything you can think of. Just make sure to run it once per minute. While the agent is just a collection of shell script files you can read, edit and run them as needed.

What happens during each cycle?

One cycle is the full process which happens every minute. The agent starts at your server, collects all the needed output and sends it to Trafikito. Then Trafikito does all the heavy lifting — parses the output, tracks variable values and fires notifications if needed.

Once per minute Trafikito agent starts the cycle

First of all, the agent will read the local file to know which commands it can execute.

If you want to add the new command at data sources settings, you have to connect to your server, edit /opt/trafikito/available_commands.sh file and wait one minute after the save. Then refresh your dashboard and you will see updated available commands list at your data source settings.

Data source edit view. Selecting available command for this data source.

For security reasons, each command must be defined at /opt/trafikito/available_commands.sh and must start with trafikito_ or it will not be executed. Commands from this file is synced with your dashboard during each cycle — once per minute.

Then the agent uses credentials from /opt/trafikito/etc/trafikito.cfg gets commands you wish to run based on your data sources settings at the dashboard.

Data sources at the server settings

The agent gets commands to run from your dashboard

After getting the list of commands from your dashboard agent will double check if it can actually run those commands. Each command must start with trafikito_ prefix, all of them must be defined at /opt/trafikito/available_commands.sh file.

Default contents of the /opt/trafikito/available_commands.sh

The output of commands and list of currently available commands are sent to Trafikito

Each valid command is executed and output together with content from /opt/trafikito/available_commands.sh are sent to one of the global Trafikito endpoints.

Trafikito.com edge locations on AWS cloud

From this point, the agent is done and work is taken by Trafikito cloud

The agent is designed to stay super light-weight so it could be used by IoT devices made with low-end CPUs. The agent does only a small but essential part of the cycle:

  1. Get commands from Trafikito dashboard
  2. Check commands against configuration at your server for security reasons
  3. Execute commands and send raw output to Trafikito

Trafikito software in the cloud does all the heavy lifting

Trafikito parses the output of each and extracts variable values based on your data sources configuration. Then it checks current values against variable range settings and if it’s in warning or error ranges, it will check for notification settings at your dashboard.

If needed notifications are sent

Eventually, if needed notifications are sent. Default notifications are email messages but with a little configuration, you can fire any API call you want.

Trafikito is a different view on how monitoring should work

With the rise of all custom machines built with such devices as RaspberryPi and all kind of software coming to market day after day, it is important to be able to monitor anything you want and with Trafikito you can.

While most of the software can output some statistical information via command line, Trafikito can monitor all of it. Ranging from classical web services to state-of-the-art custom build projects.

--

--

Lukas Liesis
Lukas Liesis

Written by Lukas Liesis

2 decades exp of building business value through web tech. Has master's degree in Physics. Built startups with ex-Googlers. Was world’s top 3% developer.

No responses yet