Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

rc: add osVersion, osKernel and osArch to core/version

Nick Craig-Wood4d19afdbbfbe
diff --git a/fs/rc/internal.go b/fs/rc/internal.go
index 36387806f..0fa82131b 100644
--- a/fs/rc/internal.go
+++ b/fs/rc/internal.go
@@ -170,17 +170,20 @@ func init() {
Add(Call{
Path: "core/version",
Fn: rcVersion,
- Title: "Shows the current version of rclone and the go runtime.",
+ Title: "Shows the current version of rclone, Go and the OS.",
Help: `
-This shows the current version of go and the go runtime:
+This shows the current versions of rclone, Go and the OS:
-- version - rclone version, e.g. "v1.53.0"
+- version - rclone version, e.g. "v1.71.2"
- decomposed - version number as [major, minor, patch]
- isGit - boolean - true if this was compiled from the git version
- isBeta - boolean - true if this is a beta version
-- os - OS in use as according to Go
-- arch - cpu architecture in use according to Go
-- goVersion - version of Go runtime in use
+- os - OS in use as according to Go GOOS (e.g. "linux")
+- osKernel - OS Kernel version (e.g. "6.8.0-86-generic (x86_64)")
+- osVersion - OS Version (e.g. "ubuntu 24.04 (64 bit)")
+- osArch - cpu architecture in use (e.g. "arm64 (ARMv8 compatible)")
+- arch - cpu architecture in use according to Go GOARCH (e.g. "arm64")
+- goVersion - version of Go runtime in use (e.g. "go1.25.0")
- linking - type of rclone executable (static or dynamic)
- goTags - space separated build tags or "none"
@@ -195,12 +198,22 @@ func rcVersion(ctx context.Context, in Params) (out Params, err error) {
return nil, err
}
linking, tagString := buildinfo.GetLinkingAndTags()
+ osVersion, osKernel := buildinfo.GetOSVersion()
+ if osVersion == "" {
+ osVersion = "unknown"
+ }
+ if osKernel == "" {
+ osKernel = "unknown"
+ }
out = Params{
"version": fs.Version,
"decomposed": version.Slice(),
"isGit": strings.HasSuffix(fs.Version, "-DEV"),
"isBeta": version.PreRelease != "",
"os": runtime.GOOS,
+ "osVersion": osVersion,
+ "osKernel": osKernel,
+ "osArch": buildinfo.GetArch(),
"arch": runtime.GOARCH,
"goVersion": runtime.Version(),
"linking": linking,
diff --git a/fs/rc/internal_test.go b/fs/rc/internal_test.go
index 1b9b13f57..2ef26c848 100644
--- a/fs/rc/internal_test.go
+++ b/fs/rc/internal_test.go
@@ -111,6 +111,9 @@ func TestCoreVersion(t *testing.T) {
assert.Equal(t, runtime.GOOS, out["os"])
assert.Equal(t, runtime.GOARCH, out["arch"])
assert.Equal(t, runtime.Version(), out["goVersion"])
+ assert.True(t, strings.HasPrefix(out["osArch"].(string), runtime.GOARCH))
+ assert.NotEqual(t, "", out["osVersion"].(string))
+ assert.NotEqual(t, "", out["osKernel"].(string))
_ = out["isGit"].(bool)
v := out["decomposed"].([]int64)
assert.True(t, len(v) >= 2)