Skip to content

Commit

Permalink
Merge pull request #55 from joular/develop
Browse files Browse the repository at this point in the history
Version 1.0.0
  • Loading branch information
adelnoureddine authored Jun 26, 2024
2 parents 46db963 + d8e1ebf commit 634c5cf
Show file tree
Hide file tree
Showing 19 changed files with 705 additions and 176 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Detailed documentation (including user and reference guides) are available at: [
## :rocket: Features

- Monitor power consumption of CPU and GPU of PC/servers
- Monitor power consumption inside virtual machines
- Monitor power consumption of individual processes in GNU/Linux
- Expose power consumption to the terminal and CSV files
- Provides a systemd service (daemon) to continuously monitor power of devices
Expand All @@ -22,13 +23,19 @@ Detailed documentation (including user and reference guides) are available at: [
PowerJoular monitors the following platforms:
- :computer: PC/Servers using a RAPL supported Intel processor (since Sandy Bridge) or a RAPL supported AMD processor (Ryzen or EPYC), and optionally an Nvidia graphic card.
- :radio: Raspberry Pi devices (multiple models) and Asus Tinker Board.
- :computer: Inside virtual machines in all supported host platforms.

In all platforms, PowerJoular works currently only on GNU/Linux.

On PC/Servers, PowerJoular uses powercap Linux interface to read Intel RAPL (Running Average Power Limit) energy consumption.

PowerJoular supports RAPL package domain (core, including integrated graphics, and dram), and for more recent processors, we support Psys package (which covers the energy consumption of the entire SoC).

On virtual machines, PowerJoular requires two steps:
- Installing PowerJoular itself or another power monitoring tool in the host machine.
Then monitoring the virtual machine power consumption every second and writing it to a file (to be shared with the guest VM).
- Installing PowerJoular in the guest VM, then running PowerJoular while specifying the path of the power file shared with the host and its format.

On Raspberry Pi and Asus Tinker Board, PowerJoular uses its own research-based empirical regression models to estimate the power consumption of the ARM processor.

The supported list of Raspberry Pi and Asus Tinker Board models are listed below.
Expand Down Expand Up @@ -74,6 +81,8 @@ The following options are available:
- ```-t```: print energy data to the terminal
- ```-d```: print debug info to the terminal
- ```-l```: use linear regression models (less accurate than the default polynomial models) for Raspberry Pi energy models
- ```-m```: specify a filename for the power consumption of the virtual machine
- ```-s```: specify the format of the VM power, either ```powerjoular``` format (generated with the ```-o``` option: 3 columns csv file with the 3rd containing the power consumption the VM), or ```watts``` format (1 column containing just the power consumption of the VM)

You can mix options, i.e., ```powerjoular -tp 144``` will monitor PID 144 and will print to the terminal.

Expand Down Expand Up @@ -135,6 +144,19 @@ If you have [Alire](https://alire.ada.dev/) installed, you can use it to build P
alr build
```

### Cross-compilation and package generation

The ```release-version.sh``` script cross-compiles PowerJoular to multiple platforms (for now x86_64 and aarch64, but can be tweaked to add other platforms).
The script then generates RPM and DEB binary installation packages for these platforms.

The script needs a x86_64 and an aarch64 gnat compiler, along with deb and rpm packaging tools.

Install them according to your distribution. For example, in Ubuntu 22.04 x86_64 :

```
sudo apt install gnat gnat-12-aarch64-linux-gnu dpkg rpm
```

## :hourglass: Systemd service

A systemd service is provided and can be installed (by copying ```powerjoular.service``` in ```systemd``` folder to ```/etc/systemd/system/```).
Expand Down
28 changes: 14 additions & 14 deletions alire.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name = "powerjoular"
description = "Monitoring the power consumption of multiple platforms and processes"
version = "0.7.3"

authors = ["Adel Noureddine"]
maintainers = ["Adel Noureddine <adel.noureddine@univ-pau.fr>"]
maintainers-logins = ["adelnoureddine"]

tags = ["linux", "power", "energy"]

licenses = "GPL-3.0-only"
website = "https://www.noureddine.org/research/joular/powerjoular"

executables = ["powerjoular"]
name = "powerjoular"
description = "Monitoring the power consumption of multiple platforms and processes"
version = "1.0.0"

authors = ["Adel Noureddine"]
maintainers = ["Adel Noureddine <adel.noureddine@univ-pau.fr>"]
maintainers-logins = ["adelnoureddine"]

tags = ["linux", "power", "energy"]

licenses = "GPL-3.0-only"
website = "https://www.noureddine.org/research/joular/powerjoular"

executables = ["powerjoular"]
22 changes: 22 additions & 0 deletions installer/aur/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Maintainer: Adel Noureddine <adel.noureddine@univ-pau.fr>
pkgname=powerjoular
pkgver=1.0.0
pkgrel=1
pkgdesc="PowerJoular allows monitoring power consumption of multiple platforms and processes."
arch=('x86_64' 'aarch64' 'armv7h')
url="https://github.com/joular/powerjoular"
license=('GPL3')
depends=('gcc-ada' 'gprbuild' 'xmlada' 'libgpr')
source=("$pkgname-$pkgver.tar.gz::https://github.com/joular/powerjoular/archive/refs/heads/main.tar.gz")
sha256sums=('SKIP')

build() {
cd "$srcdir/$pkgname-develop"
gprbuild -P powerjoular.gpr
}

package() {
cd "$srcdir/$pkgname-develop"
install -Dm755 obj/powerjoular "$pkgdir/usr/bin/powerjoular"
install -Dm644 systemd/powerjoular.service "$pkgdir/etc/systemd/system/powerjoular.service"
}
31 changes: 31 additions & 0 deletions installer/aur/create-packages-arch-source.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# Function to check user permissions to write to current directory
if [ ! -w "$(pwd)" ]; then
echo "ERROR: You don't have write permission on the directory $(pwd)."
exit 1
fi

# Source directory for PKGBUILD
PKG_DIR="arch_pkgbuild"
OUTPUT_DIR="arch_source_packages"
rm -rf $PKG_DIR $OUTPUT_DIR
mkdir -p $PKG_DIR $OUTPUT_DIR

# Copy the PKGBUILD file to the build directory
cp PKGBUILD $PKG_DIR/

# Changer de répertoire pour PKGBUILD
cd $PKG_DIR

# Change directory to PKGBUILD
makepkg

# Move the generated package to the output directory
mv *.pkg.tar.zst ../$OUTPUT_DIR/

# Clean up temporary directories
cd ..
rm -rf $PKG_DIR

echo "Arch package has been created and moved to the '$OUTPUT_DIR' directory."
File renamed without changes.
File renamed without changes.
23 changes: 0 additions & 23 deletions installer/create-packages.sh

This file was deleted.

5 changes: 0 additions & 5 deletions installer/debian-control-amd64.txt

This file was deleted.

5 changes: 0 additions & 5 deletions installer/debian-control-arm64.txt

This file was deleted.

5 changes: 0 additions & 5 deletions installer/debian-control-armhf.txt

This file was deleted.

28 changes: 28 additions & 0 deletions installer/powerjoular.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Name: powerjoular
Version: 1.0.0
Release: 1%{?dist}
Summary: PowerJoular allows monitoring power consumption of multiple platforms and processes.

License: GPL-3.0-only
Source0: %{_sourcedir}/obj/powerjoular
Source1: %{_sourcedir}/powerjoular.service

%description
PowerJoular allows monitoring power consumption of multiple platforms and processes.

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{_bindir}
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/systemd/system/
install -m 755 %{SOURCE0} $RPM_BUILD_ROOT/%{_bindir}/%{name}
install -m 644 %{SOURCE1} $RPM_BUILD_ROOT/%{_sysconfdir}/systemd/system/%{name}.service

%files
%{_bindir}/%{name}
%{_sysconfdir}/systemd/system/%{name}.service

%changelog
* Thu Jun 20 2024 Adel Noureddine <adel.noureddine@univ-pau.fr> - 1.0.0-1
- Version 1.0.0
* Thu Jun 06 2024 Adel Noureddine <adel.noureddine@univ-pau.fr> - 0.7.3-1
- First RPM build
120 changes: 120 additions & 0 deletions release-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#!/bin/bash

VERSION=1.0.0

# First cross compiler

# Create obj/ folder it not exist
mkdir -p obj

# Architectures
ARCHS=("x86_64-linux-gnu" "aarch64-linux-gnu")

for ARCH in "${ARCHS[@]}"
do
gprbuild powerjoular.gpr --target=$ARCH
mkdir -p ./binary/$ARCH
cp ./obj/powerjoular ./binary/$ARCH/
done

# Create packages folder
rm -rf packages
mkdir -p packages


# Create deb packages

# Create deb temporary folder
mkdir -p deb-temp
cd deb-temp

DEBIAN_ARCHITECTURES=("amd64" "arm64")

for DEB_ARCH in "${DEBIAN_ARCHITECTURES[@]}"
do
# Create a new directory structure for architecture
rm -rf $DEB_ARCH
mkdir -p $DEB_ARCH/powerjoular/usr/bin
mkdir -p $DEB_ARCH/powerjoular/etc/systemd/system
mkdir -p $DEB_ARCH/powerjoular/DEBIAN/
chmod 755 $DEB_ARCH

# Copy precompiled binaries to bin directory
if [[ $DEB_ARCH = "amd64" ]]
then
cp ../binary/x86_64-linux-gnu/powerjoular $DEB_ARCH/powerjoular/usr/bin
elif [[ $DEB_ARCH = "arm64" ]]
then
cp ../binary/aarch64-linux-gnu/powerjoular $DEB_ARCH/powerjoular/usr/bin
fi

# Copy systemd service files
cp ../systemd/powerjoular.service $DEB_ARCH/powerjoular/etc/systemd/system/

# Create the control
cat << EOL > $DEB_ARCH/powerjoular/DEBIAN/control
Package: powerjoular
Version: $VERSION
Maintainer: Adel Noureddine
Architecture: $DEB_ARCH
Description: PowerJoular allows monitoring power consumption of multiple platforms and processes.
EOL

cd $DEB_ARCH

# Creating a .deb package
dpkg-deb --build powerjoular
mv powerjoular.deb ../../packages/powerjoular_${VERSION}_${DEB_ARCH}.deb

cd ..
done

# Remove temp folder
cd ..
rm -rf deb-temp


# Create rpm packages

RPM_ARCHITECTURES=("x86_64" "arm64")

# Create rpm temporary folder
mkdir -p rpm-temp
cd rpm-temp

for RPM_ARCH in "${RPM_ARCHITECTURES[@]}"
do
# Create a new directory structure for architecture
rm -rf $RPM_ARCH
mkdir -p $RPM_ARCH



# Prepare the RPM build environment
mkdir -p $RPM_ARCH/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
cp ../installer/powerjoular.spec $RPM_ARCH/rpmbuild/SPECS/

# Copy the sources accordingly

if [[ $RPM_ARCH = "x86_64" ]]
then
cp ../binary/x86_64-linux-gnu/powerjoular $RPM_ARCH/rpmbuild/SOURCES/
elif [[ $RPM_ARCH = "arm64" ]]
then
cp ../binary/aarch64-linux-gnu/powerjoular $RPM_ARCH/rpmbuild/SOURCES/
fi

cp ../systemd/powerjoular.service $RPM_ARCH/rpmbuild/SOURCES/

# Build the RPM package
cd $RPM_ARCH
rpmbuild -ba rpmbuild/SPECS/powerjoular.spec --define "_topdir $(pwd)/rpmbuild" --target $RPM_ARCH

# Move the created RPM to packages
find rpmbuild/RPMS/ -name '*.rpm' -exec mv {} ../../packages/ \;
cd ..
done

# Remove temp folder
cd ..
rm -rf rpm-temp
Loading

0 comments on commit 634c5cf

Please sign in to comment.