{"id":22583247,"url":"https://github.com/devatoria/thief","last_synced_at":"2026-03-07T05:32:29.566Z","repository":{"id":93500188,"uuid":"257896827","full_name":"Devatoria/thief","owner":"Devatoria","description":"thief: a tool to steal your containers resources","archived":false,"fork":false,"pushed_at":"2020-05-04T14:12:45.000Z","size":3304,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-24T17:11:07.088Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Devatoria.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":"2020-04-22T12:36:32.000Z","updated_at":"2022-08-23T23:00:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"ab928656-7653-483f-b73d-f86123ae263d","html_url":"https://github.com/Devatoria/thief","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Devatoria%2Fthief","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Devatoria%2Fthief/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Devatoria%2Fthief/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Devatoria%2Fthief/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Devatoria","download_url":"https://codeload.github.com/Devatoria/thief/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248281415,"owners_count":21077423,"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":"2024-12-08T06:14:29.483Z","updated_at":"2026-03-07T05:32:29.498Z","avatar_url":"https://github.com/Devatoria.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# thief: a tool to steal your containers resources\n\nThief is a tool allowing to execute processes into a container cgroups instead of the actual ones, stealing its allowed resources.\n\nThis project has been made for ludic purposes only and is not expected to be used for another way than that. It manipulates your processes cgroups directly.\n\n## Example\n\nA quick example running the `sysbench` tool on CPU. First shot is from one container with no 1 CPU, second shot is from a container cgroup having only 0.5 CPU.\n\n```\n/# sysbench cpu run\nCPU speed:\n    events per second:  1135.99\n\nGeneral statistics:\n    total time:                          10.0012s\n    total number of events:              11363\n\nThreads fairness:\n    events (avg/stddev):           11363.0000/0.00\n    execution time (avg/stddev):   9.8310/0.00\n\n/# thief --sysfs-path /mnt/cgroup --runtime docker run --cpu 48b8916a8d82 sysbench cpu run\nCPU speed:\n    events per second:   516.93\n\nGeneral statistics:\n    total time:                          10.0074s\n    total number of events:              5174\n\nThreads fairness:\n    events (avg/stddev):           5174.0000/0.00\n    execution time (avg/stddev):   9.8624/0.00\n```\n\n## Usage\n\n### Global flags\n\n* `--sysfs-path` is the mounting point of the cgroups files, defaulting to `/sys/fs/cgroup`\n* `--runtime` is the runtime to use, either `docker` or `containerd`\n* `--socket` is the runtime socket path\n  * `containerd` runtime default is `/run/containerd/containerd.sock`\n  * `docker` runtime default is `/var/run/docker.sock`\n\n### Join a container CPU cgroup from the host\n\n```\n~# thief join --cpu 2c9eac1a0147e449208872330685c575933ddd2148888e8cdab899bbb7c14287\n\nSuccessfully joined 2c9eac1a0147e449208872330685c575933ddd2148888e8cdab899bbb7c14287 container cgroups\n```\n\n### Join a container CPU cgroup from another container\n\nThe host `/sys/fs/cgroup` directory has been mounted in the container running thief in the `/mnt/cgroup` mount point.\n\n```\n~# thief --sysfs-path /mnt/cgroup join --cpu 2c9eac1a0147e449208872330685c575933ddd2148888e8cdab899bbb7c14287\n\nSuccessfully joined 2c9eac1a0147e449208872330685c575933ddd2148888e8cdab899bbb7c14287 container cgroups\n```\n\n### Join back root cgroups\n\nThe `exit` subcommand re-attaches the current process to the same cgroups as the PID `1` process.\n\n```\n~# thief exit\n\nExited successfully!\n```\n\n### Run a bash shell in a container CPU cgroup from the host\n\n```\n~# thief run --cpu 2c9eac1a0147e449208872330685c575933ddd2148888e8cdab899bbb7c14287 bash\n~# \n```\n\n### Attach a running process to a container CPU cgroup\n\n```\n~# thief attach --cpu 662c9eac1a0147e449208872330685c575933ddd2148888e8cdab899bbb7c14287 6\nSuccessfully attached PID 666 to 62c9eac1a0147e449208872330685c575933ddd2148888e8cdab899bbb7c14287 container cgroups\n```\n\n## Notes\n\n* You need to execute `thief` as root to be able to manipulate cgroups\n* If executed in a container, this container needs to:\n  * Mount the host `/sys/fs/cgroup` path\n  * Be privileged\n\n## TODOs\n\n### Commands\n\n- [x] Join command to attach the current process to a cgroup\n- [x] Exit command to re-attach the current process to the main cgroup\n- [x] Run command to run a command in a cgroup\n- [x] Attach command to attach an existing process to a cgroup\n\n### Other\n\n- [ ] Tests\n- [ ] CI\n- [ ] Releases\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevatoria%2Fthief","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevatoria%2Fthief","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevatoria%2Fthief/lists"}