How to identify the Java version used by Bamboo agents from Bamboo Data center server logs

Still need help?

The Atlassian Community is here for you.

Ask the community


Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.

Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

The steps outlined on this article are provided AS-IS. This means we've had reports of them working for some customers — under certain circumstances — yet are not officially supported, nor can we guarantee they'll work for your specific scenario.

You may follow through and validate them on your own non-prod environments prior to production or fall back to supported alternatives if they don't work out.

We also invite you to reach out to our Community for matters that fall beyond Atlassian's scope of support!

Summary

Bamboo agents require Java to be installed on their host machines. In some cases, Bamboo supports multiple versions of Java, which may be used across different agents. It's essential to track the version of Java currently used by each Bamboo agent, especially in the following scenarios:

  1. Large-scale Bamboo Deployments: In environments with a large number of Bamboo agents, manually tracking which Java version is installed on each host can become challenging. Centralized tracking of Java versions simplifies management and ensures consistency across agents.

  2. Bamboo Upgrades: When upgrading Bamboo, it's crucial to know which agents are using outdated Java versions. Identifying these agents in advance allows for timely updates to the required Java version, ensuring compatibility with the latest Bamboo release and minimizing potential issues.

Environment

  • The solution was tested on Bamboo 9.6.8, but it will be applicable to other supported versions as well.

Solution

When a Bamboo agent is installed or restarted, an entry is logged in the Bamboo Tomcat access logs (<bamboo-install-dir>/logs) for the endpoint /agentServer/GetFingerprint.action. This endpoint is used by Bamboo agent to retrieve important information such as the Broker Client URL, Bamboo Fingerprint, Heartbeat configuration, and the Broker SSL certificate (if SSL is enabled).

As part of the log entry, the Java version being used by the Bamboo agent is also recorded. This provides a reliable method for determining the exact Java version in use by the agent.

To get the details, Below shell script can be executed on the Bamboo Server side by replacing <bamboo-install-dir> with the Bamboo installation directory path.

Shell script to detect the Java version used by Bamboo agents
#!/bin/bash

# Update the Bamboo installation directory
log_dir="<bamboo-install-dir>/logs"

printf "%-25s %-15s %-50s %-50s %-10s %-15s\n" "Timestamp" "IP Address" "Host Name" "Agent UUID" "Agent ID" "Java Version"
echo "--------------------------------------------------------------------------------------------------------------"

for log_file in "$log_dir"/access_log.*; do
  while IFS= read -r log_entry; do
    if echo "$log_entry" | grep -q "agentServer/GetFingerprint.action"; then
      timestamp=$(echo "$log_entry" | grep -oP '(?<=\[).+?(?=\])')
      ip_address=$(echo "$log_entry" | grep -oP '(?<=\s)[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+')
      host_name=$(echo "$log_entry" | grep -oP '(?<=hostName=)[^&]+')
      agent_uuid=$(echo "$log_entry" | grep -oP '(?<=agentUuid=)[a-f0-9\-]+')
      agent_id=$(echo "$log_entry" | grep -oP '(?<=agentId=)[0-9]+')
      java_version=$(echo "$log_entry" | grep -oP '(?<=Java\/)[^)]+')

      printf "%-25s %-15s %-50s %-50s %-10s %-15s\n" "$timestamp" "$ip_address" "$host_name" "$agent_uuid" "$agent_id" "$java_version"
    fi
  done < "$log_file"
