[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-4988":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":15,"forks30d":15,"starsTrendScore":19,"compositeScore":20,"rankGlobal":9,"rankLanguage":9,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":24,"hasPages":22,"topics":25,"createdAt":9,"pushedAt":9,"updatedAt":29,"readmeContent":30,"aiSummary":31,"trendingCount":15,"starSnapshotCount":15,"syncStatus":32,"lastSyncTime":33,"discoverSource":34},4988,"gopsutil","shirou\u002Fgopsutil","shirou","psutil for golang",null,"Go",11863,1671,209,166,0,1,11,46,5,44.67,"Other",false,"master",true,[26,27,28],"go","golang","system-information","2026-06-12 02:01:06","# gopsutil: psutil for Go\n\n[![Test](https:\u002F\u002Fgithub.com\u002Fshirou\u002Fgopsutil\u002Factions\u002Fworkflows\u002Ftest.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fshirou\u002Fgopsutil\u002Factions\u002Fworkflows\u002Ftest.yml) [![Go Reference](https:\u002F\u002Fpkg.go.dev\u002Fbadge\u002Fgithub.com\u002Fshirou\u002Fgopsutil\u002Fv4.svg)](https:\u002F\u002Fpkg.go.dev\u002Fgithub.com\u002Fshirou\u002Fgopsutil\u002Fv4) [![Calendar Versioning](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fcalver-vMAJOR.YY.MM-22bfda.svg)](https:\u002F\u002Fcalver.org\u002F)\n\nThis is a port of psutil (https:\u002F\u002Fgithub.com\u002Fgiampaolo\u002Fpsutil). The\nchallenge is porting all psutil functions on some architectures.\n\n## migration\n\n### v4 migration\n\nThere are some breaking changes. Please see [v4 release note](https:\u002F\u002Fgithub.com\u002Fshirou\u002Fgopsutil\u002Freleases\u002Ftag\u002Fv4.24.5).\n\n## Tag semantics\n\ngopsutil tag policy is almost same as Semantic Versioning, but\nautomatically increases like [Ubuntu versioning](https:\u002F\u002Fcalver.org\u002F).\n\nFor example, v4.24.04 means\n\n- v4: major version\n- 24: release year, 2024\n- 04: release month\n\ngopsutil aims to keep backwards compatibility until major version change.\n\nTagged at every end of month, but if there are only a few commits, it\ncan be skipped.\n\n## Available Architectures\n\n- FreeBSD i386\u002Famd64\u002Farm\n- Linux i386\u002Famd64\u002Farm(raspberry pi)\n- Windows i386\u002Famd64\u002Farm\u002Farm64\n- Darwin amd64\u002Farm64\n- OpenBSD i386\u002Famd64\u002Farmv7\u002Farm64\u002Friscv64 (Thank you @mpfz0r!)\n- Solaris amd64 (developed and tested on SmartOS\u002FIllumos, Thank you @jen20!)\n\nThese have partial support:\n\n- CPU on DragonFly BSD (#893, Thank you @gballet!)\n- host on Linux RISC-V (#896, Thank you @tklauser!)\n\nAll works are implemented without cgo by porting C structs to Go structs.\n\n## Usage\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n\n    \"github.com\u002Fshirou\u002Fgopsutil\u002Fv4\u002Fmem\"\n)\n\nfunc main() {\n    v, _ := mem.VirtualMemory()\n\n    \u002F\u002F almost every return value is a struct\n    fmt.Printf(\"Total: %v, Free:%v, UsedPercent:%f%%\\n\", v.Total, v.Free, v.UsedPercent)\n\n    \u002F\u002F convert to JSON. String() is also implemented\n    fmt.Println(v)\n}\n```\n\nThe output is below.\n\n    Total: 3179569152, Free:284233728, UsedPercent:84.508194%\n    {\"total\":3179569152,\"available\":492572672,\"used\":2895335424,\"usedPercent\":84.50819439828305, (snip...)}\n\nYou can set alternative locations for various system directories by using the following environment variables:\n\n- \u002Fproc: `HOST_PROC`\n- \u002Fsys: `HOST_SYS`\n- \u002Fetc: `HOST_ETC`\n- \u002Fvar: `HOST_VAR`\n- \u002Frun: `HOST_RUN`\n- \u002Fdev: `HOST_DEV`\n- \u002F: `HOST_ROOT`\n- \u002Fproc\u002FN\u002Fmountinfo: `HOST_PROC_MOUNTINFO`\n\n### Adding settings using `context` (from v3.23.6)\n\nAs of v3.23.6, it is now possible to pass a path location using `context`: import `\"github.com\u002Fshirou\u002Fgopsutil\u002Fv3\u002Fcommon\"` and pass a context with `common.EnvMap` set to `common.EnvKey`, and the location will be used within each function.\n\n```\n\tctx := context.WithValue(context.Background(), \n\t\tcommon.EnvKey, common.EnvMap{common.HostProcEnvKey: \"\u002Fmyproc\"},\n\t)\n\tv, err := mem.VirtualMemoryWithContext(ctx)\n```\n\nFirst priority is given to the value set in `context`, then the value from the environment variable, and finally the default location.\n\n### Caching\n\nAs of v3.24.1, it is now possible to cached some values. These values default to false, not cached. \n\nBe very careful that enabling the cache may cause inconsistencies. For example, if you enable caching of boottime on Linux, be aware that unintended values may be returned if [the boottime is changed by NTP after booted](https:\u002F\u002Fgithub.com\u002Fshirou\u002Fgopsutil\u002Fissues\u002F1070#issuecomment-842512782).\n\n- `host`\n  - EnableBootTimeCache\n- `process`\n  - EnableBootTimeCache\n\n### `Ex` struct (from v4.24.5)\n\ngopsutil is designed to work across multiple platforms. However, there are differences in the information available on different platforms, such as memory information that exists on Linux but not on Windows.\n\nAs of v4.24.5, to access this platform-specific information, gopsutil provides functions named `Ex` within the package. Currently, these functions are available in the mem and sensor packages.\n\nThe Ex structs are specific to each platform. For example, on Linux, there is an `ExLinux` struct, which can be obtained using the `mem.NewExLinux()` function. On Windows, it's `mem.ExWindows()`. These Ex structs provide platform-specific information.\n\n```\nex := NewExWindows()\nv, err := ex.VirtualMemory()\nif err != nil {\n    panic(err)\n}\n\nfmt.Println(v.VirtualAvail)\nfmt.Println(v.VirtualTotal)\n\n\u002F\u002F Output:\n\u002F\u002F 140731958648832\n\u002F\u002F 140737488224256\n```\n\ngopsutil aims to minimize platform differences by offering common functions. However, there are many requests to obtain unique information for each platform. The Ex structs are designed to meet those requests. Additional functionalities might be added in the future. The use of these structures makes it clear that the information they provide is specific to each platform, which is why they have been designed in this way.\n\n## Documentation\n\nSee https:\u002F\u002Fpkg.go.dev\u002Fgithub.com\u002Fshirou\u002Fgopsutil\u002Fv4 or https:\u002F\u002Fgodocs.io\u002Fgithub.com\u002Fshirou\u002Fgopsutil\u002Fv4\n\n## Requirements\n\n- go1.18 or above is required.\n\n## More Info\n\nSeveral methods have been added which are not present in psutil, but\nwill provide useful information.\n\n- host\u002FHostInfo() (linux)\n  - Hostname\n  - Uptime\n  - Procs\n  - OS (ex: \"linux\")\n  - Platform (ex: \"ubuntu\", \"arch\")\n  - PlatformFamily (ex: \"debian\")\n  - PlatformVersion (ex: \"Ubuntu 13.10\")\n  - VirtualizationSystem (ex: \"LXC\")\n  - VirtualizationRole (ex: \"guest\"\u002F\"host\")\n- IOCounters\n  - Label (linux only) The registered [device mapper\n    name](https:\u002F\u002Fwww.kernel.org\u002Fdoc\u002FDocumentation\u002FABI\u002Ftesting\u002Fsysfs-block-dm)\n- cpu\u002FCPUInfo() (linux, freebsd)\n  - CPU (ex: 0, 1, ...)\n  - VendorID (ex: \"GenuineIntel\")\n  - Family\n  - Model\n  - Stepping\n  - PhysicalID\n  - CoreID\n  - Cores (ex: 2)\n  - ModelName (ex: \"Intel(R) Core(TM) i7-2640M CPU @ 2.80GHz\")\n  - Mhz\n  - CacheSize\n  - Flags (ex: \"fpu vme de pse tsc msr pae mce cx8 ...\")\n  - Microcode\n- load\u002FAvg() (linux, freebsd, solaris)\n  - Load1\n  - Load5\n  - Load15\n- docker\u002FGetDockerIDList() (linux only)\n  - container id list ([]string)\n- docker\u002FCgroupCPU() (linux only)\n  - user\n  - system\n- docker\u002FCgroupMem() (linux only)\n  - various status\n- net_protocols (linux only)\n  - system wide stats on network protocols (i.e IP, TCP, UDP, etc.)\n  - sourced from \u002Fproc\u002Fnet\u002Fsnmp\n- iptables nf_conntrack (linux only)\n  - system wide stats on netfilter conntrack module\n  - sourced from \u002Fproc\u002Fsys\u002Fnet\u002Fnetfilter\u002Fnf_conntrack_count\n\nSome code is ported from Ohai. Many thanks.\n\n## Current Status\n\n- x: works\n- b: almost works, but something is broken\n\n|name                  |Linux  |FreeBSD  |OpenBSD  |macOS   |Windows  |Solaris  |Plan 9   |AIX      |\n|----------------------|-------|---------|---------|--------|---------|---------|---------|---------|\n|cpu\\_times            |x      |x        |x        |x       |x        |         |b        |x        |\n|cpu\\_count            |x      |x        |x        |x       |x        |         |x        |x        |\n|cpu\\_percent          |x      |x        |x        |x       |x        |         |         |x        |\n|cpu\\_times\\_percent   |x      |x        |x        |x       |x        |         |         |x        |\n|virtual\\_memory       |x      |x        |x        |x       |x        |b        |x        |x        |\n|swap\\_memory          |x      |x        |x        |x       |         |         |x        |X        |\n|disk\\_partitions      |x      |x        |x        |x       |x        |         |         |x        |\n|disk\\_io\\_counters    |x      |x        |x        |x       |x        |         |         |         |\n|disk\\_usage           |x      |x        |x        |x       |x        |         |         |x        |\n|net\\_io\\_counters     |x      |x        |x        |b       |x        |x        |         |         |\n|boot\\_time            |x      |x        |x        |x       |x        |         |         |X        |\n|users                 |x      |x        |x        |x       |x        |         |         |x        |\n|pids                  |x      |x        |x        |x       |x        |         |         |         |\n|pid\\_exists           |x      |x        |x        |x       |x        |         |         |         |\n|net\\_connections      |x      |x        |x        |x       |         |         |         |x        |\n|net\\_protocols        |x      |         |         |        |         |         |         |x        |\n|net\\_if\\_addrs        |       |         |         |        |         |         |         |x        |\n|net\\_if\\_stats        |       |         |         |        |         |         |         |x        |\n|netfilter\\_conntrack  |x      |         |         |        |         |         |         |         |\n|sensors_temperature   |x      |         |         |x       |x        |x        |         |         |\n\n\n### Process class\n\n|name                |Linux  |FreeBSD  |OpenBSD  |macOS  |Windows  |\n|--------------------|-------|---------|---------|-------|---------|\n|pid                 |x      |x        |x        |x      |x        |\n|ppid                |x      |x        |x        |x      |x        |\n|name                |x      |x        |x        |x      |x        |\n|cmdline             |x      |x        |x        |x      |x        |\n|create\\_time        |x      |         |         |x      |x        |\n|status              |x      |x        |x        |x      |         |\n|cwd                 |x      |x        |x        |x      |x        |\n|exe                 |x      |x        |x        |       |x        |\n|uids                |x      |x        |x        |x      |         |\n|gids                |x      |x        |x        |x      |         |\n|terminal            |x      |x        |x        |       |         |\n|io\\_counters        |x      |x        |x        |       |x        |\n|nice                |x      |x        |x        |x      |x        |\n|num\\_fds            |x      |         |         |x      |x        |\n|num\\_ctx\\_switches  |x      |         |         |       |         |\n|num\\_threads        |x      |x        |x        |x      |x        |\n|cpu\\_times          |x      |         |         |       |x        |\n|memory\\_info        |x      |x        |x        |x      |x        |\n|memory\\_maps        |x      |         |         |       |         |\n|open\\_files         |x      |         |         |       |x        |\n|send\\_signal        |x      |x        |x        |x      |         |\n|suspend             |x      |x        |x        |x      |x        |\n|resume              |x      |x        |x        |x      |x        |\n|terminate           |x      |x        |x        |x      |x        |\n|kill                |x      |x        |x        |x      |         |\n|username            |x      |x        |x        |x      |x        |\n|ionice              |       |         |         |       |         |\n|rlimit              |x      |         |         |       |         |\n|num\\_handlers       |       |         |         |       |         |\n|threads             |x      |         |         |       |         |\n|cpu\\_percent        |x      |         |x        |x      |x        |\n|cpu\\_affinity       |       |         |         |       |         |\n|memory\\_percent     |x      |         |         |       |x        |\n|parent              |x      |         |x        |x      |x        |\n|children            |x      |x        |x        |x      |x        |\n|connections         |x      |         |x        |x      |         |\n|is\\_running         |       |         |         |       |         |\n|page\\_faults        |x      |         |         |       |x        |\n\n### gopsutil Original Metrics\n\n|item                    |Linux  |FreeBSD  |OpenBSD  |macOS   |Windows |Solaris  |AIX      |\n|------------------------|-------|---------|---------|--------|--------|---------|---------|\n|**HostInfo**            |       |         |         |        |        |         |         |\n|hostname                |x      |x        |x        |x       |x       |x        |X        |\n|uptime                  |x      |x        |x        |x       |        |x        |x        |\n|process                 |x      |x        |x        |        |        |x        |         |\n|os                      |x      |x        |x        |x       |x       |x        |x        |\n|platform                |x      |x        |x        |x       |        |x        |x        |\n|platformfamily          |x      |x        |x        |x       |        |x        |x        |\n|virtualization          |x      |         |         |        |        |         |         |\n|**CPU**                 |       |         |         |        |        |         |         |\n|VendorID                |x      |x        |x        |x       |x       |x        |x        |\n|Family                  |x      |x        |x        |x       |x       |x        |x        |\n|Model                   |x      |x        |x        |x       |x       |x        |x        |\n|Stepping                |x      |x        |x        |x       |x       |x        |         |\n|PhysicalID              |x      |         |         |        |        |x        |         |\n|CoreID                  |x      |         |         |        |        |x        |         |\n|Cores                   |x      |         |         |x       |x       |x        |x        |\n|ModelName               |x      |x        |x        |x       |x       |x        |x        |\n|Microcode               |x      |         |         |        |        |x        |         |\n|**LoadAvg**             |       |         |         |        |        |         |         |\n|Load1                   |x      |x        |x        |x       |x       |x        |x        |\n|Load5                   |x      |x        |x        |x       |x       |x        |x        |\n|Load15                  |x      |x        |x        |x       |x       |x        |x        |\n|**Docker GetDockerID**  |       |         |         |        |        |         |         |\n|container id            |x      |no       |no       |no      |no      |no       |no       |\n|**Docker CgroupsCPU**   |       |         |         |        |        |         |         |\n|user                    |x      |no       |no       |no      |no      |no       |no       |\n|system                  |x      |no       |no       |no      |no      |no       |no       |\n|**Docker CgroupsMem**   |       |         |         |        |        |         |         |\n|various                 |x      |no       |no       |no      |no      |no       |no       |\n\n- future work\n  - process_iter\n  - wait_procs\n  - Process class\n    - as_dict\n    - wait\n  - AIX processes\n\n## License\n\nNew BSD License (same as psutil)\n\n## Related Works\n\nI have been influenced by the following great works:\n\n- psutil: https:\u002F\u002Fgithub.com\u002Fgiampaolo\u002Fpsutil\n- dstat: https:\u002F\u002Fgithub.com\u002Fdagwieers\u002Fdstat\n- gosigar: https:\u002F\u002Fgithub.com\u002Fcloudfoundry\u002Fgosigar\u002F\n- goprocinfo: https:\u002F\u002Fgithub.com\u002Fc9s\u002Fgoprocinfo\n- go-ps: https:\u002F\u002Fgithub.com\u002Fmitchellh\u002Fgo-ps\n- ohai: https:\u002F\u002Fgithub.com\u002Fopscode\u002Fohai\u002F\n- bosun:\n  https:\u002F\u002Fgithub.com\u002Fbosun-monitor\u002Fbosun\u002Ftree\u002Fmaster\u002Fcmd\u002Fscollector\u002Fcollectors\n- mackerel:\n  https:\u002F\u002Fgithub.com\u002Fmackerelio\u002Fmackerel-agent\u002Ftree\u002Fmaster\u002Fmetrics\n\n## How to Contribute\n\n1.  Fork it\n2.  Create your feature branch (git checkout -b my-new-feature)\n3.  Commit your changes (git commit -am 'Add some feature')\n4.  Push to the branch (git push origin my-new-feature)\n5.  Create new Pull Request\n\nEnglish is not my native language, so PRs correcting grammar or spelling are welcome and appreciated.\n","gopsutil 是一个为 Go 语言设计的系统信息获取库，类似于 Python 的 psutil。它提供了丰富的功能来收集和监控系统状态，包括但不限于 CPU、内存、磁盘以及网络等信息，并且所有这些功能都是在不使用 cgo 的情况下实现的，确保了跨平台兼容性。支持多种操作系统如 Linux、Windows、macOS 等及其对应的架构。适用于需要实时监控或分析服务器性能的应用场景，比如云服务管理、自动化运维工具开发等领域。通过简单的 API 调用即可获得结构化的系统数据，方便进一步处理或展示。",2,"2026-06-11 03:01:55","top_language"]