Giter VIP home page Giter VIP logo

yusufraji / zero-carb Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 6.26 MB

An application that measures software energy consumption of user device and computes software carbon intensity for data-driven decision making and software carbon accounting

License: MIT License

Dockerfile 0.79% Python 44.33% Shell 0.99% Smarty 0.26% C# 53.63%
carbon-accounting carbon-emissions green-computing green-software green-software-foundation software-carbon-intensity sustainable-development-goals sustainable-software

zero-carb's Introduction

Zero Carb

This application measures the energy consumption of software running on each computer within a team/organization, making it possible to obtain the Software Carbon Intensity (SCI).

sci

It is an entry for the Green Software Foundation's CarbonHack22 Hackathon.

Getting Started

Pre-requisites

This currently only runs on bare-metal Linux, no VM, so you need a Linux installation.

VM and cross-platform support coming soon

You need to have docker and docker compose installed.

The solution relies on the Green Software Foundation's Carbon-Aware SDK/API. The SDK requires a WattTime user account. You need to run the Carbon-Aware web API to use this solution, click here to learn more on how to get the webapi up and running.

Create .env files from these samples, .env_sample and smartwatts-formula/.env_sample, in the same directories. Replace the dummy username and password with your watttime username and password in the newly created .env files.

Ensure that you have cgroup-tools installed, Run:

apt-get update
apt-get -y install cgroup-tools

Run

Clone this repository and its submodules by running:

git clone --recurse-submodules [email protected]:yusufraji/zero-carb.git

You need to add each software you intend to monitor to a cgroup. This step is currently done manually, and will be automated later.

obtain the pid of the application

Run python ./cgroups/src/process_util.py This returns a list of dictionary of all running applications at the moment, like this:

[
    {'pid': 103721, 'user': 'chrome', 'username': 'my_username'},
    {'pid': 103721, 'user': 'zoom', 'username': 'my_username'},
    ...
    {'pid': 280263, 'user': 'word', 'username': 'my_username'}    
]

Inspect the data to get each the pid of each application (user) you are interested in.

Add application pid to cgroups

Repeat below for each application you would like to monitor:

cgcreate -g perf_event:<user>;
cgclassify -g perf_event:<user> <pid>

if you get: cgcreate: can't create cgroup chrome: Operation not permitted, or Error changing group of pid <pid>: Cgroup, operation not allowed run the commands with sudo.

Run the application

Run docker compose up to start the services.

Visualize data

grafana dashboard To visualize the results in grafana, visit localhost:3000 from your browser.

  • Add the influxdb to grafana Data Sources:
URL: http://localhost:8086
Database: results

leave all other fields as they are.

zero-carb's People

Contributors

yusufraji avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.