# ONES Telemetry Agent Installation

## ONES Agent v2.1 support Agent Auto discovery

1. ONESv2.1 Agent support auto-discovery feature
2. ONESv2.1 Agent support to send telemetry on multiple controllers (Max 2)
3. Restrict IP feature can be enabled/disabled
4. Only Collector upgrade after Deployment is possible now&#x20;
5. Using the Restrict IP feature agent will discover the ONES Controller and will update the entry on the ONES App with all the feature metrics
6. Need to add a few inputs while installing the agent
   1. Controller IP //To restrict the telemetry streaming
   2. Device Credentials
   3. Layer&#x20;
   4. Region
   5. azid
   6. brickid
   7. rackid

## Installation

On the Application machine, go to ONES-2.1/ones\_t\_agent folder

<mark style="color:blue;">`root@ones-application:~$ cd /ONES-2.1/ones_t_agent`</mark>

### Installation (Agent Install on multiple switches at the same time)&#x20;

* Enter device details (Management IP, Username and Password ) in device\_info.csv

<mark style="color:blue;">`root@ones-application/ONES-2.1/ones_t_agent:~$ vi device_info.csv`</mark>

{% hint style="info" %}
The user needs to add all the required details in the CSV file, This CSV file will be used to push this information to agent.conf(/etc/sonic/agent.conf) file to every switch and ones-agent on the switch will pick the details from agent.conf file and will register itself to ONES controller with all the given parameters\
this helps a NetOps engineer to directly add a CSV file containing all the details, The Engineer needs not to add one by one devices on the controller which actually is time-consuming
{% endhint %}

```log
ip,user,passwd,layer,region,azid,brickid,rackid
10.4.4.61,admin,YourPaSsWoRd,Superspine,SanJose,1,1,1
10.4.4.61,admin,YourPaSsWoRd,Spine,SanJose,1,1,1
10.4.4.62,admin,YourPaSsWoRd,Leaf,SanJose,1,1,1
10.4.4.61,admin,YourPaSsWoRd,ToR,SanJose,1,1,1
...
...
...
```

{% hint style="warning" %}
The user must maintain the layer names exactly as specified above (case-sensitive). If the user inputs names that differ from these, they may encounter issues when using the ONES application.
{% endhint %}

* Save the File&#x20;

**Executing the installation script can be used for installing a telemetry agent on one or more devices in the data centre.**

{% hint style="info" %}
The installer file automatically detects & will process fresh installation or upgrade to the new version
{% endhint %}

{% hint style="info" %}
While upgrading, all the previous files will automatically get deleted on the Switch
{% endhint %}

{% hint style="info" %}
If users want to use the certificate for GNMI & Auto-Registration, so users need to put the certificate in directory gnmi-certs(for GNMI) & auto-reg-certs(for Agent Auto Registration)
{% endhint %}

<mark style="color:blue;">`root@ones-application/ONES-2.1/ones_t_agent:~$ ./ones_agent_parallel_installer.sh`</mark>

1. Users can use ONES-Agent as an integrated service in SONiC OS or can use it as an independent third-party container.

```log
Does the ONES-agent is integrated with SONiC NOS? (yes/no): no
```

2. Users can choose this option to only update one more controller IP without doing the complete agent installation.

```log
Do you want to add only Collector IP for auto-discovery and skip the agent installation ?(yes/no): no 
```

3. Scripts asks to put the Controller IP to use auto-discovery feature

```log
Enter the ip address of collectors to auto-discover. Do not enter more than 2. Eg - 10.1.1.10, 10.2.2.5 : 10.4.4.11
```

{% hint style="info" %}
User can only add 2 Controller IP to restrict the telemetry streaming
{% endhint %}

4. User can choose the restriction to send telemetry to collector IP only

```log
Do you want to restrict access only to provided collector ip?
Note: Providing Yes will restrict access to agent only with the provided collector IP Address
Enter Yes/No : Yes
```

{% hint style="danger" %}
It's important to restrict collector IP as NO in case the running network has NAT translation from private to public IP for ONES server access from the device.
{% endhint %}

### Installation Begin

{% code fullWidth="false" %}

