Unix resident agent scan

Setting up the resident agent

Automatic deployment and uninstallation of the resident agent

Attention!

Before you start working with the resident agent, you need to configure a Data transfer method to send scanning results to a remote resource.

 

Resident mode is not supported for ESXi systems.

Go to the Scanner  tab and click the Resident agent button on the Sidebar.

To deploy the resident agent, first add a scan task, configure the profile settings, and select logins, then click Deploy resident agent on the Sidebar.

Elements description:

  • Deploy resident agent. The agent and configuration files are uploaded to the remote computer in the home directory of the user performing the installation. After that, the main TNI module remotely runs the agent executable file with the –install switch. The agent analyzes the configuration and adds scheduled tasks to the system according to the schedule configured in the main TNI module. On Linux/BSD systems, this is done using the CRON task scheduler, and on macOS — using the launchd system daemon.
  • Remove resident agent. The main TNI module connects to the remote computer via the SSH protocol and runs the agent executable file (tninixagent or tnimacagent) with the –uninstall switch. The agent removes the scheduled system tasks, and the main TNI module deletes the agent folder along with all its files.

  • Set up logins. Allows you to configure logins for connecting to a remote computer to transfer the agent file.

  • Clear all. Deletes all created deployment tasks.

Buttons Deploy and Remove resident agent will be displayed only if tasks have been added to the task list.

During agent deployment, the following files are uploaded to the hidden .tniagent folder on the target device (for example, /home/root/.tniagent):

  • The agent executable file — tninixagent for computers running Linux/BSD, and tnimacagent for those running macOS.
  • The configuration file tninixagent.conf.

  • The password file tninixagent.dtr (if data transfer or agent updating is configured). Unlike the Windows agent, the passwords for data transfer are stored separately from the configuration file.

When the resident agent is removed, all contents of the .tniagent folder will be permanently deleted, including inventory files and logs.

To transfer data using the Unix agent on remote devices, the sshpass package must be installed. It can be installed using almost any package manager. For example:

  • On Debian: sudo apt install sshpass -y

  • On RHEL 7: sudo yum install sshpass -y

  • On RHEL 8/9: sudo dnf install sshpass -y

For the Mac agent, a separate installation of sshpass is not required.

When deploying the Unix agent, TNI will automatically check the remote device for sshpass. If the package is not installed and data transfer parameters are specified in the agent profile, the agent deployment will be aborted and an error message will be displayed.

Resident agent profiles

All settings of resident agents can be saved in profiles. There is no limit to the number of profiles you can create. A profile can be assigned to an individual agent or to a group of agents by holding CTRL and selecting the desired devices in the network tree.

A default profile is always present, allowing you to change its settings, but it cannot be renamed or deleted. Any changes made to the default profile will be applied to all resident agents using this profile unless a different profile is selected.

Click Add a new profile on the Scanner details information panel and select SSH resident profile to create a new profile, or click the Add button in the drop-down menu of the SSH profile column.

When you create or edit a profile, you’ll see the Profile Settings, where you can specify a name for the profile and enable the Auto-export resident agent profiles option. This option determines where profiles will be automatically exported if they are modified or if an updated agent file is released. If enabled, you will need to specify or create a valid data transfer method.

It is highly recommended to specify the same network resource used for the automatic update of the resident agent, so that the agent can receive its updates.

Using a simple selection of a node or a group of assets in the network tree and the context menu, you can assign a single profile that will apply to all selected items.

If necessary, the Clear button removes the assigned profile from the selected asset(s), but the profile itself remains in the list of profiles.

Assigning a SSH resident profile to nodes in the network tree is only possible if all selected devices run Unix.

When you assign or modify a profile, an informational panel will appear in the status area. Clicking it will create a task in the Scanner tab to update the resident agent’s profile on the selected devices.

A full profile change requires the agent to be redeployed to the device, either automatically or manually.

If necessary, you can use the Resident agent state assistant in the network tree.

