1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-04-24 13:48:56 +08:00

82 Commits

Author SHA1 Message Date
shirou
bc060cc227 add SPDX License, remove old build tag, and replace import 2024-05-28 22:27:17 +09:00
shirou
ce11e9ca5f [linux][disk]: fix Rdev cast 2024-01-01 22:07:23 +09:00
Ville Skyttä
adaeba09d9 feat(disk): look for filesystem labels from udev on Linux 2023-12-25 12:07:23 +02:00
shirou
0665cafa1b chore: replace deprecated ioutil package to os and io 2023-09-08 17:05:14 +00:00
Greg Dallavalle
0a23dc690f comment cleanup 2023-08-18 09:17:37 -05:00
Greg Dallavalle
b2d1f05f08 update comment 2023-08-17 09:38:49 -05:00
Greg
aa4c84c6b3
Update disk/disk_linux.go
Co-authored-by: shirou <shirou.faw@gmail.com>
2023-08-17 09:37:46 -05:00
Greg Dallavalle
0ca6266393 fix IOCounters() SerialNumber enumeration 2023-08-16 21:36:08 -05:00
Antoine Toulme
38b94668ea allow to pass context values to override environment variables 2023-06-02 01:31:05 -07:00
Matthieu MOREL
1fb1e3e3e6 ci(lint): correct gci linter
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2023-04-04 18:07:22 +00:00
Josh Powers
7645051510
fix(disk): correctly replace /dev in /dev/mapper
Only replace the first instance of /dev in a /dev/mapper string.
Otherwise, if an LVM group is named dev it will replace that as well.

fixes: #1411
2023-02-01 08:26:10 -07:00
arstercz
f6dc96c30e follow the psutil principles, do nothing if can not find root device 2022-05-01 02:33:09 +00:00
arstercz
d52b97cd25 fix disk readlink error which system boot by nfs mount 2022-04-27 04:46:02 +00:00
Jamie Strandboge
9e6e627ec8 [disk][linux] add HOST_PROC_MOUNTINFO, closes #1271
The changes to gopsutil for reading /proc/1/mountinfo affected
applications running under restricted environments that disallows access
to /proc/1/mountinfo. #1159 was filed for android but other restricted
environments are also affected (eg, snaps)). The fix for #1159 addressed
the application behavior to work under confinement for non-android as
well. However, depending on the system, the attempt to read
/proc/1/mountinfo could cause a sandbox denial in the logs which can be
quite noisy if using gopsutil as part of a monitoring solution that
polls often.

This introduces HOST_PROC_MOUNTINFO to force reading from the parent dir
of the specified path instead of first trying /proc/1. When unset,
retain the current behavior with fallback. This allows people, for
example, to set HOST_PROC_MOUNTINFO=/proc/self/mountinfo when gopsutil
is running under these restricted environments.

