Skip to content

script: allow collecting management server and kvm agent logs - #13982

Draft
shwstppr wants to merge 2 commits into
apache:mainfrom
shwstppr:script-log-collect
Draft

script: allow collecting management server and kvm agent logs#13982
shwstppr wants to merge 2 commits into
apache:mainfrom
shwstppr:script-log-collect

Conversation

@shwstppr

@shwstppr shwstppr commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Description

Adds a utility script to collect CloudStack logs for troubleshooting.

  • Collects management server and KVM agent logs.
  • Supports collecting logs for a specific date.
  • Discovers management servers and KVM hosts using CloudMonkey, with database fallback.
  • Supports limiting collection to specified KVM hosts.
  • Packages collected logs into a compressed archive.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

[root@qa1-boot-group-42c4c4a3-kvm-mgmt1 ~]# ./cloudstack-collect-logs.sh 
[2026-09-01 12:12:22] Running on CloudStack management server
[2026-09-01 12:12:22] Trying discovery using cmk
[2026-09-01 12:12:23] Discovery method: cloudmonkey
[2026-09-01 12:12:23] Management servers: 1
[2026-09-01 12:12:23] KVM hosts: 2
[2026-09-01 12:12:23] Collecting management log from 172.120.0.219
[2026-09-01 12:12:23] Collecting agent log from 172.120.0.209
[2026-09-01 12:12:23] Collecting agent log from 172.120.0.81
[2026-09-01 12:12:23] Creating archive /tmp/cloudstack-logs-20260901-121222.tar.gz

CloudStack logs collected:
  /tmp/cloudstack-logs-20260901-121222.tar.gz

[root@qa1-boot-group-42c4c4a3-kvm-mgmt1 ~]# ll /var/log/cloudstack/management
total 335488
-rw-r--r--. 1 cloud cloud 10226776 Sep  1 12:12 access.log
-rw-r--r--. 1 cloud cloud  4333094 Sep  1 12:12 apilog.log
-rw-r--r--. 1 cloud cloud   672705 Aug 25 00:00 apilog.log.2026-08-24.gz
-rw-r--r--. 1 cloud cloud  1000905 Aug 26 00:00 apilog.log.2026-08-25.gz
-rw-r--r--. 1 cloud cloud  4522990 Aug 27 04:50 apilog.log.2026-08-26.gz
-rw-r--r--. 1 cloud cloud  6244704 Sep  1 05:49 apilog.log.2026-08-27.gz
-rw-r--r--. 1 root  root      3150 Sep  1 05:45 management-server.err
-rw-r--r--. 1 cloud cloud 42891155 Sep  1 12:13 management-server.log
-rw-r--r--. 1 cloud cloud  4646445 Aug 22 00:00 management-server.log.2026-08-21.gz
-rw-r--r--. 1 cloud cloud  7456807 Aug 23 00:00 management-server.log.2026-08-22.gz
-rw-r--r--. 1 cloud cloud  7466217 Aug 24 00:00 management-server.log.2026-08-23.gz
-rw-r--r--. 1 cloud cloud 10246906 Aug 25 00:00 management-server.log.2026-08-24.gz
-rw-r--r--. 1 cloud cloud 12118086 Aug 26 00:00 management-server.log.2026-08-25.gz
-rw-r--r--. 1 cloud cloud  6128227 Aug 27 00:00 management-server.log.2026-08-26.gz
-rw-r--r--. 1 cloud cloud 23790223 Aug 26 04:56 management-server.log-20260826T102640
-rw-r--r--. 1 cloud cloud  3765908 Aug 26 05:18 management-server.log-20260826T104801
-rw-r--r--. 1 cloud cloud  2471432 Aug 26 05:26 management-server.log-20260826T105638
-rw-r--r--. 1 cloud cloud  1959476 Aug 26 05:32 management-server.log-20260826T110251
-rw-r--r--. 1 cloud cloud 34320478 Aug 26 10:51 management-server.log-20260826T162104
-rw-r--r--. 1 cloud cloud  7064857 Aug 26 11:33 management-server.log-20260826T170303
-rw-r--r--. 1 cloud cloud   194743 Sep  1 05:42 management-server.log.2026-08-27.gz
-rw-r--r--. 1 cloud cloud 36588815 Aug 27 07:31 management-server.log-20260827T130134
-rw-r--r--. 1 cloud cloud 12043292 Aug 27 08:45 management-server.log-20260827T141514
-rw-r--r--. 1 cloud cloud  7729246 Aug 27 09:47 management-server.log-20260827T151716
-rw-r--r--. 1 cloud cloud 26016336 Aug 27 11:28 management-server.log-20260827T165847
-rw-r--r--. 1 cloud cloud 48051374 Aug 27 19:21 management-server.log-20260828T005153
-rw-r--r--. 1 cloud cloud  1557391 Sep  1 05:44 management-server.log-20260901T111453
-rw-r--r--. 1 root  root   3811034 Sep  1 12:08 management-server.out
-rw-r--r--. 1 root  root       734 Aug 21 10:01 setupManagement.log
[root@qa1-boot-group-42c4c4a3-kvm-mgmt1 ~]# ./cloudstack-collect-logs.sh --date 2026-08-24
[2026-09-01 12:15:29] Running on CloudStack management server
[2026-09-01 12:15:29] Trying discovery using cmk
[2026-09-01 12:15:29] Discovery method: cloudmonkey
[2026-09-01 12:15:29] Management servers: 1
[2026-09-01 12:15:29] KVM hosts: 2
[2026-09-01 12:15:29] Collecting management log from 172.120.0.219
[2026-09-01 12:15:31] Collecting agent log from 172.120.0.209
[2026-09-01 12:15:31] Collecting agent log from 172.120.0.81
[2026-09-01 12:15:31] Creating archive /tmp/cloudstack-logs-2026-08-24.tar.gz