Agent settings

The following options are available in a profile and allow you to fully configure the Unix resident agent according to your requirements.

  • Run test scan immediately after service start – the scan is performed immediately after the agent file is deployed. Once the scan is complete, the results are sent according to the specified data transfer method. This command is executed regardless of any scheduled tasks.
  • Run a scan every time OS starts – starts scanning after the OS boots. By default, the scan process begins 5 minutes after the OS has loaded. This delay ensures that all system processes and services are fully initialized before information is collected.
  • Overwrite the asset file upon rescan – disables adding a timestamp to the device data file. If a data file with the same name already exists on the network-shared resource or server where the agent outputs the file, it will be overwritten.
  • Auto-update the agent or settings from a network resource – allows you to specify the path to a folder on a web or file server from which the resident agent can automatically update itself or retrieve new settings. See Updating the resident agent. The following protocols are supported:  SFTP and SCP.
  • Send scan results / Data transfer method – allows you to select the data transfer method for sending scan results. The data will be sent to the specified resource. If this option is not enabled, the data files will be saved in the current installation folder of the agent (for automatically deployed agents, this is the hidden .tniagent folder in the home directory of the user under which the agent was installed).
  • Keep sent data in the ‘Sent’ folder – prevents inventory data files from being deleted after successful transfer. The files are saved in the Sent subfolder of the agent’s current installation folder.

After configuring scan result sending in the agent, be sure to create a data import task in TNI so that the data is properly imported and processed in the program’s storage.

Agent activity schedule

The format of scheduled tasks for SSH profiles differs from the scheduler in TNI and from Windows agent tasks, it fully corresponds to standard cron jobs.

Each field has two modes: At specific and Every. Tooltips with usage examples are provided for both modes.

For example, for the Hours field:

At specific — The task will be executed during each of the specified hours. You can enter values separated by commas (e.g., 0, 3, 12), ranges (2-8), or their combinations (2-8,12-16). The “*” symbol is supported, meaning all hours – equivalent to the range 0-23.

Every — The task will be executed every hour that is a multiple of the entered number. Valid values: 1-24. For example, 3 means the task will run at 0, 3, 6, 9 hours, and so on.

The agent schedule includes the following tasks:

  • Scan – according to the specified schedule, the agent will collect information from the device and then attempt to send the results.
  • Agent update – according to the specified schedule, the agent will check for updates to the executable file, configuration file, and data transfer passwords file.
  • Resend data – if, for any reason, data transfer was not completed right after scanning, the agent will attempt to resend the results according to the specified data transfer method.

Creating a scheduled scan is a crucial part of the setup process. If no schedule is created and “Run a scan every time OS starts” is not enabled, the agent will not perform any scans or data transfers.

Resident agent export

In addition to automatic export via the profile settings, you can also perform a manual export. The Export Resident Agents button is located on the Agent Profiles panel in the main area of the Scanner and allows you to export all available profiles, both Windows and Unix (SSH profiles).

It copies the agent files to the specified folder (for manual agent deployment). The exported files are tninixagent, tnimacagent, tninixagent_ssh_default.conf, and tninixagent.dtr (if a data transfer method or agent update is configured). A unique key in the tninixagent_GUID.conf format is added to the name of the exported configuration files. For instance, tninixagent_C390CD9D-31BB-46DC-B541-395A7724D3E5.conf.
Windows resident agent files will also be exported: tniwinagent.exe and tniwinagent.ini.

For correct export of all resident agent settings, please refer to Updating the resident agent and its settings.

Agent states

The resident agents’ states panel displays information about the status of agents on computers. It contains records of all hosted agents and indicates when updates are required. It also tracks the assignment of specific profiles to devices before they are installed on remote machines.

The Update resident agents button generates a list of agent deployment tasks for all nodes that require updates.