This change updates the private readMountFile() to use a root path
instead of a root subpath, and adjusts PartitionsWithContext() to set
the root path to /proc/1 initially and falling back to /proc/self. When
HOST_PROC_MOUNTINFO is not empty, set the root path to the parent
directory of HOST_PROC_MOUNTINFO.
2022-03-29 08:20:28 -05:00
Ville Skyttä
5095c3f51e [disk][linux] recognize more file systems 2022-03-19 22:34:13 +02:00
shirou
49037dd0d8 [disk][linux] add fallback to /proc/self 2022-03-05 03:15:26 +00:00
Matthieu MOREL
4671e649aa
enable revive linter 2021-12-22 23:49:50 +01:00
mmorel-35
1e6b445a8a gofumpt 2021-12-22 21:54:41 +00:00
Matthieu MOREL
b673968d5d
enable errorlint linter 2021-12-04 22:29:38 +01:00
shirou
d2e27c1712 fix dependabot v2 deletion. 2021-12-01 00:12:55 +00:00
shirou
0969c9436b delete v2 directory, move v3 to top #1078 2021-11-30 23:47:59 +00:00
shirou
b39f8bb90e
[v2][disk][linux] apply DiskPartiton change to v2 2021-09-30 21:42:30 +09:00
shirou
1f733a99dc [disk] move without context functions to disk.go. 2020-10-24 22:03:58 +09:00
Aman Karmani
23d63601d1 [disk][linux] flag bind mounts 2020-10-07 11:01:01 -07:00
Ilya Prudnikov
256e00319e implement proposed solution 2020-01-20 20:13:45 +02:00
Ilya Prudnikov
7277cdf050 Fix for track disk stats when running in container 2020-01-17 11:09:10 +02:00
Lomanic
e4ec7b275a [disk][linux] Fix #555 for kernels >=2.6.26 2019-09-01 13:12:13 +02:00
Aman Gupta
74d3cea10f Proper fix for unavailable /proc/filesystems 2019-08-12 18:33:25 -07:00
John Floren
93e08ea089 Fixes a problem when using Docker on a host with an encrypted LLVM root. A docker container with a volume mounted from the host will see /dev/mapper in its mount info file, but will not be able to read it. 2019-08-05 14:01:19 -06:00
eshimizu
91b1c81467
Update disk_linux.go 2019-07-31 22:33:57 +09:00
Aman Gupta
34b030b41c
Ignore getFileSystems errors when requesting all partitions 2019-07-30 17:59:09 -07:00
Aman Gupta
ea0f864aef ignore /proc/filesystems errors on android 2019-07-22 13:09:37 -07:00
Tony Lambiris
80ceab90aa
Add support for hfsplus file system 2019-07-06 08:33:10 -04:00
Lomanic
d7405fd873 [disk][linux] Follow symlinks with filepath.EvalSymlinks for LVM volumes
See #686
2019-06-23 17:38:42 +02:00
Tony Lambiris
8037dc42c8
Add a check for logical volume paths 2019-05-13 15:51:20 -04:00
Lomanic
368a865910 [disk][linux] Fix comment in PartitionsWithContext 2019-02-22 19:41:13 +01:00
Lomanic
0d3a2ac515
[disk][linux] Fix comment in PartitionsWithContext 2019-02-22 19:31:08 +01:00
JHE
a08b926ce6 It could be another error than the "self/mountinfo" missing 2019-02-10 00:01:25 +08:00
JHE
06a21ae66a Fix some issue. 2019-02-07 00:01:51 +08:00
JHE
a5cb715e64 if mountinfo not found, use mounts 2019-02-05 23:30:19 +08:00
JHE
d141349619 if mountinfo not found, use mounts 2019-02-05 21:23:46 +08:00
JHE
a45f6d8a03 if mountinfo not found, use mounts 2019-02-05 21:06:23 +08:00
Nico Vinzens
1a7a39a789
Merge branch 'master' into master 2019-01-14 09:53:05 +01:00
Remy Mathieu
fda98ebc34 disk: trim the device mapper name.
While reading the value of the file with `ioutil.ReadFile`,
the name is suffixed with a `\n`

Tested on Ubuntu 18.10
2018-12-17 10:59:17 +01:00
Lomanic
8888537497 [disk][linux] Fix #555 Unescape escaped sequences in fstab path in disk.Partitions 2018-11-18 20:39:18 +01:00
Nico Vinzens
1079f31626 change the way we handle the mountinfo lines 2018-10-18 09:34:06 +02:00
Nico Vinzens
23dfe98621 use HostSys to construct device path 2018-10-17 14:45:40 +02:00
Nico Vinzens
813c630e9c replace self/mounts with self/mountinfo 2018-10-17 13:46:49 +02:00
Jaime Soriano Pastor
61902bc2a5 Use HOST_* environment variables for getting disk serial number in Linux 2018-07-02 10:04:57 +02:00
shirou
d813235a11 disk[linux]: cast uint64 for build on MIPS
related: #533
2018-06-12 22:59:43 +09:00