{"id":48356946,"url":"https://github.com/green-coding-solutions/hog","last_synced_at":"2026-04-05T11:33:46.031Z","repository":{"id":195642008,"uuid":"655833918","full_name":"green-coding-solutions/hog","owner":"green-coding-solutions","description":"A tool suit that collects data of programs that use a lot of energy ","archived":false,"fork":false,"pushed_at":"2025-04-22T07:17:19.000Z","size":2357,"stargazers_count":10,"open_issues_count":14,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-22T08:27:58.055Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/green-coding-solutions.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,"zenodo":null}},"created_at":"2023-06-19T17:41:02.000Z","updated_at":"2025-04-22T07:17:23.000Z","dependencies_parsed_at":"2025-01-14T14:29:48.302Z","dependency_job_id":"bb87ff56-eee6-4908-bb9a-e72d0a5767b0","html_url":"https://github.com/green-coding-solutions/hog","commit_stats":null,"previous_names":["green-coding-berlin/hog","green-coding-solutions/hog"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/green-coding-solutions/hog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-coding-solutions%2Fhog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-coding-solutions%2Fhog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-coding-solutions%2Fhog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-coding-solutions%2Fhog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/green-coding-solutions","download_url":"https://codeload.github.com/green-coding-solutions/hog/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-coding-solutions%2Fhog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31434624,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T08:13:15.228Z","status":"ssl_error","status_checked_at":"2026-04-05T08:13:11.839Z","response_time":75,"last_error":"SSL_read: 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-04-05T11:33:45.945Z","updated_at":"2026-04-05T11:33:46.014Z","avatar_url":"https://github.com/green-coding-solutions.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The Power Hog\n\n\u003cimg src=\"logo.png\" width=\"100\"/\u003e\n\nThe power hog is a tool that periodically collects energy statistics of your mac and makes them available to you.\n\nThere are two main aims:\n\n1) Identify which apps are using a lot of energy on your machine.\n2) Collecting the data from as many machines as possible to identify wasteful apps globally.\n\nWe provide a website for detailed analytics of your data. The hog by default uploads your measurement data to our\n[Green Metrics Tool](https://github.com/green-coding-solutions/green-metrics-tool) backend. We put in a lot of effort\nto make sure that no confidential information is exposed but please refer to the [settings](#settings) section if you\nwant to disable the upload or submit the data to your own [backend](https://docs.green-coding.io/docs/installation/installation-linux/).\n\nThe hog consists of 2 apps that run on your local system. You need to power logger but not the app!\n\n## Power logger\n\nThe background process `power_logger.py` which saves the power statists to the database. We use the mac internal\n`powermetrics` tool to collect the data. Because the powermetrics tool needs to be run as root so does the power_logger\nscript. The tool accepts one argument `-d` to run the tool in debug mode. It can also be sent the SIGINFO command to\ngive some statistics. You can either call it by hand and send it to the background with `\u0026` or define it an agent.\nFor development purposes we recommend to always first run the program in the foreground and see if everything works fine\nand then use the launch agent.\n\nIf you want to avoid running the desktop app you can call the `power_logger.py` script with `-w` which will give\nyou the details url.\n\nYou can also run the `powermetrics` process yourself and then use `power_logger.py` to process the data and upload it.\nYou can use the `-f` parameter with a filename. Please submit the data in the plist format. You can use the following call string:\n`powermetrics --show-all -i 5000 -f plist -o FILENAME` and to run the powermetrics process yourself.\n\n### Parameter list\n\n- `-d`: Set's debug/ development mode to true. The Settings are set to local environments and we output statistics when running.\n- `-w`: Gives you the url of the analysis website and exits. This is especially useful when not using the desktop app\n- `-f filename`: Use the file as powermetrics input and don't start the process internally.\n\n### Setup of the power collection script\n\nThis is a description on how to set everything up if you did a git clone. You can also just do\n\n```\nsudo bash -c \"$(curl -fsSL https://raw.githubusercontent.com/green-coding-solutions/hog/main/install.sh)\"\n```\nwhich will do the whole install for you.\n\n#### Do it manually\n\nMake the `power_logger.py` script executable with `chmod a+x power_logger.py`\n\nPlease modify the `io.green-coding.hogger.plist` file to reference the right path. There is a script below that does\neverything for you.\n\nPlace the .plist file in the `/Library/LaunchDaemons` directory.\nFor security reasons, files in /Library/LaunchDaemons/ should have their permissions set to be owned by root:wheel\nand should not be writable by others.\n\n```bash\nsed -i.bak \"s|PATH_PLEASE_CHANGE|$(pwd)|g\" io.green-coding.hogger.plist\nsudo cp io.green-coding.hogger.plist /Library/LaunchDaemons/\n\nsudo chown root:wheel /Library/LaunchDaemons/io.green-coding.hogger.plist\nsudo chmod 644 /Library/LaunchDaemons/io.green-coding.hogger.plist\n\n```\n\nAfter placing the .plist file in the right directory, you need to tell launchd to load the new configuration:\n\n```bash\nsudo launchctl bootstrap system /Library/LaunchDaemons/io.green-coding.hogger.plist\n```\n\nYou can check if your service is loaded with:\n\n```bash\nsudo launchctl list | grep io.green-coding\n```\n\nIf you want to unload or stop the service:\n\n```bash\n\nsudo launchctl bootout system /Library/LaunchDaemons/io.green-coding.hogger.plist\n```\n\n### Settings\n\nIt is possible to configure your own settings by using a `settings.ini` file in the same directory as the `power_logger.py`\nscript. Or adding a `hogger_settings.ini` file to `/etc/`. This file in `etc` will be prioritized.\n\nFollowing keys are currently used:\n\n- `powermetrics`: This is the delta in ms that power metrics should take samples. So if you set this to 5000 powermetrics will return the aggregated values every 5 seconds\n- `upload_delta`: This is the time delta data should be uploaded in seconds.\n- `api_url`: The url endpoint the data should be uploaded to. You can use the https://github.com/green-coding-solutions/green-metrics-tool if you want but also write/ use your own backend.\n- `resolve_coalitions`: The way macOS works is that it looks as apps and not processes. So it can happen that when you look at your power data you see your shell as the main power hog.\n        This is because your shell has probably spawn the process that is using a lot of resources. Please add the name of the coalition to this list to resolve this error.\n- `gmt_auth_token`: If you want to upload the data to the Green Metrics Tool and see you statistics you will need to supply an auth token https://metrics.green-coding.io/authentication.html\n- `electricitymaps_token`: If you add an electricity maps token we can take the grid intensity and calculate the amount to CO2eq you are producing. You can get this token under https://api-portal.electricitymaps.com/\n- `daily_computer_usage_hours`: How long the device is used in a day on average. We need this for the embodied carbon calculations.\n- `overall_usage_years`: How long in years the device will be used. We need this for the embodied carbon calculations.\n\n## The desktop App\n\nThe hog desktop app gives you analytics of the data that was recorded. Please move this into your app folder.\n\n### Description of the headings\n\n- `Name`: This is the name of the process coalition. A coalition can be multiple processes. For example a program might fork\n        new process which will all show up in the coalition. Sometimes a shell might turn up here. Please tell us so we can\n        add this as an exception\n- `Energy Impact`: This is the value mac gives it's processes. The exact formula is not known but we know that quite some\n        factors are considered [some details](https://blog.mozilla.org/nnethercote/2015/08/26/what-does-the-os-x-activity-monitors-energy-impact-actually-measure/).\n         For now this is the best value we've got 🫣\n- `AVG Cpu Time %`: This is how long this coalition has spent on the CPUs. We take a percentage which can be over 100% as\n        the coalition could run on multiple cpus at the same time. So if a process takes up 100% of cpu time and runs on 4 cpus\n        the time will be 400%.\n\n## Database\n\nAll data is saved in an sqlite database that is located under:\n\n```bash\n/Library/Application Support/io.green-coding.hogger/db.db\n```\n\n## Updating\n\nWe currently don't support an automatic update. You will have to:\n\n- Download the current app and move it into your Applications folder from https://github.com/green-coding-solutions/hog/releases . The file will be called `hog.app.zip`\n- Rerun in the install script which will overwrite any custom changes you have made!\n```\nsudo mv /etc/hogger_settings.ini /etc/hogger_settings.ini.back\nsudo bash -c \"$(curl -fsSL https://raw.githubusercontent.com/green-coding-solutions/hog/main/install.sh)\"\n```\n\n## Contributing\n\nPRs are always welcome. Feel free to drop us an email or look into the issues.\n\nThe hog is developed to not need any dependencies.\n\n## Debugging\n\nIt sometimes help to enable debugging for the logger process you can do this by editing the `/Library/LaunchDaemons/io.green-coding.hogger.plist` file:\n```\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003c!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"\u003e\n\u003cplist version=\"1.0\"\u003e\n\u003cdict\u003e\n    \u003ckey\u003eLabel\u003c/key\u003e\n    \u003cstring\u003eio.green-coding.hogger\u003c/string\u003e\n\n    \u003ckey\u003eProgramArguments\u003c/key\u003e\n    \u003carray\u003e\n        \u003cstring\u003e/usr/local/bin/hog/power_logger.py\u003c/string\u003e\n        \u003cstring\u003e-v\u003c/string\u003e\n        \u003cstring\u003edebug\u003c/string\u003e\n        \u003cstring\u003e-o\u003c/string\u003e\n        \u003cstring\u003e/tmp/hog.log\u003c/string\u003e\n    \u003c/array\u003e\n\n    \u003ckey\u003eRunAtLoad\u003c/key\u003e\n    \u003ctrue/\u003e\n\n    \u003ckey\u003eKeepAlive\u003c/key\u003e\n    \u003ctrue/\u003e\n\u003c/dict\u003e\n```\nPlease remember that the log file can become quite big. The hog does not use logrotate or similar out of the box.\n\n## Tests\n\nYou can run some simple tests by running the `./run_test.sh` script the in the `test` folder. This is very basic!\n\n## Screenshots\n\n\u003cimg src=\"Screenshot.png\" width=\"300\"/\u003e\n\n## Sources\n\n- Logo from https://pixabay.com/de/vectors/schwein-schweinchen-ferkel-2660356/\n- Caribou (Public Domain) lib from https://raw.githubusercontent.com/clutchski/caribou/master/caribou.py\n\n## Misc\n\n- If you can't see the hog logo in the menu bar because of the notch there are multiple solutions.\n  - you can use a tool like https://www.macbartender.com/Bartender4/\n  - you can use the the command `$ sudo /usr/local/bin/hog/power_logger.py -w` to display the url.\n- We consider the readings we get from `powermetrics` to be energy and not power. As apple doesn't really give you any indication what the unit is we assume energy.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreen-coding-solutions%2Fhog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgreen-coding-solutions%2Fhog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreen-coding-solutions%2Fhog/lists"}