done
Sample log entries from <BAMBOO_INSTALL>/log/access_log files
"-" 10.229.31.10 [10/Dec/2024:06:03:51 +0000] "GET /agentServer/GetFingerprint.action?hostName=BAMAGNT1&version=5&agentUuid=998067da-bf59-4f62-b47a-0ae3e6a00f24 HTTP/1.1" 200 1091 183 "-" "Apache-HttpClient/4.5.14 (Java/17.0.12)"
"-" 10.229.31.241 [10/Dec/2024:06:06:33 +0000] "GET /agentServer/GetFingerprint.action?hostName=BAMAGNT2&version=5&agentUuid=77f9ff5f-cba6-4923-b91a-422011fb3aef HTTP/1.1" 200 1091 7 "-" "Apache-HttpClient/4.5.14 (Java/11.0.15)"
"-" 10.229.31.10 [10/Dec/2024:23:21:36 +0000] "GET /agentServer/GetFingerprint.action?hostName=BAMAGNT1&version=5&agentUuid=998067da-bf59-4f62-b47a-0ae3e6a00f24&agentId=589825 HTTP/1.1" 200 1089 158 "-" "Apache-HttpClient/4.5.14 (Java/17.0.12)"
"-" 10.229.31.241 [10/Dec/2024:23:23:18 +0000] "GET /agentServer/GetFingerprint.action?hostName=BAMAGNT2&version=5&agentUuid=77f9ff5f-cba6-4923-b91a-422011fb3aef&agentId=589826 HTTP/1.1" 200 1089 10 "-" "Apache-HttpClient/4.5.14 (Java/11.0.15)"
"-" 10.229.31.10 [18/Dec/2024:23:58:06 +0000] "GET /agentServer/GetFingerprint.action?hostName=BAMAGNT1&version=5&agentUuid=998067da-bf59-4f62-b47a-0ae3e6a00f24&agentId=589825 HTTP/1.1" 200 1091 302 "-" "Apache-HttpClient/4.5.14 (Java/11.0.15)"
"-" 10.229.31.241 [19/Dec/2024:00:01:58 +0000] "GET /agentServer/GetFingerprint.action?hostName=BAMAGNT2&version=5&agentUuid=77f9ff5f-cba6-4923-b91a-422011fb3aef&agentId=589826 HTTP/1.1" 200 1091 16 "-" "Apache-HttpClient/4.5.14 (Java/17.0.12)"
"-" 10.229.31.241 [20/Dec/2024:01:23:48 +0000] "GET /agentServer/GetFingerprint.action?hostName=BAMAGNT2&version=5&agentUuid=0d4d2a15-a05d-45a7-a707-d42b8372fe37 HTTP/1.1" 200 1091 207 "-" "Apache-HttpClient/4.5.14 (Java/11.0.15)"
"-" 10.229.31.10 [21/Dec/2024:07:14:42 +0000] "GET /agentServer/GetFingerprint.action?hostName=BAMAGNT1&version=5&agentUuid=a6c8db7b-849f-45b2-aec3-33bfa123b4a2&agentId=589827 HTTP/1.1" 200 1091 150 "-" "Apache-HttpClient/4.5.14 (Java/17.0.12)"
"-" 10.229.31.101 [21/Dec/2024:07:18:50 +0000] "GET /agentServer/GetFingerprint.action?hostName=BAMAGNT3&version=5&agentUuid=eb38c4b1-b9a1-47f5-b03a-35a5fc8719b1&agentId=589828 HTTP/1.1" 200 1091 225 "-" "Apache-HttpClient/4.5.14 (Java/11.0.15)"
"-" 10.229.31.12 [22/Dec/2024:10:45:05 +0000] "GET /agentServer/GetFingerprint.action?hostName=BAMAGNT3&version=5&agentUuid=cd4582fe-9307-4e04-a354-674dbd8c90f1&agentId=589829 HTTP/1.1" 200 1091 275 "-" "Apache-HttpClient/4.5.14 (Java/17.0.12)"
sample output from the Script
Timestamp                 IP Address      Host Name          Agent UUID                                         Agent ID   Java Version
---------------------------------------------------------------------------------------------------------------------------------------
10/Dec/2024:06:03:51 +0000 10.229.31.10    BAMAGNT1          998067da-bf59-4f62-b47a-0ae3e6a00f24               N/A        17.0.12
10/Dec/2024:06:06:33 +0000 10.229.31.241   BAMAGNT2          77f9ff5f-cba6-4923-b91a-422011fb3aef               N/A        11.0.15
10/Dec/2024:23:21:36 +0000 10.229.31.10    BAMAGNT1          998067da-bf59-4f62-b47a-0ae3e6a00f24               589825     17.0.12
10/Dec/2024:23:23:18 +0000 10.229.31.241   BAMAGNT2          77f9ff5f-cba6-4923-b91a-422011fb3aef               589826     11.0.15
18/Dec/2024:23:58:06 +0000 10.229.31.10    BAMAGNT1          998067da-bf59-4f62-b47a-0ae3e6a00f24               589825     11.0.15
19/Dec/2024:00:01:58 +0000 10.229.31.241   BAMAGNT2          77f9ff5f-cba6-4923-b91a-422011fb3aef               589826     17.0.12
20/Dec/2024:01:23:48 +0000 10.229.31.241   BAMAGNT2          0d4d2a15-a05d-45a7-a707-d42b8372fe37               N/A        11.0.15
21/Dec/2024:07:14:42 +0000 10.229.31.10    BAMAGNT1          a6c8db7b-849f-45b2-aec3-33bfa123b4a2               589827     17.0.12
21/Dec/2024:07:18:50 +0000 10.229.31.101   BAMAGNT3          eb38c4b1-b9a1-47f5-b03a-35a5fc8719b1               589828     11.0.15
22/Dec/2024:10:45:05 +0000 10.229.31.12    BAMAGNT3          cd4582fe-9307-4e04-a354-674dbd8c90f1               589829     17.0.12         

Please be aware of below limitations:

  • This may not include all the agent information if Bamboo or the Bamboo agents were not restarted during the period when the logs are available. In such cases, the only way to retrieve complete agent information is by restarting Bamboo, which will trigger all the agents to reconnect and send their fingerprints to the Bamboo server.

  • If the agent ID is N/A, it means the agent was just installed, and the agent ID will be displayed after the next restart.
  • If the output contains duplicate records, please use the Java version from the most recent record.
  • If multiple agents are installed on the same host, it can be difficult to identify a specific agent based solely on the agent ID. To retrieve the user-friendly name (as displayed in the Bamboo UI) of a Bamboo agent, you can use the following methods. If any of these methods do not work, it might indicate that the agent has been deleted, and the logs could be showing data from a previously existing agent.

    • Below query can be executed on the database by passing the <AGENT_ID> seen in the earlier output

SELECT TITLE FROM QUEUE WHERE QUEUE_ID = <AGENT_ID>;
    • or by navigating to the URL <bamboo-base-url>/admin/agent/viewAgent.action?agentId=<AGENT_ID>. Replace <AGENT_ID> with the value seen in the earlier output and <bamboo-base-url> with the Bamboo base URL.
Last modified on Dec 27, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.