Expand --report-current to show partitions and all mounts (except pseudo-filesystems)
This commit is contained in:
@@ -276,6 +276,7 @@ fn run_report_current(ctx: &Context) -> Result<()> {
|
|||||||
info!("orchestrator: report-current mode");
|
info!("orchestrator: report-current mode");
|
||||||
let fs_results = zfs::probe_existing_filesystems()?;
|
let fs_results = zfs::probe_existing_filesystems()?;
|
||||||
|
|
||||||
|
// Read all mounts, filtering common system/uninteresting ones
|
||||||
let mounts_content = fs::read_to_string("/proc/mounts").unwrap_or_default();
|
let mounts_content = fs::read_to_string("/proc/mounts").unwrap_or_default();
|
||||||
let mounts_json: Vec<serde_json::Value> = mounts_content
|
let mounts_json: Vec<serde_json::Value> = mounts_content
|
||||||
.lines()
|
.lines()
|
||||||
@@ -285,21 +286,77 @@ fn run_report_current(ctx: &Context) -> Result<()> {
|
|||||||
let target = it.next()?;
|
let target = it.next()?;
|
||||||
let fstype = it.next()?;
|
let fstype = it.next()?;
|
||||||
let options = it.next().unwrap_or("");
|
let options = it.next().unwrap_or("");
|
||||||
if target.starts_with("/var/mounts/")
|
|
||||||
|| target == "/var/cache/system"
|
// Skip common pseudo/virtual filesystems and system mounts
|
||||||
|| target == "/var/cache/etc"
|
if source.starts_with("devtmpfs")
|
||||||
|| target == "/var/cache/modules"
|
|| source.starts_with("tmpfs")
|
||||||
|| target == "/var/cache/vm-meta"
|
|| source.starts_with("proc")
|
||||||
|
|| source.starts_with("sysfs")
|
||||||
|
|| source.starts_with("cgroup")
|
||||||
|
|| source.starts_with("bpf")
|
||||||
|
|| source.starts_with("debugfs")
|
||||||
|
|| source.starts_with("securityfs")
|
||||||
|
|| source.starts_with("mqueue")
|
||||||
|
|| source.starts_with("pstore")
|
||||||
|
|| source.starts_with("tracefs")
|
||||||
|
|| source.starts_with("hugetlbfs")
|
||||||
|
|| source.starts_with("efivarfs")
|
||||||
|
|| source.starts_with("systemd-1")
|
||||||
|
|| target.starts_with("/proc")
|
||||||
|
|| target.starts_with("/sys")
|
||||||
|
|| target.starts_with("/dev")
|
||||||
|
|| target.starts_with("/run")
|
||||||
|
|| target.starts_with("/boot")
|
||||||
|
|| target.starts_with("/efi")
|
||||||
|
|| target.starts_with("/boot/efi")
|
||||||
{
|
{
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Include zosstorage target mounts and general data mounts
|
||||||
Some(json!({
|
Some(json!({
|
||||||
"source": source,
|
"source": source,
|
||||||
"target": target,
|
"target": target,
|
||||||
"fstype": fstype,
|
"fstype": fstype,
|
||||||
"options": options
|
"options": options
|
||||||
}))
|
}))
|
||||||
} else {
|
})
|
||||||
None
|
.collect();
|
||||||
|
|
||||||
|
// Read partition information from /proc/partitions
|
||||||
|
let partitions_content = fs::read_to_string("/proc/partitions").unwrap_or_default();
|
||||||
|
let partitions_json: Vec<serde_json::Value> = partitions_content
|
||||||
|
.lines()
|
||||||
|
.filter_map(|line| {
|
||||||
|
let line = line.trim();
|
||||||
|
if line.is_empty() || line.starts_with("major") {
|
||||||
|
return None;
|
||||||
}
|
}
|
||||||
|
let parts: Vec<&str> = line.split_whitespace().collect();
|
||||||
|
if parts.len() < 4 {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let name = parts[3];
|
||||||
|
// Skip pseudo devices
|
||||||
|
if name.starts_with("loop")
|
||||||
|
|| name.starts_with("ram")
|
||||||
|
|| name.starts_with("zram")
|
||||||
|
|| name.starts_with("fd")
|
||||||
|
|| name.starts_with("dm-")
|
||||||
|
|| name.starts_with("md")
|
||||||
|
{
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let major: u32 = parts[0].parse().ok()?;
|
||||||
|
let minor: u32 = parts[1].parse().ok()?;
|
||||||
|
let size_kb: u64 = parts[2].parse().ok()?;
|
||||||
|
Some(json!({
|
||||||
|
"name": name,
|
||||||
|
"major": major,
|
||||||
|
"minor": minor,
|
||||||
|
"size_kb": size_kb,
|
||||||
|
"size_gib": size_kb / (1024 * 1024)
|
||||||
|
}))
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
@@ -325,6 +382,7 @@ fn run_report_current(ctx: &Context) -> Result<()> {
|
|||||||
"version": "v1",
|
"version": "v1",
|
||||||
"timestamp": now,
|
"timestamp": now,
|
||||||
"status": "observed",
|
"status": "observed",
|
||||||
|
"partitions": partitions_json,
|
||||||
"filesystems": fs_json,
|
"filesystems": fs_json,
|
||||||
"mounts": mounts_json
|
"mounts": mounts_json
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user