```log
Does the ONES-agent is integrated with SONiC NOS? (yes/no): no
Do you want to add only Collector IP for auto-discovery and skip the agent installation ?(yes/no): no
Enter the ip address of collectors to auto-discover. Do not enter more than 2. Eg - 10.1.1.10,10.2.2.5 : 10.4.4.11
Do you want to restrict access only to provided collector ip?
Note: Providing Yes will restrict access to agent only with the provided collector IP Address
Enter Yes/No: No
468025bd9c12: Loading layer [==================================================>]   2.56kB/2.56kB
1961412d5783: Loading layer [==================================================>]  36.56MB/36.56MB
de3513fa22d1: Loading layer [==================================================>]  42.69MB/42.69MB
ca3343e443b5: Loading layer [==================================================>]  1.421MB/1.421MB
Loaded image: avizdock/agent_installer:latest
Docker image 'avizdock/agent_installer:latest' is loaded.
ab76dcd0da078a25570efe51a0057040f47e8a4a5c7320a47eb7a63ac5b42d8c
Docker container 'agent_installer' is running.
...
...
...
###############Connecting to switch###############
Connection to switch 10.4.4.61 successful.....................
Looking for previous installation........................
...
...
...
Loading Docker image on the device 10.4.4.61 ###########################################
Docker image loaded successfully on the device 10.4.4.61........
Getting name of the loaded image
image = ##avizdock/ones-agent:v2.1.0##
Running docker.....................
docker run -it -v /var/run/docker.sock:/var/run/docker.sock -v /host/reboot-cause:/host/reboot-cause -v /etc/sonic:/etc/sonic -v /var/run/redis:/var/run/redis -v /var/run:/var/hostrun --log-driver local --log-opt max-size=5m --log-opt max-file=3 --cpu-period=100000 --cpu-quota=50000 --net=host --privileged -dt --name ones-agent avizdock/ones-agent:v2.1.0
b'a01ff31e2f11613e608d7aa425748c69e4d803c5c3cd8a14a1524d173b5e9549\n'
Loading Service file on the device 10.4.4.61........
Service file loaded successfully on the device 10.4.4.61##################
Enabling ones-agent.service 10.4.4.61 ##################
Enabled ones-agent as service successfully on the device 10.4.4.61 ##################
Starting ones-agent service on the device 10.4.4.61........
started ones-agent service successfully on the device 10.4.4.61 ##################
Enabling ones-agent to restart after booting on the device 10.4.4.61........
Made ones-agent immune to booting on the device 10.4.4.61########################
Copying ones-agent.tar file
ones-agent.tar file copied successfully on the device 10.4.4.61........
Copying agent.conf file
agent.conf file copied successfully on the device 10.4.4.61........
Copying ones-agent.service file
ones-agent.service file copied successfully on the device 10.4.4.61........
Copying ones_agent_ip_rule.sh file
ones_agent_ip_rule.sh file copied successfully on the device 10.4.4.61........
Copying ones_agent_start.sh file
ones_agent_start.sh file copied successfully on the device 10.4.4.61........
##################################################################
Status of ones-agent.service is -      Active: active (running) since Mon 2024-04-15 19:32:21 IST; 1min 35s ago

Deployment of ones-agent to switch 10.4.4.61 is successful
agent_installer

Docker agent_installer has been stopped
agent_installer

Docker agent_installer has been removed
Untagged: avizdock/agent_installer:latest
Deleted: sha256:6604bbec1feedd9169ea6cca598650bf2f1fe659ae587e9637f80adabe877eeb
Deleted: sha256:4754441bc1128ca32bd0085e2a366e111b4882359cdebc92560d243a671f33e3
Deleted: sha256:c803c23f2ec84e2601fa5e5d954b1cbf406167ae057d7200e9d2f61ba1f402fa
Deleted: sha256:f9279b9fbc87fee822c69ea9cacc2f9d9a10d9c54bbc21732205684ea3bcf0b1
Deleted: sha256:27ea50b3cb2914caa5f99e5268ba0b47e15fb7c490275f560c54e400162e2cc3

Docker  image has been removed
```

{% endcode %}

{% hint style="info" %}
Now Agent will only stream the metrics to the given controller & will autoregister on the ONES-App
{% endhint %}

{% hint style="warning" %}
The user needs to make sure, The devices have a unique name, otherwise, there will issue while plotting the full topology view(Topology Page).
{% endhint %}

<figure><img src="https://content.gitbook.com/content/PfHBjTcBLMXuJNIK9YDj/blobs/4sv6QCAM730spTXr4GuC/Screenshot%202024-04-10%20at%2012.48.18%E2%80%AFPM.png" alt=""><figcaption></figcaption></figure>

###
