{"id":28741284,"url":"https://github.com/coder/clistat","last_synced_at":"2025-06-16T07:11:36.499Z","repository":{"id":284631573,"uuid":"942144673","full_name":"coder/clistat","owner":"coder","description":null,"archived":false,"fork":false,"pushed_at":"2025-05-27T17:12:33.000Z","size":75,"stargazers_count":8,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-11T05:51:53.008Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-03T16:39:10.000Z","updated_at":"2025-05-27T17:12:37.000Z","dependencies_parsed_at":"2025-03-26T21:42:27.445Z","dependency_job_id":"55456049-e3d7-40f9-b25c-e64b9c57a3b3","html_url":"https://github.com/coder/clistat","commit_stats":null,"previous_names":["coder/clistat"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/coder/clistat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder%2Fclistat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder%2Fclistat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder%2Fclistat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder%2Fclistat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coder","download_url":"https://codeload.github.com/coder/clistat/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder%2Fclistat/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260116634,"owners_count":22961066,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2025-06-16T07:11:34.927Z","updated_at":"2025-06-16T07:11:36.480Z","avatar_url":"https://github.com/coder.png","language":"Go","readme":"# clistat\n\nA Go library for measuring and reporting system resource usage.\n\n## Overview\n\n`clistat` provides utilities to query resource usage metrics on a system including:\n\n- Host resources:\n  - CPU usage\n  - Memory usage\n  - Disk usage\n\n- Container resources (cgroup v1 and v2 support):\n  - CPU usage\n  - Memory usage\n\n## Features\n\n- Human-readable output formatting with appropriate unit prefixes\n- Support for both host and containerized environments\n- Automatic container detection\n- Support for both cgroup v1 and v2\n- Configurable with options pattern\n\n## Usage\n\nThe below sample code can be run as follows:\n\n```shell\nCGO_ENABLED=0 go run github.com/coder/clistat/cmd/clistat@main\n```\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/coder/clistat\"\n)\n\nfunc main() {\n\t// Create a new Statter\n\ts, err := clistat.New()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Query host CPU usage\n\tcpu, err := s.HostCPU()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfmt.Printf(\"CPU: %s\\n\", cpu)\n\n\t// Query host memory usage\n\tmem, err := s.HostMemory(clistat.PrefixGibi)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfmt.Printf(\"Memory: %s\\n\", mem)\n\n\t// Query disk usage\n\tdisk, err := s.Disk(clistat.PrefixGibi, \"\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfmt.Printf(\"Disk: %s\\n\", disk)\n\n\t// Check if running in a container\n\tisContainer, err := s.IsContainerized()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tif isContainer {\n\t\t// Query container CPU usage\n\t\tcontainerCPU, err := s.ContainerCPU()\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\tfmt.Printf(\"Container CPU: %s\\n\", containerCPU)\n\n\t\t// Query container memory usage\n\t\tcontainerMem, err := s.ContainerMemory(clistat.PrefixMebi)\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\tfmt.Printf(\"Container Memory: %s\\n\", containerMem)\n\t}\n}\n```\n\n## Output Examples\n\nThe library formats output in a human-friendly way:\n\n```\nCPU: 2.5/8 cores (31%)\nMemory: 3.2/16 GiB (20%)\nDisk: 50/200 GiB (25%)\nContainer CPU: 0.5/2.5 cores (20%)\nContainer Memory: 256/1024 MiB (25%)\n```\n\n## Testing\n\nThe library includes a comprehensive test suite that can be run with:\n\n```\ngo test ./...\n```\n\nSome tests are designed to detect containerization status and will adjust based on the environment. You can control test behavior with these environment variables:\n\n- `CLISTAT_IS_CONTAINERIZED=yes` - Indicate tests are running in a container\n- `CLISTAT_HAS_MEMORY_LIMIT=yes` - Indicate container has memory limits\n- `CLISTAT_HAS_CPU_LIMIT=yes` - Indicate container has CPU limits\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoder%2Fclistat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoder%2Fclistat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoder%2Fclistat/lists"}