From 3472ecc723a86b9ef49c6ea3edb796769af098cb Mon Sep 17 00:00:00 2001 From: bpetit Date: Tue, 11 Jul 2023 15:52:53 +0200 Subject: [PATCH 01/20] chore: new iss file to build exe package --- .gitignore | 1 + Cargo.lock | 18 ++++++++++ Cargo.toml | 1 + docs_src/scaphandre.ico | Bin 0 -> 15560 bytes packaging/windows/installer.iss | 61 ++++++++++++++++++++++++++++++++ 5 files changed, 81 insertions(+) create mode 100644 docs_src/scaphandre.ico create mode 100644 packaging/windows/installer.iss diff --git a/.gitignore b/.gitignore index 2c9f2c0b..8c53dab9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Generated by Cargo # will have compiled files and executables /target/ +/Output/ # These are backup files generated by rustfmt **/*.rs.bk diff --git a/Cargo.lock b/Cargo.lock index f6291ed5..3821d73d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1485,6 +1485,7 @@ dependencies = [ "tokio", "warp10", "windows 0.27.0", + "windows-service", ] [[package]] @@ -2035,6 +2036,12 @@ dependencies = [ "webpki", ] +[[package]] +name = "widestring" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8" + [[package]] name = "winapi" version = "0.3.9" @@ -2084,6 +2091,17 @@ dependencies = [ "windows-targets 0.48.0", ] +[[package]] +name = "windows-service" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd9db37ecb5b13762d95468a2fc6009d4b2c62801243223aabd44fca13ad13c8" +dependencies = [ + "bitflags", + "widestring", + "windows-sys 0.45.0", +] + [[package]] name = "windows-sys" version = "0.27.0" diff --git a/Cargo.toml b/Cargo.toml index 871fdf93..5b66fd3d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,6 +39,7 @@ procfs = { version = "0.15.0" } [target.'cfg(target_os="windows")'.dependencies] windows = { version = "0.27.0", features = ["alloc","Win32_Storage_FileSystem","Win32_Foundation","Win32_Security","Win32_System_IO","Win32_System_Ioctl"]} +windows-service = { version = "0.6.0" } [features] default = ["prometheus", "riemann", "warpten", "json", "containers", "prometheuspush"] diff --git a/docs_src/scaphandre.ico b/docs_src/scaphandre.ico new file mode 100644 index 0000000000000000000000000000000000000000..2431e35bc601b21fa84a99415ff5753657b3c0fb GIT binary patch literal 15560 zcmb_jg;x|`8=hU3?nVSbx*I`4x;vx=BqXJzC6+Gfl3uz)x>-^{5D*mUZlpVQKYsti zH*@C9oiq2`d*{Zy&-1+R1pv^~`QHHoXn}e$03drxM`@}n;9^l?Jtc9K6lJyld;8yo zf%bGWaVz`q-;=YOx-Mv{9E&e}j$`1Zz(EV?HRt)i-sVx?9>^3|Xjl|i zI5I|K$$d-_>O5o~aXay;LJ|i3gH@`3e4-+yW`I{UBahvk&fn$_q=3C+&S>(4q*9@)wPulF;DK7QLcJ*GTueZ(|Mx&I1Kd~piy z(+zz2T^pr%{eqzUVVngMA$;hhyS|cdqR=MoW~Xv^St+`)IqG`iHK{cN?5ktm)vQU@PZx$AAQ@uPi&3X_&1U2=<{9SZU8+%#5+u$31_G!4nVdIBsW4ATFCM!dO1r(B1sCfXt9Uve9 zakMMO#j+cgyXSsKVS{@i5u_!kXp~8vMAy~n z^r2y)&Y`5uFHm8&2_quB=*`RHP{JRPx1Lb2lavcfb0flB)y4+XwsnfD8-N5I1Sjj1 z7W}STXrUX=#`Ex%(D2l*Izp8Laje-#8A$TPmS79RY?2lU-G1!qBEs(p%mmQ--%(|e zg^tEW=e;qwbA5mt$CRSt_vV=?gdxe}6DemPk0-r770V4wxS@4H)*}2%WA}NX8Ba@sKT5vrU1x`4Bw8U?HHswSmx!sMt z?ApEs7_II@aoJ6&iI$%iCbTN}{CJKTXb^OI$&k=axiecZ^xj3JZqf=2c8B#*=S%PuGjS_}R1Z6&Tb0 zN*2l`#ZN^0IzA}`LSRqfam;CjNfMi`5|JeA05=y{8`uQ)9vaH1rbCM9%il;y4bp@} zBk^^so*%LFBxJ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^>r*TmzLo%@NkqxQ_rmw_UAJ%I)P%Zw`Wnqo1IF{# zhIIo^=f*ZhtNqbSJWY|Z84i;pciY$m?2Zul8O5v?Ln>H=*r<%CS!L&vXI19 zIC;TCzu4zV>ioaKTAkI(K~V;ai6PC1KkH5NH_ysy`*?|8zj+5sU%B33pi|Gd_?TqE zwu$oQixUl%>RD16tAbKQ5_+WMdntRKaheC*@yhRV5)tA01rL#Kl*Lo;v`@_29P6RG zkQLLE>r+vR2t*fmfI`djNo#3vLfn35(XS{|$18qc3c}SI&wzqFT1d!OJ^Ey~WWOSl zoWnT3u0x?4FMFXYl2L{fcU`=C60&>_Im6icp_ybCiP2fIGo&UWIw{8OuWq8jB1n4T z^KcQ|hm&D;M)1~)#Vp@Zuxlli#W`}OOdX+`TLv76EtHVRl z1zur9jZE9{@zptS&4-knql(b5I$MNVDdv0$?CFdwZ@WQduF4R0@Q`q%>a&0n_XypgD5fRBj%aHT6dBp zGi4w^-TBlI*FAf_=mb?MB=l)tZ9_5i4=A>QD4H&1a4}HQX)dj*P1A$w4cCghz@P1n zMFL-^(cYaE$Ao#+v&`i@JN?r8?Im$Ln6B8BL{Z;q&o=hh|9N}v(_Y^~{Z%AN8m{g~ VN#pLmr%lL!lAOA1jkJ02{{T$RRMh|g literal 0 HcmV?d00001 diff --git a/packaging/windows/installer.iss b/packaging/windows/installer.iss new file mode 100644 index 00000000..844ee657 --- /dev/null +++ b/packaging/windows/installer.iss @@ -0,0 +1,61 @@ + ; Script generated by the Inno Setup Script Wizard. +; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! + +#define MyAppName "scaphandre" +#define MyAppVersion "0.5.0" +#define MyAppPublisher "Hubblo" +#define MyAppURL "https://hubblo-org.github.io/scaphandre-documentation" +#define MyAppExeName "scaphandre.exe" +#define MyAppSourceFolder "C:\Users\bpeti\Documents\GitHub\scaphandre" +#define RaplDriverSourceFolder "C:\Users\bpeti\Documents\GitHub\windows-rapl-driver" + +[Setup] +; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications. +; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) +AppId={{7DB7B851-1DD2-4FF5-BFC7-282FEBA3B28D} +AppName={#MyAppName} +AppVersion={#MyAppVersion} +;AppVerName={#MyAppName} {#MyAppVersion} +AppPublisher={#MyAppPublisher} +AppPublisherURL={#MyAppURL} +AppSupportURL={#MyAppURL} +AppUpdatesURL={#MyAppURL} +DefaultDirName={autopf}\{#MyAppName} +DefaultGroupName={#MyAppName} +LicenseFile=C:\Users\bpeti\Documents\GitHub\scaphandre\LICENSE +; Uncomment the following line to run in non administrative install mode (install for current user only.) +;PrivilegesRequired=lowest +OutputBaseFilename={#MyAppName}_{#MyAppVersion}_installer +Compression=lzma +SolidCompression=yes +WizardStyle=modern +Uninstallable=yes +SetupIconFile=C:\Users\bpeti\Documents\GitHub\scaphandre\docs_src\scaphandre.ico + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" + +[Files] +Source: "{#MyAppSourceFolder}\target\release\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\DriverLoader.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.inf"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.sys"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.cat"; DestDir: "{app}"; Flags: ignoreversion +Source: "C:\Program Files (x86)\Windows Kits\10\Tools\10.0.22621.0\x64\devcon.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64\certmgr.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#MyAppSourceFolder}\README.md"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#MyAppSourceFolder}\CHANGELOG.md"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#RaplDriverSourceFolder}\ScaphandreDrvTest.cer"; DestDir: "{app}"; Flags: ignoreversion +; NOTE: Don't use "Flags: ignoreversion" on any shared system files + +[Icons] +Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" + +[Run] +; Filename: "{app}/DriverLoader.exe"; Parameters: "install"; WorkingDir: "{app}"; Description: "Install MSR/RAPL Driver ?"; Flags: postinstall +; Filename: "{app}/DriverLoader.exe"; Parameters: "start"; WorkingDir: "{app}"; Description: "Install MSR/RAPL Driver ?"; Flags: postinstall +Filename: "C:\windows\System32\WindowsPowershell\v1.0\powershell.exe"; Parameters: "Import-Certificate -FilePath {app}\ScaphandreDrvTest.cer -CertStoreLocation Cert:\LocalMachine\Root"; Description: "Register test certificate"; Flags: waituntilidle shellexec +Filename: "{app}\devcon.exe"; Parameters: "install {app}\ScaphandreDrv.inf root\SCAPHANDREDRV"; Description: "Install MSR/RAPL Driver ?"; Flags: postinstall waituntilidle +Filename: "{app}\devcon.exe"; Parameters: "enable {app}\ScaphandreDrv.inf root\SCAPHANDREDRV"; Description: "Enable MSR/RAPL Driver ?"; Flags: postinstall waituntilidle +; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; + From 31637202d01891a75a088befe7235a3c7af74a37 Mon Sep 17 00:00:00 2001 From: bpetit Date: Wed, 12 Jul 2023 08:44:42 +0200 Subject: [PATCH 02/20] fix: adding instance hostname label to grouping key --- src/exporters/prometheuspush.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/exporters/prometheuspush.rs b/src/exporters/prometheuspush.rs index 1451b4a8..c72b5328 100644 --- a/src/exporters/prometheuspush.rs +++ b/src/exporters/prometheuspush.rs @@ -3,6 +3,20 @@ //! `PrometheusPushExporter` implementation, push/send metrics to //! a [Prometheus](https://prometheus.io/) pushgateway. //! + +#[cfg(target_os="windows")] +extern crate windows_service; +#[cfg(target_os="windows")] +use std::{ + ffi::OsString +}; +#[cfg(target_os="windows")] +use windows_service::{ + service::ServiceControl, service::ServiceControlAccept, + service::ServiceExitCode, service::ServiceState, service::ServiceStatus, + service::ServiceType, service_control_handler::{self, ServiceControlHandlerResult} +}; + use super::utils::{format_prometheus_metric, get_hostname}; use crate::exporters::{Exporter, MetricGenerator}; use crate::sensors::{Sensor, Topology}; @@ -78,8 +92,8 @@ impl Exporter for PrometheusPushExporter { ); let uri = format!( - "{}://{}:{}/{}/job/{}", - self.args.scheme, self.args.host, self.args.port, self.args.suffix, self.args.job + "{}://{}:{}/{}/job/{}/instance/{}", + self.args.scheme, self.args.host, self.args.port, self.args.suffix, self.args.job, self.hostname.clone() ); let mut metric_generator = MetricGenerator::new( From 57fda6c8b255843009685e9fadd179b44f04470d Mon Sep 17 00:00:00 2001 From: bpetit Date: Wed, 12 Jul 2023 08:45:36 +0200 Subject: [PATCH 03/20] chore: excluding Output iss folders from git history --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8c53dab9..98738b5b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ # Generated by Cargo # will have compiled files and executables /target/ -/Output/ +**/Output/ # These are backup files generated by rustfmt **/*.rs.bk From d47b5b78d9d75af6667cad36230e0c4b41c90c69 Mon Sep 17 00:00:00 2001 From: bpetit Date: Thu, 13 Jul 2023 17:06:55 +0200 Subject: [PATCH 04/20] docs: adding windows installation instrcutions --- docs_src/tutorials/installation-windows.md | 37 ++++++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/docs_src/tutorials/installation-windows.md b/docs_src/tutorials/installation-windows.md index 6b9c15ca..55314e6f 100644 --- a/docs_src/tutorials/installation-windows.md +++ b/docs_src/tutorials/installation-windows.md @@ -1,5 +1,36 @@ -# Install Scaphandre on Windows (experimental) +# Install Scaphandre on Windows -A better procedure and packaging should come soon. +**!! Warning: This is a first testing version of the package and installation procedure.** +**!! A new version is on its way with proper driver signature and Windows service proper management.** -The release 0.5.0 of Scaphandre can be tested on windows by compiling both the kernel driver and Scaphandre. See [Compilation for Windows (experimental)](compilation-windows.md) +## Using the installer + +In this first itration of the package, you'll need to enable Test Mode on Windows prior to proceed to this installation, then reboot. (Next version will have an officially signed version of the driver, so this won't be ncessaerry anymore.) + + bcdedit.exe -set TESTSIGNING ON + +The installer will ensure that test mode is enabled and fail otherwise, but activation of test mode **and a reboot** is needed before anyway. + +Then download the [package](https://scaphandre.s3.fr-par.scw.cloud/x86_64/scaphandre_0.5.0_installer.exe) and install it **as an administrator**. + +Once installed, you should be able to run scaphandre from Powershell, by running : + + & 'C:\Program Files (x86)\scaphandre\scaphandre.exe' stdout + +## Troubleshooting + +An error such as + + scaphandre::sensors::msr_rapl: Failed to open device : HANDLE(-1) + +means that the driver is not properly setup. Check it's state by running: + + driverquery /v | findstr capha + +If there is not item returned, the installation of the driver encountered an issue. + +If the service is STOPPED, there is also something wrong. + +## Compilation + +If you look for compiling Scaphandre and its driver yourself, see [Compilation for Windows](compilation-windows.md) \ No newline at end of file From 3dde8a49492259c4eba7f3048ef3d71e86041d14 Mon Sep 17 00:00:00 2001 From: bpetit Date: Fri, 14 Jul 2023 14:08:39 +0200 Subject: [PATCH 05/20] docs: improving windows install doc --- docs_src/tutorials/installation-windows.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs_src/tutorials/installation-windows.md b/docs_src/tutorials/installation-windows.md index 55314e6f..f71a09e8 100644 --- a/docs_src/tutorials/installation-windows.md +++ b/docs_src/tutorials/installation-windows.md @@ -8,6 +8,7 @@ In this first itration of the package, you'll need to enable Test Mode on Windows prior to proceed to this installation, then reboot. (Next version will have an officially signed version of the driver, so this won't be ncessaerry anymore.) bcdedit.exe -set TESTSIGNING ON + bcdedit.exe -set nointegritychecks on The installer will ensure that test mode is enabled and fail otherwise, but activation of test mode **and a reboot** is needed before anyway. From 1410c83b9298b24695903155eaf22a9c0c434c45 Mon Sep 17 00:00:00 2001 From: bpetit Date: Fri, 14 Jul 2023 14:09:11 +0200 Subject: [PATCH 06/20] fix: changing default step value for prompush --- src/exporters/prometheuspush.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exporters/prometheuspush.rs b/src/exporters/prometheuspush.rs index c72b5328..09a5991f 100644 --- a/src/exporters/prometheuspush.rs +++ b/src/exporters/prometheuspush.rs @@ -50,7 +50,7 @@ pub struct ExporterArgs { #[arg(short = 'S', long, default_value_t = String::from("http"))] pub scheme: String, - #[arg(short, long, default_value_t = 5)] + #[arg(short, long, default_value_t = 30)] pub step: u64, /// Apply labels to metrics of processes that look like a Qemu/KVM virtual machine From cde000fcb30b12a9d37cdd9b76975450831d2fea Mon Sep 17 00:00:00 2001 From: bpetit Date: Fri, 21 Jul 2023 15:36:23 +0200 Subject: [PATCH 07/20] build: improving exe installer to get driver properlly setup --- packaging/windows/installer.iss | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/packaging/windows/installer.iss b/packaging/windows/installer.iss index 844ee657..fb06f118 100644 --- a/packaging/windows/installer.iss +++ b/packaging/windows/installer.iss @@ -8,6 +8,8 @@ #define MyAppExeName "scaphandre.exe" #define MyAppSourceFolder "C:\Users\bpeti\Documents\GitHub\scaphandre" #define RaplDriverSourceFolder "C:\Users\bpeti\Documents\GitHub\windows-rapl-driver" +#define SystemFolder "C:\Windows\System32" +#define System64Folder "C:\Windows\SysWOW64" [Setup] ; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications. @@ -37,10 +39,14 @@ Name: "english"; MessagesFile: "compiler:Default.isl" [Files] Source: "{#MyAppSourceFolder}\target\release\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion -Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\DriverLoader.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#RaplDriverSourceFolder}\x64\Release\DriverLoader.exe"; DestDir: "{app}"; Flags: ignoreversion Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.inf"; DestDir: "{app}"; Flags: ignoreversion -Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.sys"; DestDir: "{app}"; Flags: ignoreversion -Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.cat"; DestDir: "{app}"; Flags: ignoreversion +; Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.sys"; DestDir: "{#SystemFolder}"; +; Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.sys"; DestDir: "{#System64Folder}"; +Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.sys"; DestDir: "{app}"; +Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.cat"; DestDir: "{app}"; +; Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.cat"; DestDir: "{#SystemFolder}"; +; Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.cat"; DestDir: "{#System64Folder}"; Source: "C:\Program Files (x86)\Windows Kits\10\Tools\10.0.22621.0\x64\devcon.exe"; DestDir: "{app}"; Flags: ignoreversion Source: "C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64\certmgr.exe"; DestDir: "{app}"; Flags: ignoreversion Source: "{#MyAppSourceFolder}\README.md"; DestDir: "{app}"; Flags: ignoreversion @@ -52,10 +58,18 @@ Source: "{#RaplDriverSourceFolder}\ScaphandreDrvTest.cer"; DestDir: "{app}"; Fla Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" [Run] -; Filename: "{app}/DriverLoader.exe"; Parameters: "install"; WorkingDir: "{app}"; Description: "Install MSR/RAPL Driver ?"; Flags: postinstall -; Filename: "{app}/DriverLoader.exe"; Parameters: "start"; WorkingDir: "{app}"; Description: "Install MSR/RAPL Driver ?"; Flags: postinstall Filename: "C:\windows\System32\WindowsPowershell\v1.0\powershell.exe"; Parameters: "Import-Certificate -FilePath {app}\ScaphandreDrvTest.cer -CertStoreLocation Cert:\LocalMachine\Root"; Description: "Register test certificate"; Flags: waituntilidle shellexec -Filename: "{app}\devcon.exe"; Parameters: "install {app}\ScaphandreDrv.inf root\SCAPHANDREDRV"; Description: "Install MSR/RAPL Driver ?"; Flags: postinstall waituntilidle -Filename: "{app}\devcon.exe"; Parameters: "enable {app}\ScaphandreDrv.inf root\SCAPHANDREDRV"; Description: "Enable MSR/RAPL Driver ?"; Flags: postinstall waituntilidle +Filename: "{app}/devcon.exe"; Parameters: "install {app}\ScaphandreDrv.inf root\SCAPHANDREDRV"; Description: "Install Driver"; Flags: waituntilidle +Filename: "{app}/devcon.exe"; Parameters: "enable {app}\ScaphandreDrv.inf root\SCAPHANDREDRV"; Description: "Enable Driver"; Flags: waituntilidle +Filename: "{app}/DriverLoader.exe"; Parameters: "install"; WorkingDir: "{app}"; Description: "Install Driver Service"; +Filename: "{app}/DriverLoader.exe"; Parameters: "start"; WorkingDir: "{app}"; Description: "Start Driver Service"; ; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; +; Filename: "schtasks.exe"; Parameters: "/Create /SC ONSTART {app}\scaphandre.exe prometheus-push " + +[UninstallRun] +Filename: "{app}/DriverLoader.exe"; Parameters: "stop"; WorkingDir: "{app}"; RunOnceId: "StopService"; +Filename: "{app}/DriverLoader.exe"; Parameters: "remove"; WorkingDir: "{app}"; RunOnceId: "RemoveService"; +Filename: "{app}/devcon.exe"; Parameters: "disable ScaphandreDrv"; RunOnceId: "DisableDrier"; +Filename: "{app}/devcon.exe"; Parameters: "remove ScaphandreDrv"; RunOnceId: "RemoveService"; + From f24e5d16040caf74771adc8980a3f854ad69984b Mon Sep 17 00:00:00 2001 From: bpetit Date: Fri, 21 Jul 2023 15:37:03 +0200 Subject: [PATCH 08/20] chore: first try on argfile --- Cargo.lock | 19 +++++++++++++++++++ Cargo.toml | 1 + src/main.rs | 41 +++++++++++++++++++++++++++++++++-------- 3 files changed, 53 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3821d73d..467e5e11 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -84,6 +84,15 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "argfile" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "265f5108974489a217d5098cd81666b60480c8dd67302acbbe7cbdd8aa09d638" +dependencies = [ + "os_str_bytes", +] + [[package]] name = "async-channel" version = "1.8.0" @@ -1128,6 +1137,15 @@ dependencies = [ "num-traits", ] +[[package]] +name = "os_str_bytes" +version = "6.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac" +dependencies = [ + "memchr", +] + [[package]] name = "parking" version = "2.1.0" @@ -1462,6 +1480,7 @@ checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" name = "scaphandre" version = "0.5.0" dependencies = [ + "argfile", "chrono", "clap", "colored", diff --git a/Cargo.toml b/Cargo.toml index 5b66fd3d..39fd0be3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,7 @@ hyper = { version = "0.14", features = ["full"], optional = true } tokio = { version = "1.26.0", features = ["full"], optional = true} sysinfo = { version = "0.28.3"} isahc = { version = "1.7.2", optional = true } +argfile = { version = "0.1.5" } [target.'cfg(target_os="linux")'.dependencies] procfs = { version = "0.15.0" } diff --git a/src/main.rs b/src/main.rs index d01ce7cb..78af2d76 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,7 @@ use clap::{command, ArgAction, Parser, Subcommand}; use colored::Colorize; use scaphandre::{exporters, sensors::Sensor}; +use argfile::expand_args; #[cfg(target_os = "linux")] use scaphandre::sensors::powercap_rapl; @@ -101,15 +102,27 @@ fn main() { fn build_exporter(choice: ExporterChoice, sensor: &dyn Sensor) -> Box { match choice { ExporterChoice::Stdout(args) => { - Box::new(exporters::stdout::StdoutExporter::new(sensor, args)) + if let Ok(args_from_file) = expand_args(argfile::parse_fromfile, argfile::PREFIX) { + Box::new(exporters::stdout::StdoutExporter::new(sensor, args_from_file)) + } else { + Box::new(exporters::stdout::StdoutExporter::new(sensor, args)) + } } #[cfg(feature = "json")] ExporterChoice::Json(args) => { - Box::new(exporters::json::JsonExporter::new(sensor, args)) // keep this in braces + if let Ok(args_from_file) = expand_args(argfile::parse_fromfile, argfile::PREFIX) { + Box::new(exporters::json::JsonExporter::new(sensor, args_from_file)) + } else { + Box::new(exporters::json::JsonExporter::new(sensor, args)) // keep this in braces + } } #[cfg(feature = "prometheus")] ExporterChoice::Prometheus(args) => { - Box::new(exporters::prometheus::PrometheusExporter::new(sensor, args)) + if let Ok(args_from_file) = expand_args(argfile::parse_fromfile, argfile::PREFIX) { + Box::new(exporters::prometheus::PrometheusExporter::new(sensor, args_from_file)) + } else { + Box::new(exporters::prometheus::PrometheusExporter::new(sensor, args)) + } } #[cfg(feature = "qemu")] ExporterChoice::Qemu => { @@ -117,16 +130,28 @@ fn build_exporter(choice: ExporterChoice, sensor: &dyn Sensor) -> Box { - Box::new(exporters::riemann::RiemannExporter::new(sensor, args)) + if let Ok(args_from_file) = expand_args(argfile::parse_fromfile, argfile::PREFIX) { + Box::new(exporters::riemann::RiemannExporter::new(sensor, args_from_file)) + } else { + Box::new(exporters::riemann::RiemannExporter::new(sensor, args)) + } } #[cfg(feature = "warpten")] ExporterChoice::Warpten(args) => { - Box::new(exporters::warpten::Warp10Exporter::new(sensor, args)) + if let Ok(args_from_file) = expand_args(argfile::parse_fromfile, argfile::PREFIX) { + Box::new(exporters::warpten::Warp10Exporter::new(sensor, args_from_file)) + } else { + Box::new(exporters::warpten::Warp10Exporter::new(sensor, args)) + } } #[cfg(feature = "prometheuspush")] - ExporterChoice::PrometheusPush(args) => Box::new( - exporters::prometheuspush::PrometheusPushExporter::new(sensor, args), - ), + ExporterChoice::PrometheusPush(args) => { + if let Ok(args_from_file) = expand_args(argfile::parse_fromfile, argfile::PREFIX) { + Box::new(exporters::prometheuspush::PrometheusPushExporter::new(sensor, args_from_file)) + } else { + Box::new(exporters::prometheuspush::PrometheusPushExporter::new(sensor, args)) + } + }, } // Note that invalid choices are automatically turned into errors by `parse()` before the Cli is populated, // that's why they don't appear in this function. From 193235e5f6ca33824b6522c8c8f70e3ae7f9f427 Mon Sep 17 00:00:00 2001 From: bpetit Date: Tue, 25 Jul 2023 18:20:50 +0200 Subject: [PATCH 09/20] clean: removing useless sample metric --- src/exporters/prometheuspush.rs | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/exporters/prometheuspush.rs b/src/exporters/prometheuspush.rs index 09a5991f..a5cd5de1 100644 --- a/src/exporters/prometheuspush.rs +++ b/src/exporters/prometheuspush.rs @@ -4,19 +4,6 @@ //! a [Prometheus](https://prometheus.io/) pushgateway. //! -#[cfg(target_os="windows")] -extern crate windows_service; -#[cfg(target_os="windows")] -use std::{ - ffi::OsString -}; -#[cfg(target_os="windows")] -use windows_service::{ - service::ServiceControl, service::ServiceControlAccept, - service::ServiceExitCode, service::ServiceState, service::ServiceStatus, - service::ServiceType, service_control_handler::{self, ServiceControlHandlerResult} -}; - use super::utils::{format_prometheus_metric, get_hostname}; use crate::exporters::{Exporter, MetricGenerator}; use crate::sensors::{Sensor, Topology}; @@ -106,9 +93,7 @@ impl Exporter for PrometheusPushExporter { loop { metric_generator.topology.refresh(); metric_generator.gen_all_metrics(); - let mut body = String::from( - "# HELP mymetric this is my metric\n# TYPE mymetric gauge\nmymetric 50\n", - ); + let mut body = String::from(""); let mut metrics_pushed: Vec = vec![]; //let mut counter = 0; for mut m in metric_generator.pop_metrics() { @@ -167,6 +152,7 @@ impl Exporter for PrometheusPushExporter { thread::sleep(Duration::new(self.args.step, 0)); } + } fn kind(&self) -> &str { From c9d5547bc5553bab34706c5bf2b653af3120d4a7 Mon Sep 17 00:00:00 2001 From: bpetit Date: Tue, 25 Jul 2023 18:52:08 +0200 Subject: [PATCH 10/20] feat: adding basic windows service management support --- Cargo.lock | 19 -------- Cargo.toml | 1 - src/main.rs | 122 +++++++++++++++++++++++++++++++++++++++------------- 3 files changed, 91 insertions(+), 51 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 467e5e11..3821d73d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -84,15 +84,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "argfile" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "265f5108974489a217d5098cd81666b60480c8dd67302acbbe7cbdd8aa09d638" -dependencies = [ - "os_str_bytes", -] - [[package]] name = "async-channel" version = "1.8.0" @@ -1137,15 +1128,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "os_str_bytes" -version = "6.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac" -dependencies = [ - "memchr", -] - [[package]] name = "parking" version = "2.1.0" @@ -1480,7 +1462,6 @@ checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" name = "scaphandre" version = "0.5.0" dependencies = [ - "argfile", "chrono", "clap", "colored", diff --git a/Cargo.toml b/Cargo.toml index 39fd0be3..5b66fd3d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,6 @@ hyper = { version = "0.14", features = ["full"], optional = true } tokio = { version = "1.26.0", features = ["full"], optional = true} sysinfo = { version = "0.28.3"} isahc = { version = "1.7.2", optional = true } -argfile = { version = "0.1.5" } [target.'cfg(target_os="linux")'.dependencies] procfs = { version = "0.15.0" } diff --git a/src/main.rs b/src/main.rs index 78af2d76..5c11e06a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,6 @@ use clap::{command, ArgAction, Parser, Subcommand}; use colored::Colorize; use scaphandre::{exporters, sensors::Sensor}; -use argfile::expand_args; #[cfg(target_os = "linux")] use scaphandre::sensors::powercap_rapl; @@ -11,6 +10,29 @@ use scaphandre::sensors::powercap_rapl; #[cfg(target_os = "windows")] use scaphandre::sensors::msr_rapl; +#[cfg(target_os="windows")] +use windows_service::{ + Result, service_dispatcher, + service::ServiceControl, service::ServiceControlAccept, + service::ServiceExitCode, service::ServiceState, service::ServiceStatus, + service::ServiceType, service_control_handler::{self, ServiceControlHandlerResult} +}; + +#[cfg(target_os="windows")] +define_windows_service!(ffi_service_main, my_service_main); + +#[cfg(target_os="windows")] +#[macro_use] +extern crate windows_service; + +#[cfg(target_os="windows")] +use std::time::Duration; + +#[cfg(target_os="windows")] +use std::{ + ffi::OsString +}; + // the struct below defines the main Scaphandre command-line interface /// Extensible metrology agent for electricity consumption related metrics. #[derive(Parser)] @@ -86,7 +108,69 @@ enum ExporterChoice { PrometheusPush(exporters::prometheuspush::ExporterArgs), } +#[cfg(target_os="windows")] +fn my_service_main(arguments: Vec) { + if let Err(_e) = run_service(arguments) { + // Handle errors in some way. + } +} + +#[cfg(target_os="windows")] +fn run_service(arguments: Vec) -> Result<()> { + #[cfg(target_os="windows")] + let event_handler = move |control_event| -> ServiceControlHandlerResult { + match control_event { + ServiceControl::Stop => { + // Handle stop event and return control back to the system. + ServiceControlHandlerResult::NoError + } + // All services must accept Interrogate even if it's a no-op. + ServiceControl::Interrogate => ServiceControlHandlerResult::NoError, + _ => ServiceControlHandlerResult::NotImplemented, + } + }; + #[cfg(target_os="windows")] + if let Ok(system_handler) = service_control_handler::register("Scaphandre", event_handler) { + let next_status = ServiceStatus { + // Should match the one from system service registry + service_type: ServiceType::OWN_PROCESS, + // The new state + current_state: ServiceState::Running, + // Accept stop events when running + controls_accepted: ServiceControlAccept::STOP, + // Used to report an error when starting or stopping only, otherwise must be zero + exit_code: ServiceExitCode::Win32(0), + // Only used for pending states, otherwise must be zero + checkpoint: 0, + // Only used for pending states, otherwise must be zero + wait_hint: Duration::default(), + // Unused for setting status + process_id: None, + }; + + // Tell the system that the service is running now + if let Ok(status_set) = system_handler.set_service_status(next_status) { + parse_cli_and_run_exporter(); + } else { + panic!("Couldn't set Windows service status."); + } + } else { + panic!("Couldn't get Windows system events handler."); + } + Ok(()) +} + fn main() { + #[cfg(target_os="windows")] + match service_dispatcher::start("Scaphandre", ffi_service_main) { + Ok(_) => { }, + Err(e) => { println!("Couldn't start Windows service dispatcher. Got : {}", e); } + } + + parse_cli_and_run_exporter(); +} + +fn parse_cli_and_run_exporter() { let cli = Cli::parse(); loggerv::init_with_verbosity(cli.verbose.into()).expect("unable to initialize the logger"); @@ -102,27 +186,15 @@ fn main() { fn build_exporter(choice: ExporterChoice, sensor: &dyn Sensor) -> Box { match choice { ExporterChoice::Stdout(args) => { - if let Ok(args_from_file) = expand_args(argfile::parse_fromfile, argfile::PREFIX) { - Box::new(exporters::stdout::StdoutExporter::new(sensor, args_from_file)) - } else { - Box::new(exporters::stdout::StdoutExporter::new(sensor, args)) - } + Box::new(exporters::stdout::StdoutExporter::new(sensor, args)) } #[cfg(feature = "json")] ExporterChoice::Json(args) => { - if let Ok(args_from_file) = expand_args(argfile::parse_fromfile, argfile::PREFIX) { - Box::new(exporters::json::JsonExporter::new(sensor, args_from_file)) - } else { - Box::new(exporters::json::JsonExporter::new(sensor, args)) // keep this in braces - } + Box::new(exporters::json::JsonExporter::new(sensor, args)) // keep this in braces } #[cfg(feature = "prometheus")] ExporterChoice::Prometheus(args) => { - if let Ok(args_from_file) = expand_args(argfile::parse_fromfile, argfile::PREFIX) { - Box::new(exporters::prometheus::PrometheusExporter::new(sensor, args_from_file)) - } else { - Box::new(exporters::prometheus::PrometheusExporter::new(sensor, args)) - } + Box::new(exporters::prometheus::PrometheusExporter::new(sensor, args)) } #[cfg(feature = "qemu")] ExporterChoice::Qemu => { @@ -130,27 +202,15 @@ fn build_exporter(choice: ExporterChoice, sensor: &dyn Sensor) -> Box { - if let Ok(args_from_file) = expand_args(argfile::parse_fromfile, argfile::PREFIX) { - Box::new(exporters::riemann::RiemannExporter::new(sensor, args_from_file)) - } else { - Box::new(exporters::riemann::RiemannExporter::new(sensor, args)) - } + Box::new(exporters::riemann::RiemannExporter::new(sensor, args)) } #[cfg(feature = "warpten")] ExporterChoice::Warpten(args) => { - if let Ok(args_from_file) = expand_args(argfile::parse_fromfile, argfile::PREFIX) { - Box::new(exporters::warpten::Warp10Exporter::new(sensor, args_from_file)) - } else { - Box::new(exporters::warpten::Warp10Exporter::new(sensor, args)) - } + Box::new(exporters::warpten::Warp10Exporter::new(sensor, args)) } #[cfg(feature = "prometheuspush")] ExporterChoice::PrometheusPush(args) => { - if let Ok(args_from_file) = expand_args(argfile::parse_fromfile, argfile::PREFIX) { - Box::new(exporters::prometheuspush::PrometheusPushExporter::new(sensor, args_from_file)) - } else { - Box::new(exporters::prometheuspush::PrometheusPushExporter::new(sensor, args)) - } + Box::new(exporters::prometheuspush::PrometheusPushExporter::new(sensor, args)) }, } // Note that invalid choices are automatically turned into errors by `parse()` before the Cli is populated, From dbdbc774ef74a9cfaea93a1de0d7d44fcd1bca10 Mon Sep 17 00:00:00 2001 From: bpetit Date: Tue, 25 Jul 2023 19:07:46 +0200 Subject: [PATCH 11/20] style: clippy and fmt --- src/exporters/json.rs | 1 + src/exporters/mod.rs | 3 ++ src/exporters/prometheuspush.rs | 1 - src/lib.rs | 2 ++ src/main.rs | 56 ++++++++++++++++++--------------- 5 files changed, 36 insertions(+), 27 deletions(-) diff --git a/src/exporters/json.rs b/src/exporters/json.rs index f0cd1b51..1abaae88 100644 --- a/src/exporters/json.rs +++ b/src/exporters/json.rs @@ -340,6 +340,7 @@ impl JsonExporter { .proc_tracker .get_filtered_processes(regex_filter) } else if let Some(regex_filter) = &self.container_regex { + debug!("Processes filtered by '{}':", regex_filter.as_str()); #[cfg(feature = "containers")] { self.metric_generator diff --git a/src/exporters/mod.rs b/src/exporters/mod.rs index 2d03b6d0..4d054a4e 100644 --- a/src/exporters/mod.rs +++ b/src/exporters/mod.rs @@ -43,12 +43,15 @@ pub struct Metric { /// `metric_type` mostly used by Prometheus, define is it is a gauge, counter... metric_type: String, /// `ttl` time to live for this metric used by Riemann. + #[allow(dead_code)] ttl: f32, /// `hostname` host that provides the metric. hostname: String, /// `state` used by Riemann, define a state like Ok or Ko regarding this metric. + #[allow(dead_code)] state: String, /// `tags` used by Riemann, tags attached to the metric. + #[allow(dead_code)] tags: Vec, /// `attributes` used by exporters to better qualify the metric. In Prometheus context /// this is used as a metric tag (socket_id) : `scaph_self_socket_stats_nb{socket_id="0"} 2`. diff --git a/src/exporters/prometheuspush.rs b/src/exporters/prometheuspush.rs index 3d2755a1..b460c45c 100644 --- a/src/exporters/prometheuspush.rs +++ b/src/exporters/prometheuspush.rs @@ -157,7 +157,6 @@ impl Exporter for PrometheusPushExporter { thread::sleep(Duration::new(self.args.step, 0)); } - } fn kind(&self) -> &str { diff --git a/src/lib.rs b/src/lib.rs index b19e66bf..2a4e2b21 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,6 +14,7 @@ use sensors::msr_rapl; #[cfg(target_os = "linux")] use sensors::powercap_rapl; +#[cfg(target_os = "linux")] use std::time::{Duration, SystemTime}; /// Create a new [`Sensor`] instance with the default sensor available, @@ -30,6 +31,7 @@ pub fn get_default_sensor() -> impl sensors::Sensor { return msr_rapl::MsrRAPLSensor::new(); } +#[cfg(target_os = "linux")] fn current_system_time_since_epoch() -> Duration { SystemTime::now() .duration_since(SystemTime::UNIX_EPOCH) diff --git a/src/main.rs b/src/main.rs index 5c11e06a..83db7998 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,28 +10,30 @@ use scaphandre::sensors::powercap_rapl; #[cfg(target_os = "windows")] use scaphandre::sensors::msr_rapl; -#[cfg(target_os="windows")] +#[cfg(target_os = "windows")] use windows_service::{ - Result, service_dispatcher, - service::ServiceControl, service::ServiceControlAccept, - service::ServiceExitCode, service::ServiceState, service::ServiceStatus, - service::ServiceType, service_control_handler::{self, ServiceControlHandlerResult} + service::ServiceControl, + service::ServiceControlAccept, + service::ServiceExitCode, + service::ServiceState, + service::ServiceStatus, + service::ServiceType, + service_control_handler::{self, ServiceControlHandlerResult}, + service_dispatcher, Result, }; -#[cfg(target_os="windows")] +#[cfg(target_os = "windows")] define_windows_service!(ffi_service_main, my_service_main); -#[cfg(target_os="windows")] +#[cfg(target_os = "windows")] #[macro_use] extern crate windows_service; -#[cfg(target_os="windows")] +#[cfg(target_os = "windows")] use std::time::Duration; -#[cfg(target_os="windows")] -use std::{ - ffi::OsString -}; +#[cfg(target_os = "windows")] +use std::ffi::OsString; // the struct below defines the main Scaphandre command-line interface /// Extensible metrology agent for electricity consumption related metrics. @@ -108,16 +110,16 @@ enum ExporterChoice { PrometheusPush(exporters::prometheuspush::ExporterArgs), } -#[cfg(target_os="windows")] +#[cfg(target_os = "windows")] fn my_service_main(arguments: Vec) { if let Err(_e) = run_service(arguments) { // Handle errors in some way. } } -#[cfg(target_os="windows")] -fn run_service(arguments: Vec) -> Result<()> { - #[cfg(target_os="windows")] +#[cfg(target_os = "windows")] +fn run_service(_arguments: Vec) -> Result<()> { + #[cfg(target_os = "windows")] let event_handler = move |control_event| -> ServiceControlHandlerResult { match control_event { ServiceControl::Stop => { @@ -129,7 +131,7 @@ fn run_service(arguments: Vec) -> Result<()> { _ => ServiceControlHandlerResult::NotImplemented, } }; - #[cfg(target_os="windows")] + #[cfg(target_os = "windows")] if let Ok(system_handler) = service_control_handler::register("Scaphandre", event_handler) { let next_status = ServiceStatus { // Should match the one from system service registry @@ -147,9 +149,9 @@ fn run_service(arguments: Vec) -> Result<()> { // Unused for setting status process_id: None, }; - + // Tell the system that the service is running now - if let Ok(status_set) = system_handler.set_service_status(next_status) { + if let Ok(_status_set) = system_handler.set_service_status(next_status) { parse_cli_and_run_exporter(); } else { panic!("Couldn't set Windows service status."); @@ -161,10 +163,12 @@ fn run_service(arguments: Vec) -> Result<()> { } fn main() { - #[cfg(target_os="windows")] + #[cfg(target_os = "windows")] match service_dispatcher::start("Scaphandre", ffi_service_main) { - Ok(_) => { }, - Err(e) => { println!("Couldn't start Windows service dispatcher. Got : {}", e); } + Ok(_) => {} + Err(e) => { + println!("Couldn't start Windows service dispatcher. Got : {}", e); + } } parse_cli_and_run_exporter(); @@ -209,9 +213,9 @@ fn build_exporter(choice: ExporterChoice, sensor: &dyn Sensor) -> Box { - Box::new(exporters::prometheuspush::PrometheusPushExporter::new(sensor, args)) - }, + ExporterChoice::PrometheusPush(args) => Box::new( + exporters::prometheuspush::PrometheusPushExporter::new(sensor, args), + ), } // Note that invalid choices are automatically turned into errors by `parse()` before the Cli is populated, // that's why they don't appear in this function. @@ -231,7 +235,7 @@ fn build_sensor(cli: &Cli) -> impl Sensor { }; #[cfg(target_os = "windows")] - let msr_sensor_win = || msr_rapl::MsrRAPLSensor::new(); + let msr_sensor_win = msr_rapl::MsrRAPLSensor::new; match cli.sensor.as_deref() { Some("powercap_rapl") => { From b115bc34ca996c429a871508f63c348eeca161bb Mon Sep 17 00:00:00 2001 From: bpetit Date: Tue, 25 Jul 2023 19:14:05 +0200 Subject: [PATCH 12/20] fix: removed fn not needed in conditional compilation but needed otherwise --- src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 2a4e2b21..c5f6e634 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -31,7 +31,6 @@ pub fn get_default_sensor() -> impl sensors::Sensor { return msr_rapl::MsrRAPLSensor::new(); } -#[cfg(target_os = "linux")] fn current_system_time_since_epoch() -> Duration { SystemTime::now() .duration_since(SystemTime::UNIX_EPOCH) From c02506379724b071551cb9b532b80896cff07416 Mon Sep 17 00:00:00 2001 From: bpetit Date: Wed, 26 Jul 2023 12:11:00 +0200 Subject: [PATCH 13/20] style: clippy rules --- src/exporters/json.rs | 2 +- src/lib.rs | 1 - src/sensors/mod.rs | 3 +-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/exporters/json.rs b/src/exporters/json.rs index 1abaae88..c448cd4f 100644 --- a/src/exporters/json.rs +++ b/src/exporters/json.rs @@ -228,7 +228,7 @@ impl JsonExporter { let mut res: Vec = vec![]; for m in metrics { let metric_disk_name = m.attributes.get("disk_name").unwrap(); - if let Some(mut disk) = res.iter_mut().find(|x| metric_disk_name == &x.disk_name) { + if let Some(disk) = res.iter_mut().find(|x| metric_disk_name == &x.disk_name) { info!("editing disk"); disk.disk_name = metric_disk_name.clone(); if m.name == "scaph_host_disk_available_bytes" { diff --git a/src/lib.rs b/src/lib.rs index c5f6e634..b19e66bf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,7 +14,6 @@ use sensors::msr_rapl; #[cfg(target_os = "linux")] use sensors::powercap_rapl; -#[cfg(target_os = "linux")] use std::time::{Duration, SystemTime}; /// Create a new [`Sensor`] instance with the default sensor available, diff --git a/src/sensors/mod.rs b/src/sensors/mod.rs index 1d9fd3e8..fa89aa1e 100644 --- a/src/sensors/mod.rs +++ b/src/sensors/mod.rs @@ -276,8 +276,7 @@ impl Topology { /// to appropriate CPUSocket instance from self.sockets pub fn add_cpu_cores(&mut self) { if let Some(mut cores) = Topology::generate_cpu_cores() { - while !cores.is_empty() { - let c = cores.pop().unwrap(); + while let Some(c) = cores.pop() { let socket_id = &c .attributes .get("physical id") From 8a5ff5b0c0fd633fcb7ec78fbdf2890dab9df4bc Mon Sep 17 00:00:00 2001 From: bpetit Date: Wed, 26 Jul 2023 15:25:38 +0200 Subject: [PATCH 14/20] ci: adding sample job to build and publish exe installer --- .github/bloat-test.yml | 31 -------- .../workflows/exe-release-prometheuspush.yml | 78 +++++++++++++++++++ 2 files changed, 78 insertions(+), 31 deletions(-) delete mode 100644 .github/bloat-test.yml create mode 100644 .github/workflows/exe-release-prometheuspush.yml diff --git a/.github/bloat-test.yml b/.github/bloat-test.yml deleted file mode 100644 index e6462579..00000000 --- a/.github/bloat-test.yml +++ /dev/null @@ -1,31 +0,0 @@ -#name: Check changes in binary size -# -#on: -# push: -# branches: [ main ] -# paths-ignore: -# - 'docs_src/**' -# - 'README.md' -# - 'CHANGELOG.md' -# - 'CITATION' -# - 'book.toml' -# pull_request: -# branches: [ main ] -# paths-ignore: -# - 'docs_src/**' -# - 'README.md' -# - 'CHANGELOG.md' -# - 'CITATION' -# - 'book.toml' -# -#jobs: -# bloat_test: -# name: Cargo Fmt and Clippy - Linux -# runs-on: ubuntu-latest -# steps: -# - name: Checkout repository -# uses: actions/checkout@v2 -# - name: Run cargo bloat -# uses: orf/cargo-bloat-action@v1 -# with: -# token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/exe-release-prometheuspush.yml b/.github/workflows/exe-release-prometheuspush.yml new file mode 100644 index 00000000..8e4c8917 --- /dev/null +++ b/.github/workflows/exe-release-prometheuspush.yml @@ -0,0 +1,78 @@ +name: Build exe installer for windows for prometheus-push only version + +on: + push: + paths-ignore: + - 'docs_src/**' + - 'README.md' + - 'CITATION' + - 'book.toml' + - 'CONTRIBUTING.md' + tags: [ 'v*.*.*', 'dev*.*.*' ] + branches: [ '311-github-workflow-to-build-and-publish-a-exemsi-file-including-signed-rapl-driver-at-each-tagrelease' ] + +jobs: + build_exe_win1011: + name: Build exe installer for windows 10/11/server 2016/server 2019/server 2022 + runs-on: windows + steps: + - name: Checkout + uses: actions/checkout@v3 + - uses: Swatinem/rust-cache@v2 + with: + # The prefix cache key, this can be changed to start a new cache manually. + # default: "v0-rust" + prefix-key: "" + + # A cache key that is used instead of the automatic `job`-based key, + # and is stable over multiple jobs. + # default: empty + shared-key: "" + + # An additional cache key that is added alongside the automatic `job`-based + # cache key and can be used to further differentiate jobs. + # default: empty + key: "" + + # A whitespace separated list of env-var *prefixes* who's value contributes + # to the environment cache key. + # The env-vars are matched by *prefix*, so the default `RUST` var will + # match all of `RUSTC`, `RUSTUP_*`, `RUSTFLAGS`, `RUSTDOC_*`, etc. + # default: "CARGO CC CFLAGS CXX CMAKE RUST" + env-vars: "" + + # The cargo workspaces and target directory configuration. + # These entries are separated by newlines and have the form + # `$workspace -> $target`. The `$target` part is treated as a directory + # relative to the `$workspace` and defaults to "target" if not explicitly given. + # default: ". -> target" + workspaces: "" + + # Additional non workspace directories to be cached, separated by newlines. + cache-directories: "" + + # Determines whether workspace `target` directories are cached. + # If `false`, only the cargo registry will be cached. + # default: "true" + cache-targets: "" + + # Determines if the cache should be saved even when the workflow has failed. + # default: "false" + cache-on-failure: "" + + # Determines which crates are cached. + # If `true` all crates will be cached, otherwise only dependent crates will be cached. + # Useful if additional crates are used for CI tooling. + # default: "false" + cache-all-crates: "" + + # Determiners whether the cache should be saved. + # If `false`, the cache is only restored. + # Useful for jobs where the matrix is additive e.g. additional Cargo features. + # default: "true" + save-if: "" + - name: Install Innosoft + run: | + $url = "https://jrsoftware.org/download.php/is.exe" + $dest = "is.exe" + Invoke-WebRequest -Uri $url -OutFile $dest \ No newline at end of file From de1095cbcac653cfa9df2c9e8602a96b9a58d086 Mon Sep 17 00:00:00 2001 From: bpetit Date: Wed, 26 Jul 2023 15:48:19 +0200 Subject: [PATCH 15/20] ci: fix job label --- .github/workflows/exe-release-prometheuspush.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/exe-release-prometheuspush.yml b/.github/workflows/exe-release-prometheuspush.yml index 8e4c8917..6d4031d2 100644 --- a/.github/workflows/exe-release-prometheuspush.yml +++ b/.github/workflows/exe-release-prometheuspush.yml @@ -14,7 +14,7 @@ on: jobs: build_exe_win1011: name: Build exe installer for windows 10/11/server 2016/server 2019/server 2022 - runs-on: windows + runs-on: "windows-2019" steps: - name: Checkout uses: actions/checkout@v3 From 67d3fb6c0b37ddd1c591e613e7c414c131e84442 Mon Sep 17 00:00:00 2001 From: bpetit Date: Wed, 26 Jul 2023 17:00:21 +0200 Subject: [PATCH 16/20] ci: checkout windows rapl driver to be able to build full exe --- .../workflows/exe-release-prometheuspush.yml | 74 ++++++------------- 1 file changed, 21 insertions(+), 53 deletions(-) diff --git a/.github/workflows/exe-release-prometheuspush.yml b/.github/workflows/exe-release-prometheuspush.yml index 6d4031d2..b019c987 100644 --- a/.github/workflows/exe-release-prometheuspush.yml +++ b/.github/workflows/exe-release-prometheuspush.yml @@ -18,61 +18,29 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - uses: Swatinem/rust-cache@v2 with: - # The prefix cache key, this can be changed to start a new cache manually. - # default: "v0-rust" - prefix-key: "" - - # A cache key that is used instead of the automatic `job`-based key, - # and is stable over multiple jobs. - # default: empty - shared-key: "" - - # An additional cache key that is added alongside the automatic `job`-based - # cache key and can be used to further differentiate jobs. - # default: empty - key: "" - - # A whitespace separated list of env-var *prefixes* who's value contributes - # to the environment cache key. - # The env-vars are matched by *prefix*, so the default `RUST` var will - # match all of `RUSTC`, `RUSTUP_*`, `RUSTFLAGS`, `RUSTDOC_*`, etc. - # default: "CARGO CC CFLAGS CXX CMAKE RUST" - env-vars: "" - - # The cargo workspaces and target directory configuration. - # These entries are separated by newlines and have the form - # `$workspace -> $target`. The `$target` part is treated as a directory - # relative to the `$workspace` and defaults to "target" if not explicitly given. - # default: ". -> target" - workspaces: "" - - # Additional non workspace directories to be cached, separated by newlines. - cache-directories: "" - - # Determines whether workspace `target` directories are cached. - # If `false`, only the cargo registry will be cached. - # default: "true" - cache-targets: "" - - # Determines if the cache should be saved even when the workflow has failed. - # default: "false" - cache-on-failure: "" - - # Determines which crates are cached. - # If `true` all crates will be cached, otherwise only dependent crates will be cached. - # Useful if additional crates are used for CI tooling. - # default: "false" - cache-all-crates: "" - - # Determiners whether the cache should be saved. - # If `false`, the cache is only restored. - # Useful for jobs where the matrix is additive e.g. additional Cargo features. - # default: "true" - save-if: "" + path: scaphandre + - name: Checkout + uses: actions/checkout@v3 + with: + repository: hubblo-org/windows-rapl-driver.git + ref: master + path: windows-rapl-driver - name: Install Innosoft run: | $url = "https://jrsoftware.org/download.php/is.exe" $dest = "is.exe" - Invoke-WebRequest -Uri $url -OutFile $dest \ No newline at end of file + Invoke-WebRequest -Uri $url -OutFile $dest + ls + & "$dest" /verysilent /suppressmsgbox + ls "C:\Program Files (x86)\" + - name: Install Rustup + uses: crazy-max/ghaction-chocolatey@v2 + with: + args: install rustup.install --ignore-checksums + - name: Install Rust toolchain + run: | + rustup toolchain install stable-x86_64-pc-windows-msvc + - name: Build (debug mode) + run: | + cargo build --release --no-default-features --features "prometheuspush json" \ No newline at end of file From b8be3e2230be819f4b91bae9ebf23e07433770a2 Mon Sep 17 00:00:00 2001 From: bpetit Date: Wed, 26 Jul 2023 17:28:04 +0200 Subject: [PATCH 17/20] ci: fixing exe push to s3 --- .../workflows/exe-release-prometheuspush.yml | 53 ++++++++++++++----- packaging/windows/installer.iss | 35 ++++++------ 2 files changed, 57 insertions(+), 31 deletions(-) diff --git a/.github/workflows/exe-release-prometheuspush.yml b/.github/workflows/exe-release-prometheuspush.yml index b019c987..706b2a7c 100644 --- a/.github/workflows/exe-release-prometheuspush.yml +++ b/.github/workflows/exe-release-prometheuspush.yml @@ -11,6 +11,10 @@ on: tags: [ 'v*.*.*', 'dev*.*.*' ] branches: [ '311-github-workflow-to-build-and-publish-a-exemsi-file-including-signed-rapl-driver-at-each-tagrelease' ] +env: + WRD_VERSION: v0.0.2 + WRD_BASE_URL: https://github.com/hubblo-org/windows-rapl-driver/releases/download + jobs: build_exe_win1011: name: Build exe installer for windows 10/11/server 2016/server 2019/server 2022 @@ -18,22 +22,38 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - with: - path: scaphandre - - name: Checkout - uses: actions/checkout@v3 - with: - repository: hubblo-org/windows-rapl-driver.git - ref: master - path: windows-rapl-driver - name: Install Innosoft run: | $url = "https://jrsoftware.org/download.php/is.exe" $dest = "is.exe" Invoke-WebRequest -Uri $url -OutFile $dest ls - & "$dest" /verysilent /suppressmsgbox - ls "C:\Program Files (x86)\" + & "D:\a\scaphandre\scaphandre\$dest" /verysilent /suppressmsgbox + ls "C:\Program Files (x86)\Inno Setup 6\" + - name: Get windows-rapl-driver + run: | + $dest = "DriverLoader.exe" + $url = "${{ env.WRD_BASE_URL }}/${{ env.WRD_VERSION }}/DriverLoader.exe" + Invoke-WebRequest -Uri ($url -replace '"', "") -OutFile $dest + $dest = "ScaphandreDrv.cat" + $url = "${{ env.WRD_BASE_URL }}/${{ env.WRD_VERSION }}/ScaphandreDrv.cat" + Invoke-WebRequest -Uri ($url -replace '"', "") -OutFile $dest + $dest = "ScaphandreDrv.sys" + $url = "${{ env.WRD_BASE_URL }}/${{ env.WRD_VERSION }}/ScaphandreDrv.sys" + Invoke-WebRequest -Uri ($url -replace '"', "") -OutFile $dest + $dest = "ScaphandreDrv.inf" + $url = "${{ env.WRD_BASE_URL }}/${{ env.WRD_VERSION }}/ScaphandreDrv.inf" + Invoke-WebRequest -Uri ($url -replace '"', "") -OutFile $dest + $dest = "ScaphandreDrvTest.cer" + $url = "${{ env.WRD_BASE_URL }}/${{ env.WRD_VERSION }}/ScaphandreDrvTest.cer" + Invoke-WebRequest -Uri ($url -replace '"', "") -OutFile $dest + $dest = "devcon.exe" + $url = "${{ env.WRD_BASE_URL }}/${{ env.WRD_VERSION }}/devcon.exe" + Invoke-WebRequest -Uri ($url -replace '"', "") -OutFile $dest + $dest = "certmgr.exe" + $url = "${{ env.WRD_BASE_URL }}/${{ env.WRD_VERSION }}/certmgr.exe" + Invoke-WebRequest -Uri ($url -replace '"', "") -OutFile $dest + ls - name: Install Rustup uses: crazy-max/ghaction-chocolatey@v2 with: @@ -41,6 +61,15 @@ jobs: - name: Install Rust toolchain run: | rustup toolchain install stable-x86_64-pc-windows-msvc - - name: Build (debug mode) + - name: Build Scaphandre + run: | + cargo build --release --no-default-features --features "prometheuspush json" + - name: Build package + run: | + & "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" packaging/windows/installer.iss + - name: Upload artifact run: | - cargo build --release --no-default-features --features "prometheuspush json" \ No newline at end of file + Install-Module -Name AWS.Tools.Installer + Install-AWSToolsModule AWS.Tools.EC2,AWS.Tools.S3 -CleanUp + Set-AWSCredential -AccessKey ${{ secrets.S3_ACCESS_KEY_ID }} -SecretKey ${{ secrets.S3_SECRET_ACCESS_KEY }} -StoreAs default + Write-S3Object -BucketName scaphandre -File scaphandre_0.5.0_installer.exe \ No newline at end of file diff --git a/packaging/windows/installer.iss b/packaging/windows/installer.iss index fb06f118..2389673e 100644 --- a/packaging/windows/installer.iss +++ b/packaging/windows/installer.iss @@ -6,8 +6,6 @@ #define MyAppPublisher "Hubblo" #define MyAppURL "https://hubblo-org.github.io/scaphandre-documentation" #define MyAppExeName "scaphandre.exe" -#define MyAppSourceFolder "C:\Users\bpeti\Documents\GitHub\scaphandre" -#define RaplDriverSourceFolder "C:\Users\bpeti\Documents\GitHub\windows-rapl-driver" #define SystemFolder "C:\Windows\System32" #define System64Folder "C:\Windows\SysWOW64" @@ -24,7 +22,7 @@ AppSupportURL={#MyAppURL} AppUpdatesURL={#MyAppURL} DefaultDirName={autopf}\{#MyAppName} DefaultGroupName={#MyAppName} -LicenseFile=C:\Users\bpeti\Documents\GitHub\scaphandre\LICENSE +LicenseFile=../../LICENSE ; Uncomment the following line to run in non administrative install mode (install for current user only.) ;PrivilegesRequired=lowest OutputBaseFilename={#MyAppName}_{#MyAppVersion}_installer @@ -32,26 +30,26 @@ Compression=lzma SolidCompression=yes WizardStyle=modern Uninstallable=yes -SetupIconFile=C:\Users\bpeti\Documents\GitHub\scaphandre\docs_src\scaphandre.ico +SetupIconFile=../../docs_src/scaphandre.ico [Languages] Name: "english"; MessagesFile: "compiler:Default.isl" [Files] -Source: "{#MyAppSourceFolder}\target\release\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion -Source: "{#RaplDriverSourceFolder}\x64\Release\DriverLoader.exe"; DestDir: "{app}"; Flags: ignoreversion -Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.inf"; DestDir: "{app}"; Flags: ignoreversion -; Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.sys"; DestDir: "{#SystemFolder}"; -; Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.sys"; DestDir: "{#System64Folder}"; -Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.sys"; DestDir: "{app}"; -Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.cat"; DestDir: "{app}"; -; Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.cat"; DestDir: "{#SystemFolder}"; -; Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.cat"; DestDir: "{#System64Folder}"; -Source: "C:\Program Files (x86)\Windows Kits\10\Tools\10.0.22621.0\x64\devcon.exe"; DestDir: "{app}"; Flags: ignoreversion -Source: "C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64\certmgr.exe"; DestDir: "{app}"; Flags: ignoreversion -Source: "{#MyAppSourceFolder}\README.md"; DestDir: "{app}"; Flags: ignoreversion -Source: "{#MyAppSourceFolder}\CHANGELOG.md"; DestDir: "{app}"; Flags: ignoreversion -Source: "{#RaplDriverSourceFolder}\ScaphandreDrvTest.cer"; DestDir: "{app}"; Flags: ignoreversion +Source: "../../target/release/{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion +Source: "../../DriverLoader.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "../../ScaphandreDrv.inf"; DestDir: "{app}"; Flags: ignoreversion +; Source: "../../ScaphandreDrv.sys"; DestDir: "{#SystemFolder}"; +; Source: "../../ScaphandreDrv.sys"; DestDir: "{#System64Folder}"; +Source: "../../ScaphandreDrv.sys"; DestDir: "{app}"; +Source: "../../ScaphandreDrv.cat"; DestDir: "{app}"; +; Source: "../../ScaphandreDrv.cat"; DestDir: "{#SystemFolder}"; +; Source: "../../ScaphandreDrv.cat"; DestDir: "{#System64Folder}"; +Source: "../../devcon.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "../../certmgr.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "../../README.md"; DestDir: "{app}"; Flags: ignoreversion +Source: "../../CHANGELOG.md"; DestDir: "{app}"; Flags: ignoreversion +Source: "../../ScaphandreDrvTest.cer"; DestDir: "{app}"; Flags: ignoreversion ; NOTE: Don't use "Flags: ignoreversion" on any shared system files [Icons] @@ -64,7 +62,6 @@ Filename: "{app}/devcon.exe"; Parameters: "enable {app}\ScaphandreDrv.inf root\S Filename: "{app}/DriverLoader.exe"; Parameters: "install"; WorkingDir: "{app}"; Description: "Install Driver Service"; Filename: "{app}/DriverLoader.exe"; Parameters: "start"; WorkingDir: "{app}"; Description: "Start Driver Service"; ; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; -; Filename: "schtasks.exe"; Parameters: "/Create /SC ONSTART {app}\scaphandre.exe prometheus-push " [UninstallRun] Filename: "{app}/DriverLoader.exe"; Parameters: "stop"; WorkingDir: "{app}"; RunOnceId: "StopService"; From d1d797584d7977b8e4337c8e2ba14f0e1d166fa9 Mon Sep 17 00:00:00 2001 From: Benoit Petit Date: Mon, 14 Aug 2023 17:36:49 +0200 Subject: [PATCH 18/20] fix: trying latest windows version to be abble to install aws tools as powershell cmdlet ci: fixing artifact push on scw s3 --- .../workflows/exe-release-prometheuspush.yml | 19 +++-- packaging/windows/dev_installer.iss | 75 +++++++++++++++++++ packaging/windows/installer.iss | 2 +- 3 files changed, 90 insertions(+), 6 deletions(-) create mode 100644 packaging/windows/dev_installer.iss diff --git a/.github/workflows/exe-release-prometheuspush.yml b/.github/workflows/exe-release-prometheuspush.yml index 706b2a7c..c7c99db0 100644 --- a/.github/workflows/exe-release-prometheuspush.yml +++ b/.github/workflows/exe-release-prometheuspush.yml @@ -18,7 +18,7 @@ env: jobs: build_exe_win1011: name: Build exe installer for windows 10/11/server 2016/server 2019/server 2022 - runs-on: "windows-2019" + runs-on: "windows-latest" steps: - name: Checkout uses: actions/checkout@v3 @@ -67,9 +67,18 @@ jobs: - name: Build package run: | & "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" packaging/windows/installer.iss - - name: Upload artifact + - name: Upload artifact #Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force run: | - Install-Module -Name AWS.Tools.Installer - Install-AWSToolsModule AWS.Tools.EC2,AWS.Tools.S3 -CleanUp + Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted + Install-Module -Confirm:$False -Name AWS.Tools.Installer + Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine + Import-Module AWS.Tools.Installer + Install-AWSToolsModule AWS.Tools.EC2,AWS.Tools.S3 -CleanUp -Confirm:$False Set-AWSCredential -AccessKey ${{ secrets.S3_ACCESS_KEY_ID }} -SecretKey ${{ secrets.S3_SECRET_ACCESS_KEY }} -StoreAs default - Write-S3Object -BucketName scaphandre -File scaphandre_0.5.0_installer.exe \ No newline at end of file + mv packaging/windows/Output/scaphandre_installer.exe scaphandre_${GITHUB_REF_NAME}_installer.exe + $clientconfig=@{ + SignatureVersion="s3v4" + ServiceUrl="https://s3.fr-par.scw.cloud" + S3Region="fr-par" + } + Write-S3Object -EndpointUrl "https://s3.fr-par.scw.cloud" -Region "fr-par" -BucketName "scaphandre" -File scaphandre_${GITHUB_REF_NAME}_installer.exe -key "x86_64/scaphandre_${GITHUB_REF_NAME}_installer.exe" -PublicReadOnly -ClientConfig $clientconfig \ No newline at end of file diff --git a/packaging/windows/dev_installer.iss b/packaging/windows/dev_installer.iss new file mode 100644 index 00000000..fb06f118 --- /dev/null +++ b/packaging/windows/dev_installer.iss @@ -0,0 +1,75 @@ + ; Script generated by the Inno Setup Script Wizard. +; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! + +#define MyAppName "scaphandre" +#define MyAppVersion "0.5.0" +#define MyAppPublisher "Hubblo" +#define MyAppURL "https://hubblo-org.github.io/scaphandre-documentation" +#define MyAppExeName "scaphandre.exe" +#define MyAppSourceFolder "C:\Users\bpeti\Documents\GitHub\scaphandre" +#define RaplDriverSourceFolder "C:\Users\bpeti\Documents\GitHub\windows-rapl-driver" +#define SystemFolder "C:\Windows\System32" +#define System64Folder "C:\Windows\SysWOW64" + +[Setup] +; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications. +; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) +AppId={{7DB7B851-1DD2-4FF5-BFC7-282FEBA3B28D} +AppName={#MyAppName} +AppVersion={#MyAppVersion} +;AppVerName={#MyAppName} {#MyAppVersion} +AppPublisher={#MyAppPublisher} +AppPublisherURL={#MyAppURL} +AppSupportURL={#MyAppURL} +AppUpdatesURL={#MyAppURL} +DefaultDirName={autopf}\{#MyAppName} +DefaultGroupName={#MyAppName} +LicenseFile=C:\Users\bpeti\Documents\GitHub\scaphandre\LICENSE +; Uncomment the following line to run in non administrative install mode (install for current user only.) +;PrivilegesRequired=lowest +OutputBaseFilename={#MyAppName}_{#MyAppVersion}_installer +Compression=lzma +SolidCompression=yes +WizardStyle=modern +Uninstallable=yes +SetupIconFile=C:\Users\bpeti\Documents\GitHub\scaphandre\docs_src\scaphandre.ico + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" + +[Files] +Source: "{#MyAppSourceFolder}\target\release\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#RaplDriverSourceFolder}\x64\Release\DriverLoader.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.inf"; DestDir: "{app}"; Flags: ignoreversion +; Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.sys"; DestDir: "{#SystemFolder}"; +; Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.sys"; DestDir: "{#System64Folder}"; +Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.sys"; DestDir: "{app}"; +Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.cat"; DestDir: "{app}"; +; Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.cat"; DestDir: "{#SystemFolder}"; +; Source: "{#RaplDriverSourceFolder}\ScaphandreDrv\ScaphandreDrv.cat"; DestDir: "{#System64Folder}"; +Source: "C:\Program Files (x86)\Windows Kits\10\Tools\10.0.22621.0\x64\devcon.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64\certmgr.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#MyAppSourceFolder}\README.md"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#MyAppSourceFolder}\CHANGELOG.md"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#RaplDriverSourceFolder}\ScaphandreDrvTest.cer"; DestDir: "{app}"; Flags: ignoreversion +; NOTE: Don't use "Flags: ignoreversion" on any shared system files + +[Icons] +Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" + +[Run] +Filename: "C:\windows\System32\WindowsPowershell\v1.0\powershell.exe"; Parameters: "Import-Certificate -FilePath {app}\ScaphandreDrvTest.cer -CertStoreLocation Cert:\LocalMachine\Root"; Description: "Register test certificate"; Flags: waituntilidle shellexec +Filename: "{app}/devcon.exe"; Parameters: "install {app}\ScaphandreDrv.inf root\SCAPHANDREDRV"; Description: "Install Driver"; Flags: waituntilidle +Filename: "{app}/devcon.exe"; Parameters: "enable {app}\ScaphandreDrv.inf root\SCAPHANDREDRV"; Description: "Enable Driver"; Flags: waituntilidle +Filename: "{app}/DriverLoader.exe"; Parameters: "install"; WorkingDir: "{app}"; Description: "Install Driver Service"; +Filename: "{app}/DriverLoader.exe"; Parameters: "start"; WorkingDir: "{app}"; Description: "Start Driver Service"; +; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; +; Filename: "schtasks.exe"; Parameters: "/Create /SC ONSTART {app}\scaphandre.exe prometheus-push " + +[UninstallRun] +Filename: "{app}/DriverLoader.exe"; Parameters: "stop"; WorkingDir: "{app}"; RunOnceId: "StopService"; +Filename: "{app}/DriverLoader.exe"; Parameters: "remove"; WorkingDir: "{app}"; RunOnceId: "RemoveService"; +Filename: "{app}/devcon.exe"; Parameters: "disable ScaphandreDrv"; RunOnceId: "DisableDrier"; +Filename: "{app}/devcon.exe"; Parameters: "remove ScaphandreDrv"; RunOnceId: "RemoveService"; + + diff --git a/packaging/windows/installer.iss b/packaging/windows/installer.iss index 2389673e..bc5287ac 100644 --- a/packaging/windows/installer.iss +++ b/packaging/windows/installer.iss @@ -25,7 +25,7 @@ DefaultGroupName={#MyAppName} LicenseFile=../../LICENSE ; Uncomment the following line to run in non administrative install mode (install for current user only.) ;PrivilegesRequired=lowest -OutputBaseFilename={#MyAppName}_{#MyAppVersion}_installer +OutputBaseFilename={#MyAppName}_installer Compression=lzma SolidCompression=yes WizardStyle=modern From 9267e0a240595c7d8b2039d972233462f30ad4ae Mon Sep 17 00:00:00 2001 From: bpetit Date: Tue, 15 Aug 2023 11:59:46 +0200 Subject: [PATCH 19/20] ci: fixing artifact push on scw s3 --- .github/workflows/exe-release-prometheuspush.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/exe-release-prometheuspush.yml b/.github/workflows/exe-release-prometheuspush.yml index c7c99db0..2e8963ca 100644 --- a/.github/workflows/exe-release-prometheuspush.yml +++ b/.github/workflows/exe-release-prometheuspush.yml @@ -79,6 +79,5 @@ jobs: $clientconfig=@{ SignatureVersion="s3v4" ServiceUrl="https://s3.fr-par.scw.cloud" - S3Region="fr-par" } Write-S3Object -EndpointUrl "https://s3.fr-par.scw.cloud" -Region "fr-par" -BucketName "scaphandre" -File scaphandre_${GITHUB_REF_NAME}_installer.exe -key "x86_64/scaphandre_${GITHUB_REF_NAME}_installer.exe" -PublicReadOnly -ClientConfig $clientconfig \ No newline at end of file From 23af28668e90967cf5e1bb72983d4124cd33b22a Mon Sep 17 00:00:00 2001 From: bpetit Date: Tue, 15 Aug 2023 12:44:52 +0200 Subject: [PATCH 20/20] ci: removed old codesee workflow --- .github/workflows/codesee-arch-diagram.yml | 87 ---------------------- 1 file changed, 87 deletions(-) delete mode 100644 .github/workflows/codesee-arch-diagram.yml diff --git a/.github/workflows/codesee-arch-diagram.yml b/.github/workflows/codesee-arch-diagram.yml deleted file mode 100644 index 904763c8..00000000 --- a/.github/workflows/codesee-arch-diagram.yml +++ /dev/null @@ -1,87 +0,0 @@ -on: - push: - branches: - - main - pull_request_target: - types: [opened, synchronize, reopened] - -name: CodeSee Map - -jobs: - test_map_action: - runs-on: ubuntu-latest - continue-on-error: true - name: Run CodeSee Map Analysis - steps: - - name: checkout - id: checkout - uses: actions/checkout@v2 - with: - repository: ${{ github.event.pull_request.head.repo.full_name }} - ref: ${{ github.event.pull_request.head.ref }} - fetch-depth: 0 - - # codesee-detect-languages has an output with id languages. - - name: Detect Languages - id: detect-languages - uses: Codesee-io/codesee-detect-languages-action@latest - - #- name: Configure JDK 16 - # uses: actions/setup-java@v2 - # if: ${{ fromJSON(steps.detect-languages.outputs.languages).java }} - # with: - # java-version: '16' - # distribution: 'zulu' - - ## CodeSee Maps Go support uses a static binary so there's no setup step required. - - #- name: Configure Node.js 14 - # uses: actions/setup-node@v2 - # if: ${{ fromJSON(steps.detect-languages.outputs.languages).javascript }} - # with: - # node-version: '14' - - #- name: Configure Python 3.x - # uses: actions/setup-python@v2 - # if: ${{ fromJSON(steps.detect-languages.outputs.languages).python }} - # with: - # python-version: '3.10' - # architecture: 'x64' - - #- name: Configure Ruby '3.x' - # uses: ruby/setup-ruby@v1 - # if: ${{ fromJSON(steps.detect-languages.outputs.languages).ruby }} - # with: - # ruby-version: '3.0' - - # We need the rust toolchain because it uses rustc and cargo to inspect the package - - name: Configure Rust 1.x stable - uses: bpetit/action-toolchain@v2.0.0 - if: ${{ fromJSON(steps.detect-languages.outputs.languages).rust }} - with: - toolchain: stable - - - name: Generate Map - id: generate-map - uses: Codesee-io/codesee-map-action@latest - with: - step: map - api_token: ${{ secrets.CODESEE_ARCH_DIAG_API_TOKEN }} - github_ref: ${{ github.ref }} - languages: ${{ steps.detect-languages.outputs.languages }} - - - name: Upload Map - id: upload-map - uses: Codesee-io/codesee-map-action@latest - with: - step: mapUpload - api_token: ${{ secrets.CODESEE_ARCH_DIAG_API_TOKEN }} - github_ref: ${{ github.ref }} - - - name: Insights - id: insights - uses: Codesee-io/codesee-map-action@latest - with: - step: insights - api_token: ${{ secrets.CODESEE_ARCH_DIAG_API_TOKEN }} - github_ref: ${{ github.ref }}