The pain and benefit
The Dynatrace-OneAgent (OA) keept up to 10 older versions in /opt/dynatrace/oneagent/agent/bin then the “current” used version.
This RFE should give a better way to:
- Reduce the number of OA installation
- Reduce waste of storage usage
- Reduce the security risks of old installations
- Keep OneAgent better up to date if the disk free for an OA update is tight
- Reduce the coast of storage by the customer
How it works?
- All installation that are not the current installation and older then the last boot can be removed
- Find all remove candidates
- Remove all never be used old installations
Where are the installations keept?
ls -1 /opt/dynatrace/oneagent/agent/bin
|
On a typical and longer running machine you have up to 11 versions The used version is link by current and has the full installation of the OneAgent. Older installations are reduced of usage.
ls -l /opt/dynatrace/oneagent/agent/bin
total 0
drwxrwxr-x. 6 root dtuser 82 Aug 6 2024 1.293.168.20240805-161707
drwxrwxr-x. 6 root dtuser 82 Aug 21 2024 1.295.70.20240820-160945
drwxrwxr-x. 6 root dtuser 82 Sep 6 2024 1.297.63.20240905-133818
drwxrwxr-x. 6 root dtuser 82 Sep 30 2024 1.297.74.20240930-123813
drwxrwxr-x. 6 root dtuser 82 Oct 1 2024 1.299.50.20240930-123825
drwxrwxr-x. 6 root dtuser 82 Nov 18 15:27 1.303.50.20241118-133432
drwxrwxr-x. 6 root dtuser 82 Nov 30 11:45 1.303.62.20241129-131342
drwxrwxr-x. 6 root dtuser 82 Feb 3 23:16 1.305.109.20250203-163926
drwxrwxr-x. 6 root dtuser 82 Feb 13 15:04 1.305.110.20250213-112827
drwxrwxr-x. 6 root dtuser 82 Jan 14 20:01 1.305.98.20250114-172617
drwxrwxr-x. 6 root dtuser 82 Feb 26 17:57 1.307.61.20250226-155505
lrwxrwxrwx. 1 root dtuser 24 Mar 12 06:00 current -> 1.307.61.20250226-155505
|
The diskusage of these OA is actually
du -hcs /opt/dynatrace/oneagent/agent/bin/1.*
50M /opt/dynatrace/oneagent/agent/bin/1.293.168.20240805-161707
32M /opt/dynatrace/oneagent/agent/bin/1.295.70.20240820-160945
32M /opt/dynatrace/oneagent/agent/bin/1.297.63.20240905-133818
32M /opt/dynatrace/oneagent/agent/bin/1.297.74.20240930-123813
32M /opt/dynatrace/oneagent/agent/bin/1.299.50.20240930-123825
33M /opt/dynatrace/oneagent/agent/bin/1.303.50.20241118-133432
33M /opt/dynatrace/oneagent/agent/bin/1.303.62.20241129-131342
33M /opt/dynatrace/oneagent/agent/bin/1.305.109.20250203-163926
33M /opt/dynatrace/oneagent/agent/bin/1.305.110.20250213-112827
33M /opt/dynatrace/oneagent/agent/bin/1.305.98.20250114-172617
958M /opt/dynatrace/oneagent/agent/bin/1.307.61.20250226-155505
1.3G total
|
In this case it waste around 350 MB of old OA versions.
The candiate to reduce
All installation that are older then the last boot. But exclude the current installation
The last time of boot you see via “stat /dev/shm”. All directories that are older then the directory “/dev/shm”.
In this case all over the stat of “/dev/shm” shows:
stat -c "%w | %n" /opt/dynatrace/oneagent/agent/bin/1.* /dev/shm|sort -n
2024-08-08 20:04:22.970465391 +0200 | /opt/dynatrace/oneagent/agent/bin/1.293.168.20240805-161707
2024-09-12 20:07:41.300161636 +0200 | /opt/dynatrace/oneagent/agent/bin/1.295.70.20240820-160945
2024-10-02 07:00:45.239424904 +0200 | /opt/dynatrace/oneagent/agent/bin/1.297.63.20240905-133818
2024-10-09 07:01:15.395335667 +0200 | /opt/dynatrace/oneagent/agent/bin/1.297.74.20240930-123813
2024-10-29 06:01:09.263204351 +0100 | /opt/dynatrace/oneagent/agent/bin/1.299.50.20240930-123825
2024-11-25 06:00:35.737849190 +0100 | /opt/dynatrace/oneagent/agent/bin/1.303.50.20241118-133432
2024-12-05 06:00:39.114198974 +0100 | /opt/dynatrace/oneagent/agent/bin/1.303.62.20241129-131342
2025-02-05 06:00:34.337497537 +0100 | /opt/dynatrace/oneagent/agent/bin/1.305.98.20250114-172617
2025-02-12 06:01:08.312319174 +0100 | /opt/dynatrace/oneagent/agent/bin/1.305.109.20250203-163926
2025-02-19 06:00:32.854178575 +0100 | /opt/dynatrace/oneagent/agent/bin/1.305.110.20250213-112827
2025-03-12 06:00:24.400509625 +0100 | /opt/dynatrace/oneagent/agent/bin/1.307.61.20250226-155505
2025-04-01 21:13:14.998000012 +0200 | /dev/shm
|
As this machine has a younger uptime then the last installation, I have this following example from the support-ticket and shows that are installation exist after “/dev/shm”.
stat -c "%w | %n" /opt/dynatrace/oneagent/agent/bin/1.* /dev/shm|sort -n
2024-08-08 20:04:22.970465391 +0200 | /opt/dynatrace/oneagent/agent/bin/1.293.168.20240805-161707
2024-09-12 20:07:41.300161636 +0200 | /opt/dynatrace/oneagent/agent/bin/1.295.70.20240820-160945
2024-10-02 07:00:45.239424904 +0200 | /opt/dynatrace/oneagent/agent/bin/1.297.63.20240905-133818
2024-10-09 07:01:15.395335667 +0200 | /opt/dynatrace/oneagent/agent/bin/1.297.74.20240930-123813
2024-10-29 06:01:09.263204351 +0100 | /opt/dynatrace/oneagent/agent/bin/1.299.50.20240930-123825
2024-11-25 06:00:35.737849190 +0100 | /opt/dynatrace/oneagent/agent/bin/1.303.50.20241118-133432
2024-12-05 06:00:39.114198974 +0100 | /opt/dynatrace/oneagent/agent/bin/1.303.62.20241129-131342
2025-02-05 06:00:34.337497537 +0100 | /opt/dynatrace/oneagent/agent/bin/1.305.98.20250114-172617
2025-02-12 06:01:08.312319174 +0100 | /opt/dynatrace/oneagent/agent/bin/1.305.109.20250203-163926
2025-02-19 06:00:32.854178575 +0100 | /opt/dynatrace/oneagent/agent/bin/1.305.110.20250213-112827
2025-03-04 21:38:04.028000012 +0100 | /dev/shm
2025-03-12 06:00:24.400509625 +0100 | /opt/dynatrace/oneagent/agent/bin/1.307.61.20250226-155505
|
With following “one line command” you get all candidates to remove
Example with the “one line command”
stat -c "%w|%n" /opt/dynatrace/oneagent/agent/bin/1.* /dev/shm | sort -n | grep -B 20 /dev/shm|grep -v dev/shm | grep -v $(ls -l /opt/dynatrace/oneagent/agent/bin/current | sed s/".* "//g) | sed s/".*|"//g
/opt/dynatrace/oneagent/agent/bin/1.293.168.20240805-161707
/opt/dynatrace/oneagent/agent/bin/1.295.70.20240820-160945
/opt/dynatrace/oneagent/agent/bin/1.297.63.20240905-133818
/opt/dynatrace/oneagent/agent/bin/1.297.74.20240930-123813
/opt/dynatrace/oneagent/agent/bin/1.299.50.20240930-123825
/opt/dynatrace/oneagent/agent/bin/1.303.50.20241118-133432
/opt/dynatrace/oneagent/agent/bin/1.303.62.20241129-131342
/opt/dynatrace/oneagent/agent/bin/1.305.98.20250114-172617
/opt/dynatrace/oneagent/agent/bin/1.305.109.20250203-163926
/opt/dynatrace/oneagent/agent/bin/1.305.110.20250213-112827
|
We keept the current installation
The current installation is 1.307.61 and must be kept.
ls -l /opt/dynatrace/oneagent/agent/bin/current
lrwxrwxrwx. 1 root dtuser 24 Mar 12 06:00 /opt/dynatrace/oneagent/agent/bin/current -> 1.307.61.20250226-155505
|
It would be a strong benefit to implement this behavior.
Does it works also on inside of container with dynatrace-operator?
I try it inside an OpenShift Container. It works inside of the “/mnt/host_root” where the OA is running inside.
Additon Info for Dynatrace-Staff
For Dyntrace staff you see info in " https://one.dynatrace.com/hc/en-us/requests/460348 - How to reduce the number of kept old OneAgents - Re: OneAgents keeps older version with unnessary security concern and disc usage" which is is a follow up from https://one.dynatrace.com/hc/en-us/requests/392314
10 Likes