From acc85df2be23bd90e61abf5c0d087b406620ba4a Mon Sep 17 00:00:00 2001 From: Adel Noureddine Date: Tue, 21 Feb 2023 18:11:31 +0100 Subject: [PATCH 1/7] Add Citation file --- CITATION.cff | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 CITATION.cff diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 0000000..de41c5d --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,15 @@ +cff-version: 1.2.0 +message: "If you use this software, please cite the research paper." +preferred-citation: + type: conference-paper + conference: + name: "Intelligent Environments" + collection-title: "Proceedings of the 18th International Conference on Intelligent Environments" + publisher: IEEE + authors: + - family-names: "Noureddine" + given-names: "Adel" + orcid: "https://orcid.org/0000-0002-8585-574X" + title: "PowerJoular and JoularJX: Multi-Platform Software Power Monitoring Tools" + year: 2022 + doi: 10.1109/IE54923.2022.9826760 \ No newline at end of file From ec074f9fc0116973e15e4fd185be1cb9a6d79bfc Mon Sep 17 00:00:00 2001 From: Adel Noureddine Date: Tue, 21 Feb 2023 23:33:56 +0100 Subject: [PATCH 2/7] Add paper citation --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 6950768..1a6ec8b 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,24 @@ The service can be enabled to run automatically on boot. The systemd service is automatically installed when installing PowerJoular using the GNU/Linux provided packages. +## :bookmark_tabs: Cite this work + +To cite our work in a research paper, please cite our paper in the 18th International Conference on Intelligent Environments (IE2022). + +- **PowerJoular and JoularJX: Multi-Platform Software Power Monitoring Tools**. Adel Noureddine. In the 18th International Conference on Intelligent Environments (IE2022). Biarritz, France, 2022. + +``` +@inproceedings{noureddine-ie-2022, + title = {PowerJoular and JoularJX: Multi-Platform Software Power Monitoring Tools}, + author = {Noureddine, Adel}, + booktitle = {18th International Conference on Intelligent Environments (IE2022)}, + address = {Biarritz, France} + year = {2022} + month = {Jun}, + keywords = {Power Monitoring; Measurement; Power Consumption; Energy Analysis} +} +``` + ## :newspaper: License PowerJoular is licensed under the GNU GPL 3 license only (GPL-3.0-only). From bbc6b9c643a3e63b37b2f537481f680400cd19cd Mon Sep 17 00:00:00 2001 From: Adel Noureddine Date: Thu, 13 Apr 2023 16:22:52 +0200 Subject: [PATCH 3/7] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 22a9f05..534890b 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ PowerJoular is a command line software to monitor, in real time, the power consumption of software and hardware components. +Detailed documentation (including user and reference guides) are available at: [https://joular.github.io/powerjoular/](https://joular.github.io/powerjoular/). + ## :rocket: Features - Monitor power consumption of CPU and GPU of PC/servers From b6ed98fb01707652657a06775fcbca531e298cef Mon Sep 17 00:00:00 2001 From: afonsoCarreira1 Date: Fri, 13 Dec 2024 16:14:22 +0000 Subject: [PATCH 4/7] added timestamps with ms to the output csv --- src/csv_power.adb | 54 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/src/csv_power.adb b/src/csv_power.adb index bba9300..4e73f1b 100644 --- a/src/csv_power.adb +++ b/src/csv_power.adb @@ -19,6 +19,52 @@ with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; package body CSV_Power is + procedure Get_Timestamp (F : in File_Type) is + Current_Time : Time := Clock; + Year : Year_Number; + Month : Month_Number; + Day : Day_Number; + Seconds : Duration; + Hours, Minutes, Secs, Msecs : Integer; + Total_Seconds : Integer; + begin + Split(Current_Time, Year, Month, Day, Seconds); + + Total_Seconds := Integer(Seconds); + + Hours := Total_Seconds / 3600; + Minutes := (Total_Seconds mod 3600) / 60; + Secs := Total_Seconds mod 60; + Msecs := Integer((Seconds - Duration(Total_Seconds)) * 1000.0); + + if Msecs < 0 then + Msecs := 1000 + Msecs; + Secs := Secs -1; + end if; + + if Secs < 0 then + Secs := 59; + Minutes := Minutes - 1; + + if Minutes < 0 then + Minutes := 59; + Hours := Hours - 1; + + if Hours < 0 then + Hours := 23; + end if; + end if; + end if; + Put(F, Year'Image & "-" & + Month'Image & "-" & + Day'Image & " " & + Hours'Image & ":" & + Minutes'Image & ":" & + Secs'Image & "." & + Msecs'Image & ","); + end Get_Timestamp; + + procedure Save_To_CSV_File (Filename : String; Utilization : Long_Float; Total_Power : Long_Float; CPU_Power : Long_Float; GPU_Power : Long_Float; Overwrite_Data : Boolean) is F : File_Type; -- File handle Now : Time := Clock; -- Current UTC time @@ -26,7 +72,8 @@ package body CSV_Power is -- Procedure to save data to file procedure Save_Data (F : File_Type) is begin - Put (F, Image (Date => Now, Time_Zone => UTC_Time_Offset) & ","); -- Get time based on current timezone with UTC offset + -- Put (F, Image (Date => Now, Time_Zone => UTC_Time_Offset) & ","); -- Get time based on current timezone with UTC offset + Get_Timestamp(F); Put (F, Utilization, Exp => 0, Fore => 0); -- Exp = 0 to not show in scientific notation. Fore = 0 to show all digits Put (F, ","); Put (F, Total_Power, Exp => 0, Fore => 0); @@ -64,7 +111,8 @@ package body CSV_Power is -- Procedure to save data to file procedure Save_Data (F : File_Type) is begin - Put (F, Image (Date => Now, Time_Zone => UTC_Time_Offset) & ","); -- Get time based on current timezone with UTC offset + -- Put (F, Image (Date => Now, Time_Zone => UTC_Time_Offset) & ","); -- Get time based on current timezone with UTC offset + Get_Timestamp(F); Put (F, Utilization, Exp => 0, Fore => 0); -- Exp = 0 to not show in scientific notation. Fore = 0 to show all digits Put (F, ","); Put (F, Power, Exp => 0, Fore => 0); @@ -148,4 +196,4 @@ package body CSV_Power is Put (" Watts)"); end; -end CSV_Power; +end CSV_Power; \ No newline at end of file From 5d9505268641134509626efc63600cd1d576580f Mon Sep 17 00:00:00 2001 From: afonsoCarreira1 Date: Fri, 31 Jan 2025 21:39:31 +0000 Subject: [PATCH 5/7] updated pr to meet requirements --- src/csv_power.adb | 32 ++++++++++++++++++++------------ src/csv_power.ads | 4 ++-- src/help_info.adb | 1 + src/powerjoular.adb | 11 +++++++---- 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/csv_power.adb b/src/csv_power.adb index 4e73f1b..08ba844 100644 --- a/src/csv_power.adb +++ b/src/csv_power.adb @@ -16,10 +16,11 @@ with Ada.Calendar.Formatting; use Ada.Calendar.Formatting; with Ada.Calendar.Time_Zones; use Ada.Calendar.Time_Zones; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; +with Ada.Strings.Fixed; package body CSV_Power is - procedure Get_Timestamp (F : in File_Type) is + procedure Get_Timestamp (F : in File_Type; Save_Ms : Boolean) is Current_Time : Time := Clock; Year : Year_Number; Month : Month_Number; @@ -27,7 +28,13 @@ package body CSV_Power is Seconds : Duration; Hours, Minutes, Secs, Msecs : Integer; Total_Seconds : Integer; + Now : Time := Clock; -- Current UTC time + use Ada.Strings.Fixed; begin + if not Save_Ms then + Put (F, Image (Date => Now, Time_Zone => UTC_Time_Offset) & ","); -- Get time based on current timezone + return; + end if; Split(Current_Time, Year, Month, Day, Seconds); Total_Seconds := Integer(Seconds); @@ -55,17 +62,18 @@ package body CSV_Power is end if; end if; end if; - Put(F, Year'Image & "-" & - Month'Image & "-" & - Day'Image & " " & - Hours'Image & ":" & - Minutes'Image & ":" & - Secs'Image & "." & - Msecs'Image & ","); + -- Trimmed_Image : constant String := Trim(Raw_Image, Ada.Strings.Left); + Put(F,Trim(Year'Image & "-" , Ada.Strings.Left) & + Trim(Month'Image & "-" , Ada.Strings.Left) & + Trim(Day'Image & " " , Ada.Strings.Left) & + Trim(Hours'Image & ":" , Ada.Strings.Left) & + Trim(Minutes'Image & ":" , Ada.Strings.Left) & + Trim(Secs'Image & "." , Ada.Strings.Left) & + Trim(Msecs'Image & "," , Ada.Strings.Left)); end Get_Timestamp; - procedure Save_To_CSV_File (Filename : String; Utilization : Long_Float; Total_Power : Long_Float; CPU_Power : Long_Float; GPU_Power : Long_Float; Overwrite_Data : Boolean) is + procedure Save_To_CSV_File (Filename : String; Utilization : Long_Float; Total_Power : Long_Float; CPU_Power : Long_Float; GPU_Power : Long_Float; Overwrite_Data : Boolean; Save_Ms : Boolean) is F : File_Type; -- File handle Now : Time := Clock; -- Current UTC time @@ -73,7 +81,7 @@ package body CSV_Power is procedure Save_Data (F : File_Type) is begin -- Put (F, Image (Date => Now, Time_Zone => UTC_Time_Offset) & ","); -- Get time based on current timezone with UTC offset - Get_Timestamp(F); + Get_Timestamp(F, Save_Ms); Put (F, Utilization, Exp => 0, Fore => 0); -- Exp = 0 to not show in scientific notation. Fore = 0 to show all digits Put (F, ","); Put (F, Total_Power, Exp => 0, Fore => 0); @@ -104,7 +112,7 @@ package body CSV_Power is raise PROGRAM_ERROR with "Error in accessing or creating the CSV file"; end; - procedure Save_PID_To_CSV_File (Filename : String; Utilization : Long_Float; Power : Long_Float; Overwrite_Data : Boolean) is + procedure Save_PID_To_CSV_File (Filename : String; Utilization : Long_Float; Power : Long_Float; Overwrite_Data : Boolean; Save_Ms : Boolean) is F : File_Type; -- File handle Now : Time := Clock; -- Current UTC time @@ -112,7 +120,7 @@ package body CSV_Power is procedure Save_Data (F : File_Type) is begin -- Put (F, Image (Date => Now, Time_Zone => UTC_Time_Offset) & ","); -- Get time based on current timezone with UTC offset - Get_Timestamp(F); + Get_Timestamp(F, Save_Ms); Put (F, Utilization, Exp => 0, Fore => 0); -- Exp = 0 to not show in scientific notation. Fore = 0 to show all digits Put (F, ","); Put (F, Power, Exp => 0, Fore => 0); diff --git a/src/csv_power.ads b/src/csv_power.ads index 2f60207..64fa39c 100644 --- a/src/csv_power.ads +++ b/src/csv_power.ads @@ -12,10 +12,10 @@ package CSV_Power is -- Save CPU utilization and power conusmption to CSV file - procedure Save_To_CSV_File (Filename : String; Utilization : Long_Float; Total_Power : Long_Float; CPU_Power : Long_Float; GPU_Power : Long_Float; Overwrite_Data : Boolean); + procedure Save_To_CSV_File (Filename : String; Utilization : Long_Float; Total_Power : Long_Float; CPU_Power : Long_Float; GPU_Power : Long_Float; Overwrite_Data : Boolean; Save_Ms : Boolean); -- Save PID's CPU utilization and power conusmption to CSV file - procedure Save_PID_To_CSV_File (Filename : String; Utilization : Long_Float; Power : Long_Float; Overwrite_Data : Boolean); + procedure Save_PID_To_CSV_File (Filename : String; Utilization : Long_Float; Power : Long_Float; Overwrite_Data : Boolean; Save_Ms : Boolean); -- Print CPU utilization, CPU, GPU and total power conusmption on the terminal procedure Show_On_Terminal (Utilization : Long_Float; Power : Long_Float; Previous_Power : Long_Float; CPU_Power : Long_Float; GPU_Power : Long_Float; GPU_Supported : Boolean); diff --git a/src/help_info.adb b/src/help_info.adb index d57955d..f1c260a 100644 --- a/src/help_info.adb +++ b/src/help_info.adb @@ -43,6 +43,7 @@ package body Help_Info is Put_Line (HT & "-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)"); Put_Line ("You can mix options, i.e., powerjoular -tp 144 --> monitor PID 144 and will print to the terminal"); Put_Line (HT & "-k: use TIDs to calculate PID stats instead of PID stat directly (Experimental feature)"); + Put_Line (HT & "-c: save timestamps with milliseconds in CSV"); Put_Line ("--------------------------"); Put_Line (ESC & "[93m" & "Daemons/Systemd service:" & ESC & "[0m"); Put_Line ("When installing the tool, a systemd service can also be installed. The service runs PowerJoular using the -o option and saves power data to /tmp/powerjoular-service.csv"); diff --git a/src/powerjoular.adb b/src/powerjoular.adb index 07ca81a..1e4eafa 100755 --- a/src/powerjoular.adb +++ b/src/powerjoular.adb @@ -94,6 +94,7 @@ procedure Powerjoular is Monitor_App : Boolean := False; -- Monitor a specific application by its name Overwrite_Data : Boolean := false; -- Overwrite data instead of append on file TID_PID : Boolean := false; -- Use TIDs to calculate PID stats instead of PID directly (Experimental feature) + Save_Ms : Boolean := false; -- Save timestamps with milliseconds in CSV -- Procedure to capture Ctrl+C to show total energy on exit procedure CtrlCHandler is @@ -117,7 +118,7 @@ procedure Powerjoular is begin -- Loop over command line options loop - case Getopt ("h v t d f: p: a: o: u l m: s: k") is + case Getopt ("h v t d f: p: a: o: u l m: s: k c") is when 'h' => -- Show help Show_Help; OS_Exit (0); @@ -153,6 +154,8 @@ procedure Powerjoular is Monitor_VM := True; when 'k' => -- Use TIDs to calculate PID stats instead of PID stat directly (Experimental feature) TID_PID := True; + when 'c' => -- Save timestamps with milliseconds in CSV + Save_Ms := True; when others => exit; end case; @@ -356,7 +359,7 @@ begin -- Save CPU power data to CSV file of monitored PID if Print_File then - Save_PID_To_CSV_File (To_String (PID_Or_App_CSV_Filename), PID_CPU_Utilization, PID_CPU_Power, Overwrite_Data); + Save_PID_To_CSV_File (To_String (PID_Or_App_CSV_Filename), PID_CPU_Utilization, PID_CPU_Power, Overwrite_Data,Save_Ms); end if; end if; @@ -373,7 +376,7 @@ begin -- Save CPU power data to CSV file of monitored PID if Print_File then - Save_PID_To_CSV_File (To_String (PID_Or_App_CSV_Filename), App_CPU_Utilization, App_CPU_Power, Overwrite_Data); + Save_PID_To_CSV_File (To_String (PID_Or_App_CSV_Filename), App_CPU_Utilization, App_CPU_Power, Overwrite_Data,Save_Ms); end if; end if; @@ -394,7 +397,7 @@ begin -- Save total power data to CSV file if Print_File then - Save_To_CSV_File (To_String (CSV_Filename), CPU_Utilization, Total_Power, CPU_Power, GPU_Power, Overwrite_Data); + Save_To_CSV_File (To_String (CSV_Filename), CPU_Utilization, Total_Power, CPU_Power, GPU_Power, Overwrite_Data, Save_Ms); end if; end loop; end Powerjoular; From ad2dbd0a20b4b018b97cdba971baa41e434bbff7 Mon Sep 17 00:00:00 2001 From: Adel Noureddine Date: Tue, 4 Feb 2025 17:34:03 +0100 Subject: [PATCH 6/7] Styling and typos --- src/csv_power.adb | 20 ++++++++++---------- src/powerjoular.adb | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/csv_power.adb b/src/csv_power.adb index 08ba844..3d6cf49 100644 --- a/src/csv_power.adb +++ b/src/csv_power.adb @@ -16,7 +16,7 @@ with Ada.Calendar.Formatting; use Ada.Calendar.Formatting; with Ada.Calendar.Time_Zones; use Ada.Calendar.Time_Zones; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; -with Ada.Strings.Fixed; +with Ada.Strings.Fixed; use Ada.Strings.Fixed; package body CSV_Power is @@ -29,40 +29,40 @@ package body CSV_Power is Hours, Minutes, Secs, Msecs : Integer; Total_Seconds : Integer; Now : Time := Clock; -- Current UTC time - use Ada.Strings.Fixed; - begin + + begin if not Save_Ms then Put (F, Image (Date => Now, Time_Zone => UTC_Time_Offset) & ","); -- Get time based on current timezone return; end if; + Split(Current_Time, Year, Month, Day, Seconds); Total_Seconds := Integer(Seconds); - Hours := Total_Seconds / 3600; Minutes := (Total_Seconds mod 3600) / 60; Secs := Total_Seconds mod 60; Msecs := Integer((Seconds - Duration(Total_Seconds)) * 1000.0); - if Msecs < 0 then + if Msecs < 0 then Msecs := 1000 + Msecs; Secs := Secs -1; - end if; + end if; if Secs < 0 then Secs := 59; Minutes := Minutes - 1; - + if Minutes < 0 then Minutes := 59; Hours := Hours - 1; - + if Hours < 0 then Hours := 23; end if; end if; end if; - -- Trimmed_Image : constant String := Trim(Raw_Image, Ada.Strings.Left); + Put(F,Trim(Year'Image & "-" , Ada.Strings.Left) & Trim(Month'Image & "-" , Ada.Strings.Left) & Trim(Day'Image & " " , Ada.Strings.Left) & @@ -204,4 +204,4 @@ package body CSV_Power is Put (" Watts)"); end; -end CSV_Power; \ No newline at end of file +end CSV_Power; diff --git a/src/powerjoular.adb b/src/powerjoular.adb index 1e4eafa..1eef50a 100755 --- a/src/powerjoular.adb +++ b/src/powerjoular.adb @@ -359,7 +359,7 @@ begin -- Save CPU power data to CSV file of monitored PID if Print_File then - Save_PID_To_CSV_File (To_String (PID_Or_App_CSV_Filename), PID_CPU_Utilization, PID_CPU_Power, Overwrite_Data,Save_Ms); + Save_PID_To_CSV_File (To_String (PID_Or_App_CSV_Filename), PID_CPU_Utilization, PID_CPU_Power, Overwrite_Data, Save_Ms); end if; end if; @@ -376,7 +376,7 @@ begin -- Save CPU power data to CSV file of monitored PID if Print_File then - Save_PID_To_CSV_File (To_String (PID_Or_App_CSV_Filename), App_CPU_Utilization, App_CPU_Power, Overwrite_Data,Save_Ms); + Save_PID_To_CSV_File (To_String (PID_Or_App_CSV_Filename), App_CPU_Utilization, App_CPU_Power, Overwrite_Data, Save_Ms); end if; end if; From 984478e3a690a6953b8a2f3b04f211d27a206e73 Mon Sep 17 00:00:00 2001 From: Adel Noureddine Date: Tue, 4 Feb 2025 17:36:58 +0100 Subject: [PATCH 7/7] Styling and typos --- README.md | 1 + src/help_info.adb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bcf6391..c6cb857 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ The following options are available: - ```-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) - ```-k```: use TIDs to calculate PID stats instead of PID stat directly (Experimental feature) +- ```-c```: save timestamps in milliseconds (instead of just seconds) in the written CSV files You can mix options, i.e., ```powerjoular -tp 144``` will monitor PID 144 and will print to the terminal. diff --git a/src/help_info.adb b/src/help_info.adb index f1c260a..b624130 100644 --- a/src/help_info.adb +++ b/src/help_info.adb @@ -43,7 +43,7 @@ package body Help_Info is Put_Line (HT & "-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)"); Put_Line ("You can mix options, i.e., powerjoular -tp 144 --> monitor PID 144 and will print to the terminal"); Put_Line (HT & "-k: use TIDs to calculate PID stats instead of PID stat directly (Experimental feature)"); - Put_Line (HT & "-c: save timestamps with milliseconds in CSV"); + Put_Line (HT & "-c: save timestamps in milliseconds (instead of just seconds) in the written CSV files"); Put_Line ("--------------------------"); Put_Line (ESC & "[93m" & "Daemons/Systemd service:" & ESC & "[0m"); Put_Line ("When installing the tool, a systemd service can also be installed. The service runs PowerJoular using the -o option and saves power data to /tmp/powerjoular-service.csv");