1
0

Add kernel changed metric

This commit is contained in:
clerie 2023-03-25 16:18:36 +01:00
parent f3ea6ee9d5
commit 7e019abec4
4 changed files with 17 additions and 11 deletions

2
Cargo.lock generated
View File

@ -450,7 +450,7 @@ dependencies = [
[[package]]
name = "nixos-exporter"
version = "0.4.0"
version = "0.5.0"
dependencies = [
"axum",
"reqwest",

View File

@ -1,6 +1,6 @@
[package]
name = "nixos-exporter"
version = "0.4.0"
version = "0.5.0"
edition = "2021"
[dependencies]

View File

@ -10,7 +10,7 @@
in {
nixos-exporter = pkgs.rustPlatform.buildRustPackage rec {
pname = "nixos-exporter";
version = "0.4.0";
version = "0.5.0";
src = ./.;

View File

@ -190,6 +190,12 @@ async fn metrics() -> Result<(StatusCode, impl IntoResponse), (StatusCode, impl
.map_err(|err| (StatusCode::INTERNAL_SERVER_ERROR, err))?.as_str());
}
out.push_str(format!("nixos_current_system_kernel_is_booted_system_kernel{{}} {}", (
nix_store_paths.get("current_system_kernel").ok_or_else(|| (StatusCode::INTERNAL_SERVER_ERROR, String::from("")))?.hash
== nix_store_paths.get("booted_system_kernel").ok_or_else(|| (StatusCode::INTERNAL_SERVER_ERROR, String::from("")))?.hash
) as i32).as_str()
);
return Ok((
StatusCode::OK,
out,