When this mode is activated, the program checks data against previously created device snapshots to determine whether agent files and their profiles need updating. If outdated agents are detected, this will be reflected in the states panel and a corresponding pop-up notification will appear above the main area of the Scanner tab.

Manual addition and removal of the resident agent

Manual deployment can be used when the computer to be inventoried is not connected to your network or when the resident agent cannot be deployed automatically for any reason.

To perform manual deployment, follow these steps:

  1. Set up the resident agent and its Schedule.
  2. Using the Export resident agent button on the Agent profiles panel, select an empty folder to which the files tninixagent / tnimacagent, tninixafent_*.conf, and tninixagent.dtr will be copied.
  3. After exporting the files, select the configuration file corresponding to the profile you prepared for manual installation and rename it to tninixagent.conf. You can find the profile name by opening the .conf file in any text editor.
  4. Copy or move these files to an empty directory on the remote computer where you want to install the agent. Make sure that the agent’s working directory will not be accidentally deleted.
  5. Install the resident agent from the current directory using the following commands:
    sudo chmod 755 tninixagent (or tnimacagent)
    sudo ./tninixagent --install

Available parameters for resident agents
*nix agent:
-f, --inv-file – perform a one-time scan and save the result to a file;
-l, --log– enable logging;
-i, --install– install the script as a resident agent and schedule all tasks defined in the configuration file. If the configuration file is not found, the default configuration will be used;
-u, --uninstall– remove all cron jobs related to the agent;
-u, --update– update the agent script;
-s, --send– send all files with scan results;
--non-interactive– disable interactive prompts;
--no-archive– disable archiving of output scan files.

Mac agent:
-ip:[ipaddr] – set the current IP address;
--help– display help information describing available parameters;
-debug– enable extended debugging mode (detailed logging);
--inv-file– perform a one-time scan and save the result to a file (without console output);
--install– install the agent as a resident service and schedule tasks according to the configured schedule;
-uninstall– remove the resident agent and all related tasks;
--send– send all accumulated scan result files.

Example: tninixagent --install --inv-file --send — installs the agent, performs a test scan, and immediately sends the results to the server or network folder.

Updating the resident agent and its settings

The resident agent can be updated on remote computers using any of the following methods:

  1. Re-deploy the agent from the Scanner tab in TNI.

In this case, do not remove the resident agent first; otherwise, all contents of the agent’s folder, including any saved scan results, will be deleted.

 2. Configure auto-updates from a network resource. To do this, enable the option in the agent profile settings and specify the path to the directory where updated versions of the agent and settings file will be placed. If only the settings need to be updated, the settings file (tninixagent.conf) can be copied to the specified directory without the agent file.
The resident agent automatically checks for updates according to the specified scheduled tasks. The following protocols are supported for updating: SCP and SFTP.

Example path for updating via SCP:
scp://serveradress:22/TNIAgentFolder/

Example path for updating via SFTP:
sftp://serveradress:22/TNIAgentFolder/

It’s important to note that updating the agent file without the configuration file is not possible.

When specifying paths, ports can be omitted. In this case, the resident agent will use the default ports for the corresponding protocols when sending data.

3. Manual updating. If needed, the resident agent can be updated manually. To do this, set up the resident agent as usual and export it to obtain the new configuration files tninixagent.conf and tninixagent.dtr (and the updated agent file tninixagent or tnimacagent if required).

Copy the new tninixagent.conf and tninixagent.dtr files (and the agent file, if necessary) into the agent’s installation directory on the target device. The path depends on the username under which the agent was installed. If the users’ home directories have not been reconfigured, the path may look as follows:

  • Linux/BSD/home/<username>/.tniagent

  • macOS/Users/<username>/.tniagent

After copying, connect to the target device via SSH as the user under which the agent was installed, and set the appropriate file permissions:

  • For Linux/BSD: chmod 700 tninixagent

  • For macOS: chmod 700 tnimacagent

  • For all systems: chmod 600 tninixagent.conf tninixagent.dtr

Contents