cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Extracting a Flexera AgentUniqueID from Hosts

AntonGoosen
Observer

Hi there.

I want to Extract the Flexera AgentUniqueID from the config.ini file of all the Hosts in my env and assign it to the Host in DT as a Tag.  I can easily get the ID from ssh in Linux:

---------------------------
sudo grep -r "AgentUniqueID" /var/opt/managesoft/etc/config.ini

The result is:

--------------------------- 

[ManageSoft\AgentUniqueID]
AgentUniqueID=a96abfc1ababc16bb7190ffaf965336ca7df1814dcf2c24ac3

---------------------------

Is there an easier way to do this via another mechanism?

1 REPLY 1

MostafaHussein
Advisor

you can use the following bash script as it automate extraction to a variable then use oneagentctl to reset assigned property or tag by removing it if exists then set the new value (you can change the oneagentctl to set property not tags according to your needs).

this on each host individually or within batch for your cluster

 

#!/bin/bash

# Get the AgentUniqueID from the config file
agent_unique_id=$(sudo grep -Po '(?<=AgentUniqueID=).*' /var/opt/managesoft/etc/config.ini)

# Check if the AgentUniqueID was found
if [[ -z "$agent_unique_id" ]]; then
    echo "AgentUniqueID not found in config file."
    exit 1
fi

# Remove the existing AgentUniqueID property
./oneagentctl --remove-host-tag=AgentUniqueID

# Set the new AgentUniqueID property
./oneagentctl --set-host-tag=AgentUniqueID="$agent_unique_id"

echo "AgentUniqueID updated successfully."

 

 

references:
https://docs.dynatrace.com/docs/shortlink/oneagentctl#custom-host-metadata

https://docs.dynatrace.com/docs/shortlink/tagging-hostautotag

hope this helpful for you.

BR,
Mostafa Hussein.

 

Certified Dynatrace Professional | Certified Dynatrace Services - Observability | Dynatrace Partner yourcompass.ca

Featured Posts