shirou / gopsutil

psutil for golang
Other
10.47k stars 1.58k forks source link

Fetch stats from folder mounted volumes #1534

Open dloucasfx opened 11 months ago

dloucasfx commented 11 months ago

This fixes https://github.com/shirou/gopsutil/issues/1245 and https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/27203

The test from OpenTelemetry

Steps to reproduce

Before the fix:

Resource SchemaURL: https://opentelemetry.io/schemas/1.9.0
Resource attributes:
     -> host.name: Str(wintestswatsplunk)
     -> os.type: Str(windows)
     -> cloud.provider: Str(azure)
     -> cloud.platform: Str(azure_vm)
     -> cloud.region: Str(eastus)
     -> host.id: Str(09f0d80d-d5a7-4082-953a-bfd10cb77cbf)
     -> cloud.account.id: Str(5db89e2c-2127-4418-9a31-dac67b04e87b)
     -> azure.vm.name: Str(win2016-swat-2021)
     -> azure.vm.size: Str(Standard_D2as_v4)
     -> azure.vm.scaleset.name: Str()
     -> azure.resourcegroup.name: Str(win2016-swat)
ScopeMetrics #0
ScopeMetrics SchemaURL:
InstrumentationScope otelcol/hostmetricsreceiver/filesystem 0.85.0-dev
Metric #0
Descriptor:
     -> Name: system.filesystem.usage
     -> Description: Filesystem bytes used.
     -> Unit: By
     -> DataType: Sum
     -> IsMonotonic: false
     -> AggregationTemporality: Cumulative
NumberDataPoints #0
Data point attributes:
     -> device: Str(C:)
     -> mode: Str(rw)
     -> mountpoint: Str(C:)
     -> type: Str(NTFS)
     -> state: Str(used)
StartTimestamp: 2023-09-26 14:11:00 +0000 UTC
Timestamp: 2023-10-03 21:22:58.5265249 +0000 UTC
Value: 19619004416
NumberDataPoints #1
Data point attributes:
     -> device: Str(C:)
     -> mode: Str(rw)
     -> mountpoint: Str(C:)
     -> type: Str(NTFS)
     -> state: Str(free)
StartTimestamp: 2023-09-26 14:11:00 +0000 UTC
Timestamp: 2023-10-03 21:22:58.5265249 +0000 UTC
Value: 116220866560
NumberDataPoints #2
Data point attributes:
     -> device: Str(D:)
     -> mode: Str(rw)
     -> mountpoint: Str(D:)
     -> type: Str(NTFS)
     -> state: Str(used)
StartTimestamp: 2023-09-26 14:11:00 +0000 UTC
Timestamp: 2023-10-03 21:22:58.5265249 +0000 UTC
Value: 1418309632
NumberDataPoints #3
Data point attributes:
     -> device: Str(D:)
     -> mode: Str(rw)
     -> mountpoint: Str(D:)
     -> type: Str(NTFS)
     -> state: Str(free)
StartTimestamp: 2023-09-26 14:11:00 +0000 UTC
Timestamp: 2023-10-03 21:22:58.5265249 +0000 UTC
Value: 15759458304

With the fix, notice the folder mounted volumes stats C:\mount4 :

2023-10-03T21:14:24.922Z        info    ResourceMetrics #0
Resource SchemaURL: https://opentelemetry.io/schemas/1.9.0
Resource attributes:
     -> host.name: Str(wintestswatsplunk)
     -> os.type: Str(windows)
     -> cloud.provider: Str(azure)
     -> cloud.platform: Str(azure_vm)
     -> cloud.region: Str(eastus)
     -> host.id: Str(09f0d80d-d5a7-4082-953a-bfd10cb77cbf)
     -> cloud.account.id: Str(5db89e2c-2127-4418-9a31-dac67b04e87b)
     -> azure.vm.name: Str(win2016-swat-2021)
     -> azure.vm.size: Str(Standard_D2as_v4)
     -> azure.vm.scaleset.name: Str()
     -> azure.resourcegroup.name: Str(win2016-swat)
ScopeMetrics #0
ScopeMetrics SchemaURL:
InstrumentationScope otelcol/hostmetricsreceiver/filesystem 0.85.0-dev
Metric #0
Descriptor:
     -> Name: system.filesystem.usage
     -> Description: Filesystem bytes used.
     -> Unit: By
     -> DataType: Sum
     -> IsMonotonic: false
     -> AggregationTemporality: Cumulative
NumberDataPoints #0
Data point attributes:
     -> device: Str(D:)
     -> mode: Str(rw)
     -> mountpoint: Str(D:)
     -> type: Str(NTFS)
     -> state: Str(used)
StartTimestamp: 2023-09-26 14:11:00 +0000 UTC
Timestamp: 2023-10-03 21:14:24.795121 +0000 UTC
Value: 1418309632
NumberDataPoints #1
Data point attributes:
     -> device: Str(D:)
     -> mode: Str(rw)
     -> mountpoint: Str(D:)
     -> type: Str(NTFS)
     -> state: Str(free)
StartTimestamp: 2023-09-26 14:11:00 +0000 UTC
Timestamp: 2023-10-03 21:14:24.795121 +0000 UTC
Value: 15759458304
NumberDataPoints #2
Data point attributes:
     -> device: Str(C:\mount4)
     -> mode: Str(rw)
     -> mountpoint: Str(C:\mount4)
     -> type: Str(NTFS)
     -> state: Str(used)
StartTimestamp: 2023-09-26 14:11:00 +0000 UTC
Timestamp: 2023-10-03 21:14:24.795121 +0000 UTC
Value: 189624320
NumberDataPoints #3
Data point attributes:
     -> device: Str(C:\mount4)
     -> mode: Str(rw)
     -> mountpoint: Str(C:\mount4)
     -> type: Str(NTFS)
     -> state: Str(free)
StartTimestamp: 2023-09-26 14:11:00 +0000 UTC
Timestamp: 2023-10-03 21:14:24.795121 +0000 UTC
Value: 4102193152
NumberDataPoints #4
Data point attributes:
     -> device: Str(C:)
     -> mode: Str(rw)
     -> mountpoint: Str(C:)
     -> type: Str(NTFS)
     -> state: Str(used)
StartTimestamp: 2023-09-26 14:11:00 +0000 UTC
Timestamp: 2023-10-03 21:14:24.795121 +0000 UTC
Value: 19642892288
NumberDataPoints #5
Data point attributes:
     -> device: Str(C:)
     -> mode: Str(rw)
     -> mountpoint: Str(C:)
     -> type: Str(NTFS)
     -> state: Str(free)
StartTimestamp: 2023-09-26 14:11:00 +0000 UTC
Timestamp: 2023-10-03 21:14:24.795121 +0000 UTC
Value: 116196978688
        {"kind": "exporter", "data_type": "metrics", "name": "logging"}
dloucasfx commented 8 months ago

Updated the PR with the requested changes

atoulme commented 7 months ago

@shirou would you please take a look?