Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c8f800a1e5 | |||
| fc6b3424cf | |||
| 35e06c6734 |
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -270,7 +270,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
|
||||
|
||||
[[package]]
|
||||
name = "cm-dashboard"
|
||||
version = "0.1.38"
|
||||
version = "0.1.40"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
@@ -291,7 +291,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cm-dashboard-agent"
|
||||
version = "0.1.38"
|
||||
version = "0.1.40"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@@ -314,7 +314,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cm-dashboard-shared"
|
||||
version = "0.1.38"
|
||||
version = "0.1.40"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"serde",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "cm-dashboard-agent"
|
||||
version = "0.1.39"
|
||||
version = "0.1.42"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -37,6 +37,22 @@ impl NixOSCollector {
|
||||
}
|
||||
|
||||
/// Get configuration hash from deployed nix store system
|
||||
/// Get git commit hash from rebuild process
|
||||
fn get_git_commit(&self) -> Result<String, Box<dyn std::error::Error>> {
|
||||
let commit_file = "/var/lib/cm-dashboard/git-commit";
|
||||
match std::fs::read_to_string(commit_file) {
|
||||
Ok(content) => {
|
||||
let commit_hash = content.trim();
|
||||
if commit_hash.len() >= 7 {
|
||||
Ok(commit_hash.to_string())
|
||||
} else {
|
||||
Err("Git commit hash too short".into())
|
||||
}
|
||||
}
|
||||
Err(e) => Err(format!("Failed to read git commit file: {}", e).into())
|
||||
}
|
||||
}
|
||||
|
||||
fn get_config_hash(&self) -> Result<String, Box<dyn std::error::Error>> {
|
||||
// Read the symlink target of /run/current-system to get nix store path
|
||||
let output = Command::new("readlink")
|
||||
@@ -74,25 +90,25 @@ impl Collector for NixOSCollector {
|
||||
let mut metrics = Vec::new();
|
||||
let timestamp = chrono::Utc::now().timestamp() as u64;
|
||||
|
||||
// Collect NixOS build information (config hash)
|
||||
match self.get_config_hash() {
|
||||
Ok(config_hash) => {
|
||||
// Collect git commit information (shows what's actually deployed)
|
||||
match self.get_git_commit() {
|
||||
Ok(git_commit) => {
|
||||
metrics.push(Metric {
|
||||
name: "system_nixos_build".to_string(),
|
||||
value: MetricValue::String(config_hash),
|
||||
value: MetricValue::String(git_commit),
|
||||
unit: None,
|
||||
description: Some("NixOS deployed configuration hash".to_string()),
|
||||
description: Some("Git commit hash of deployed configuration".to_string()),
|
||||
status: Status::Ok,
|
||||
timestamp,
|
||||
});
|
||||
}
|
||||
Err(e) => {
|
||||
debug!("Failed to get config hash: {}", e);
|
||||
debug!("Failed to get git commit: {}", e);
|
||||
metrics.push(Metric {
|
||||
name: "system_nixos_build".to_string(),
|
||||
value: MetricValue::String("unknown".to_string()),
|
||||
unit: None,
|
||||
description: Some("NixOS config hash (failed to detect)".to_string()),
|
||||
description: Some("Git commit hash (failed to detect)".to_string()),
|
||||
status: Status::Unknown,
|
||||
timestamp,
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "cm-dashboard"
|
||||
version = "0.1.39"
|
||||
version = "0.1.42"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -14,7 +14,7 @@ use app::Dashboard;
|
||||
|
||||
/// Get hardcoded version
|
||||
fn get_version() -> &'static str {
|
||||
"v0.1.33"
|
||||
"v0.1.42"
|
||||
}
|
||||
|
||||
/// Check if running inside tmux session
|
||||
|
||||
@@ -246,20 +246,12 @@ impl TuiApp {
|
||||
if let Some(hostname) = self.current_host.clone() {
|
||||
// Create command that shows CM Dashboard logo and then rebuilds
|
||||
let logo_and_rebuild = format!(
|
||||
"echo ''; \
|
||||
echo -e '\\033[1;32m _____ __ __ _____ _ _ _ \\033[0m'; \
|
||||
echo -e '\\033[1;32m / ____| \\/ | | __ \\ | | | | | |\\033[0m'; \
|
||||
echo -e '\\033[1;32m| | | \\ / | | | | | __ _ ___| |__ | |__ ___ __ _ _ __ __| |\\033[0m'; \
|
||||
echo -e '\\033[1;32m| | | |\\/| | | | | |/ _` / __| \\'_ \\| \\'_ \\ / _ \\ / _` | \\'__/ _` |\\033[0m'; \
|
||||
echo -e '\\033[1;32m| |____| | | | | |__| | (_| \\__ \\ | | | |_) | (_) | (_| | | | (_| |\\033[0m'; \
|
||||
echo -e '\\033[1;32m \\_____|_| |_| |_____/ \\__,_|___/_| |_|_.__/ \\___/ \\__,_|_| \\__,_|\\033[0m'; \
|
||||
echo ''; \
|
||||
echo -e '\\033[1;33m NixOS System Rebuild\\033[0m'; \
|
||||
echo -e '\\033[1;32m Target: {}\\033[0m'; \
|
||||
echo ''; \
|
||||
echo -e '\\033[1;90m────────────────────────────────────────────────────────────────────────────────\\033[0m'; \
|
||||
echo ''; \
|
||||
ssh -tt {}@{} 'bash -ic {}'",
|
||||
r"cat << 'EOF'
|
||||
NixOS System Rebuild
|
||||
Target: {}
|
||||
|
||||
EOF
|
||||
ssh -tt {}@{} 'bash -ic {}'",
|
||||
hostname,
|
||||
self.config.ssh.rebuild_user,
|
||||
hostname,
|
||||
@@ -576,7 +568,7 @@ impl TuiApp {
|
||||
// Left side: "cm-dashboard" text
|
||||
let left_span = Span::styled(
|
||||
" cm-dashboard",
|
||||
Style::default().fg(Theme::background()).bg(background_color)
|
||||
Style::default().fg(Theme::background()).bg(background_color).add_modifier(Modifier::BOLD)
|
||||
);
|
||||
let left_title = Paragraph::new(Line::from(vec![left_span]))
|
||||
.style(Style::default().bg(background_color));
|
||||
@@ -716,7 +708,7 @@ impl TuiApp {
|
||||
host_widgets.system_scroll_offset
|
||||
};
|
||||
let host_widgets = self.get_or_create_host_widgets(&hostname);
|
||||
host_widgets.system_widget.render_with_scroll(frame, inner_area, scroll_offset);
|
||||
host_widgets.system_widget.render_with_scroll(frame, inner_area, scroll_offset, &hostname);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -292,12 +292,6 @@ impl Components {
|
||||
}
|
||||
|
||||
impl Typography {
|
||||
/// Main title style (dashboard header)
|
||||
pub fn title() -> Style {
|
||||
Style::default()
|
||||
.fg(Theme::primary_text())
|
||||
.bg(Theme::background())
|
||||
}
|
||||
|
||||
/// Widget title style (panel headers) - bold bright white
|
||||
pub fn widget_title() -> Style {
|
||||
|
||||
@@ -439,12 +439,12 @@ impl Widget for SystemWidget {
|
||||
|
||||
impl SystemWidget {
|
||||
/// Render with scroll offset support
|
||||
pub fn render_with_scroll(&mut self, frame: &mut Frame, area: Rect, scroll_offset: usize) {
|
||||
pub fn render_with_scroll(&mut self, frame: &mut Frame, area: Rect, scroll_offset: usize, hostname: &str) {
|
||||
let mut lines = Vec::new();
|
||||
|
||||
// NixOS section
|
||||
lines.push(Line::from(vec![
|
||||
Span::styled("NixOS:", Typography::widget_title())
|
||||
Span::styled(format!("NixOS {}:", hostname), Typography::widget_title())
|
||||
]));
|
||||
|
||||
let build_text = self.nixos_build.as_deref().unwrap_or("unknown");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "cm-dashboard-shared"
|
||||
version = "0.1.39"
|
||||
version = "0.1.42"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
Reference in New Issue
Block a user