{"id":37166209,"url":"https://github.com/cipherboy/gopsutil","last_synced_at":"2026-01-14T19:41:46.180Z","repository":{"id":57707984,"uuid":"500540022","full_name":"cipherboy/gopsutil","owner":"cipherboy","description":"psutil for golang","archived":false,"fork":true,"pushed_at":"2022-06-06T18:24:59.000Z","size":2622,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-22T11:02:29.993Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"shirou/gopsutil","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cipherboy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"shirou"}},"created_at":"2022-06-06T18:00:01.000Z","updated_at":"2022-06-06T14:06:05.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/cipherboy/gopsutil","commit_stats":null,"previous_names":[],"tags_count":72,"template":false,"template_full_name":null,"purl":"pkg:github/cipherboy/gopsutil","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cipherboy%2Fgopsutil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cipherboy%2Fgopsutil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cipherboy%2Fgopsutil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cipherboy%2Fgopsutil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cipherboy","download_url":"https://codeload.github.com/cipherboy/gopsutil/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cipherboy%2Fgopsutil/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28432680,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T18:57:19.464Z","status":"ssl_error","status_checked_at":"2026-01-14T18:52:48.501Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-14T19:41:45.369Z","updated_at":"2026-01-14T19:41:46.154Z","avatar_url":"https://github.com/cipherboy.png","language":null,"funding_links":["https://github.com/sponsors/shirou"],"categories":[],"sub_categories":[],"readme":"# gopsutil: psutil for golang\n\n[![Test](https://github.com/shirou/gopsutil/actions/workflows/test.yml/badge.svg)](https://github.com/shirou/gopsutil/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/shirou/gopsutil/badge.svg?branch=master)](https://coveralls.io/github/shirou/gopsutil?branch=master) [![Go Reference](https://pkg.go.dev/badge/github.com/shirou/gopsutil.svg)](https://pkg.go.dev/github.com/shirou/gopsutil)\n\nThis is a port of psutil (https://github.com/giampaolo/psutil). The\nchallenge is porting all psutil functions on some architectures.\n\n## v3 migration\n\nfrom v3.20.10, gopsutil becomes v3 which breaks backwards compatibility.\nSee [v3Changes.md](_tools/v3migration/v3Changes.md) more detail changes.\n\n## Tag semantics\n\ngopsutil tag policy is almost same as Semantic Versioning, but\nautomatically increase like Ubuntu versioning.\n\nfor example, v2.17.04 means\n\n- v2: major version\n- 17: release year, 2017\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/amd64/arm\n- Linux i386/amd64/arm(raspberry pi)\n- Windows i386/amd64/arm/arm64\n- Darwin i386/amd64\n- OpenBSD amd64 (Thank you @mpfz0r!)\n- Solaris amd64 (developed and tested on SmartOS/Illumos, Thank you\n  @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 golang\nstructs.\n\n## Usage\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n\n    \"github.com/shirou/gopsutil/v3/mem\"\n    // \"github.com/shirou/gopsutil/mem\"  // to use v2\n)\n\nfunc main() {\n    v, _ := mem.VirtualMemory()\n\n    // 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    // 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 an alternative location to `/proc` by setting the `HOST_PROC`\nenvironment variable.\n\nYou can set an alternative location to `/sys` by setting the `HOST_SYS`\nenvironment variable.\n\nYou can set an alternative location to `/etc` by setting the `HOST_ETC`\nenvironment variable.\n\nYou can set an alternative location to `/var` by setting the `HOST_VAR`\nenvironment variable.\n\nYou can set an alternative location to `/run` by setting the `HOST_RUN`\nenvironment variable.\n\nYou can set an alternative location to `/dev` by setting the `HOST_DEV`\nenvironment variable.\n\nYou can set an alternative location to `/proc/N/mountinfo` by setting the\n`HOST_PROC_MOUNTINFO` environment variable.\n\n## Documentation\n\nsee http://godoc.org/github.com/shirou/gopsutil\n\n## Requirements\n\n- go1.16 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/HostInfo() (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\"/\"host\")\n- IOCounters\n  - Label (linux only) The registered [device mapper\n    name](https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-block-dm)\n- cpu/CPUInfo() (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/Avg() (linux, freebsd, solaris)\n  - Load1\n  - Load5\n  - Load15\n- docker/GetDockerIDList() (linux only)\n  - container id list ([]string)\n- docker/CgroupCPU() (linux only)\n  - user\n  - system\n- docker/CgroupMem() (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 /proc/net/snmp\n- iptables nf_conntrack (linux only)\n  - system wide stats on netfilter conntrack module\n  - sourced from /proc/sys/net/netfilter/nf_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   |\n|----------------------|-------|---------|---------|--------|---------|---------|---------|\n|cpu\\_times            |x      |x        |x        |x       |x        |         |b        |\n|cpu\\_count            |x      |x        |x        |x       |x        |         |x        |\n|cpu\\_percent          |x      |x        |x        |x       |x        |         |         |\n|cpu\\_times\\_percent   |x      |x        |x        |x       |x        |         |         |\n|virtual\\_memory       |x      |x        |x        |x       |x        | b       |x        |\n|swap\\_memory          |x      |x        |x        |x       |         |         |x        |\n|disk\\_partitions      |x      |x        |x        |x       |x        |         |         |\n|disk\\_io\\_counters    |x      |x        |x        |        |         |         |         |\n|disk\\_usage           |x      |x        |x        |x       |x        |         |         |\n|net\\_io\\_counters     |x      |x        |x        |b       |x        |         |         |\n|boot\\_time            |x      |x        |x        |x       |x        |         |         |\n|users                 |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       |         |         |         |\n|net\\_protocols        |x      |         |         |        |         |         |         |\n|net\\_if\\_addrs        |       |         |         |        |         |         |         |\n|net\\_if\\_stats        |       |         |         |        |         |         |         |\n|netfilter\\_conntrack  |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        |\n|create\\_time        |x      |         |         |x      |x        |\n|status              |x      |x        |x        |x      |         |\n|cwd                 |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      |         |         |       |         |\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\\_info\\_ex    |x      |         |         |       |         |\n|memory\\_maps        |x      |         |         |       |         |\n|open\\_files         |x      |         |         |       |         |\n|send\\_signal        |x      |x        |x        |x      |         |\n|suspend             |x      |x        |x        |x      |         |\n|resume              |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      |         |\n|cpu\\_affinity       |       |         |         |       |         |\n|memory\\_percent     |       |         |         |       |         |\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      |         |         |       |         |\n\n### Original Metrics\n\n|item             |Linux  |FreeBSD  |OpenBSD  |macOS   |Windows |Solaris  |\n|-----------------|-------|---------|---------|--------|--------|---------|\n|**HostInfo**     |       |         |         |        |        |         |\n|hostname         |x      |x        |x        |x       |x       |x        |\n|uptime           |x      |x        |x        |x       |        |x        |\n|process          |x      |x        |x        |        |        |x        |\n|os               |x      |x        |x        |x       |x       |x        |\n|platform         |x      |x        |x        |x       |        |x        |\n|platformfamily   |x      |x        |x        |x       |        |x        |\n|virtualization   |x      |         |         |        |        |         |\n|**CPU**          |       |         |         |        |        |         |\n|VendorID         |x      |x        |x        |x       |x       |x        |\n|Family           |x      |x        |x        |x       |x       |x        |\n|Model            |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        |\n|ModelName        |x      |x        |x        |x       |x       |x        |\n|Microcode        |x      |         |         |        |        |x        |\n|**LoadAvg**      |       |         |         |        |        |         |\n|Load1            |x      |x        |x        |x       |        |         |\n|Load5            |x      |x        |x        |x       |        |         |\n|Load15           |x      |x        |x        |x       |        |         |\n|**GetDockerID**  |       |         |         |        |        |         |\n|container id     |x      |no       |no       |no      |no      |         |\n|**CgroupsCPU**   |       |         |         |        |        |         |\n|user             |x      |no       |no       |no      |no      |         |\n|system           |x      |no       |no       |no      |no      |         |\n|**CgroupsMem**   |       |         |         |        |        |         |\n|various          |x      |no       |no       |no      |no      |         |\n\n- future work\n  - process_iter\n  - wait_procs\n  - Process class\n    - as_dict\n    - wait\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://github.com/giampaolo/psutil\n- dstat: https://github.com/dagwieers/dstat\n- gosigar: https://github.com/cloudfoundry/gosigar/\n- goprocinfo: https://github.com/c9s/goprocinfo\n- go-ps: https://github.com/mitchellh/go-ps\n- ohai: https://github.com/opscode/ohai/\n- bosun:\n  https://github.com/bosun-monitor/bosun/tree/master/cmd/scollector/collectors\n- mackerel:\n  https://github.com/mackerelio/mackerel-agent/tree/master/metrics\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\nare welcome and appreciated.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcipherboy%2Fgopsutil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcipherboy%2Fgopsutil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcipherboy%2Fgopsutil/lists"}