CloudStack logs collected:
  /tmp/cloudstack-logs-2026-08-24.tar.gz

How did you try to break this feature and the system with this change?

Adds a utility script to collect CloudStack logs for troubleshooting.

* Collects management server and KVM agent logs.
* Supports collecting logs for a specific date.
* Discovers management servers and KVM hosts using CloudMonkey, with database fallback.
* Supports limiting collection to specified KVM hosts.
* Packages collected logs into a compressed archive.

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Copilot AI lite review requested due to automatic review settings August 26, 2026 12:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new troubleshooting utility script to collect Apache CloudStack management server and KVM agent logs, optionally filtered to a specific date and/or a subset of KVM hosts, and packages the results into a tarball.

Changes:

  • Introduces cloudstack-collect-logs.sh to detect node type (management vs KVM) and collect the relevant logs.
  • Implements discovery of management servers and KVM hosts via CloudMonkey (with jq), with a MySQL/database fallback via db.properties.
  • Supports date-scoped extraction across rotated logs and produces a compressed archive with a small info.txt manifest.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +23 to +26
SSH_USER="${SSH_USER:-root}"
REQUESTED_HOSTS=()
SSH_OPTS="${SSH_OPTS:--o BatchMode=yes -o ConnectTimeout=10 -o StrictHostKeyChecking=no}"

Comment on lines +333 to +343
get_property() {
local property="$1"

awk -F= -v property="$property" '
$1 == property {
sub(/^[^=]*=/, "")
print
exit
}
' "$DB_PROPERTIES"
}
Comment thread scripts/util/cloudstack-collect-logs.sh Outdated
Comment thread scripts/util/cloudstack-collect-logs.sh Outdated
Comment thread scripts/util/cloudstack-collect-logs.sh Outdated
@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 19.74%. Comparing base (158fe4f) to head (ea638d3).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #13982      +/-   ##
============================================
- Coverage     19.74%   19.74%   -0.01%     
+ Complexity    19960    19959       -1     
============================================
  Files          6371     6371              
  Lines        575784   575784              
  Branches      70478    70478              
============================================
- Hits         113665   113660       -5     
- Misses       449765   449772       +7     
+ Partials      12354    12352       -2     
Flag Coverage Δ
uitests 3.41% <ø> (ø)
unittests 21.02% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DaanHoogland DaanHoogland moved this from Backlog to conflict/waiting for author in CloudStack Testing Aug 31, 2026
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@shwstppr

shwstppr commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@shwstppr a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 19054

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: conflict/waiting

Development

Successfully merging this pull request may close these issues.

4 participants