POSIX agent which is running on client's machine.
Once per minute agent get commands to execute from Trafikito API by server configuration, executes them on server and sends outputs back to Trafikito. Trafikito does all the parsing, UI and notifications related actions.
Agent can be installed anywhere on Linux machine.
Default location is /opt/trafikito
and in what follows it is assumed that Trafikito
is installed in the default location.
This file is used only during installation. It tries to execute default commands to gather all basic information. Sends it to Trafikito API to get agent files + generate default settings for this specific server.
Installation downloads agent files, configure startup method and removes itself.
The Trafikito controller:
Template file which will have initial list of commands after installation. This file will be appended with lines similar to:
trafikito_uptime="uptime"
trafikito_total_ram="/usr/sbin/sysctl hw.memsize"
trafikito_df="df -hl"
To add a new command first step is to edit file at /opt/trafikito/available_commands.sh
Location may be different if installed on custom path.
All commands must have trafikito_
prefix. E.g:
- trafikito_free (alias for
free
) - trafikito_uptime (alias for
uptime
) - trafikito_df (alias for
df
)
The static configuration file for Trafikito.
The dynamic configuration file for Trafikito.
A wrapper to run the real agent /opt/trafikito/lib/trafikito_agent.sh
The real Trafikito agent.
Trafikito log file.
Temporary file used by Trafikito.
tmp/trafikito/ ├── available_commands.sh ├── etc │ └── trafikito.cfg ├── lib │ └── trafikito_agent.sh │ └── trafikito_wrapper.sh ├── trafikito └── var trafikito.log trafikito.tmp
3 directories, 5 files
Main file which runs all the agent. All other files supports execution of agent.sh.
Each cycle of data collection runs once per minute. Agent calls Trafikito API with API key and server ID. If last data was received 1+ minute ago Trafikito API responses with CSV:
63e374bd-92be-4275-a985-ba2b8d2a953d,trafikito_uptime,trafikito_total_ram
First argument is unique call token and then are commands to be executed.
Agent splits this CSV and executes each command, saves all outputs to temporary file and when all done - sends to Trafikito API together with call token. Trafikito backend does the rest - parse output, send notifications etc.etc.
Together with output of commands agent on each cycle sends available commands from /opt/trafikito/available_commands.sh
Environment configuration for agent.
- api_key
- server_id
- tmp_file
- url_output = https://api.trafikito.com/v1/agent/output
- url_get_config = https://api.trafikito.com/v1/agent/get
- random_number
All values inside pair of curly braces will be replaced during installation
On each cycle available commands from /opt/trafikito/available_commands.sh
are sent
to Trafikito API. This is helper function to read this file.
Helper file which takes commands to run output from Trafikito API. Splits 1st argument as
call_token
(unique for each cycle & used to save output to Trafikito) and uses all following
comma separated values as inputs for functions/execute_trafikito_cmd.sh
Takes one command at a time and executes. Prints output to temporary file.
Takes value from config file
Sends $tmp_file
contents to Trafikito API together with $call_token
and $api_key
Makes request to Trafikito API to get commands_to_run
. Output may be error, so this file handles it or
it is something like this:
63e374bd-92be-4275-a985-ba2b8d2a953d,trafikito_uptime,trafikito_total_ram
Sets some global variables:
- agent_version
- config_file
- lock_file
- api_key
- server_id
- tmp_file
- random_number
- url_output
- url_get_config
Sets some global variables:
- os
- os_codename
- os_release
- centos_flavor