multipath and bonding bugfixes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "rsnmpagent"
|
||||
version = "0.4.2"
|
||||
version = "0.4.4"
|
||||
edition = "2024"
|
||||
|
||||
[profile.release]
|
||||
|
||||
@@ -75,33 +75,43 @@ pub(crate) fn bonding_status(path: &str, re: Option<®ex::Regex>) -> io::Resul
|
||||
}
|
||||
|
||||
fn bond_status(d: &Path) -> io::Result<Vec<BondingInfo>> {
|
||||
trace!("now getting status of bonding {:?}",d);
|
||||
let mut bl = Vec::new();
|
||||
let bond_info = BondingInfo {
|
||||
bond: d
|
||||
.file_name()
|
||||
.unwrap_or(OsStr::new("unknown"))
|
||||
.to_string_lossy()
|
||||
.to_string(),
|
||||
.to_string_lossy().to_string(),
|
||||
master_state: fs::read_to_string(d.join("bonding/mii_status"))?.trim().to_string(),
|
||||
slave: "".to_string(),
|
||||
slave_state: "".to_string(),
|
||||
mode: "".to_string(),
|
||||
};
|
||||
trace!("now try to read {:?}/bonding/mode",d);
|
||||
let bond_info_mode = fs::read_to_string(d.join("bonding/mode"))?.trim().to_string();
|
||||
let bond_info_mode: String = bond_info_mode.chars().take(bond_info_mode.chars().count().saturating_sub(2)).collect();
|
||||
let slaves = fs::read_to_string(d.join("bonding/slaves"))?.trim().to_string();
|
||||
for slave in slaves.split(' ') {
|
||||
trace!("try to read {:?}/lower_{}/bonding_slave/mii_status",d, slave);
|
||||
let slave_state = fs::read_to_string(d.join(format!("lower_{}/bonding_slave/mii_status", slave)))?
|
||||
.trim()
|
||||
.to_string();
|
||||
trace!("try to read {:?}/lower_{}/speed",d, slave);
|
||||
let slave_speed = fs::read_to_string(d.join(format!("lower_{}/speed", slave)))?
|
||||
.trim()
|
||||
.to_string();
|
||||
trace!("try to read {:?}/lower_{}/mtu",d, slave);
|
||||
let slave_mtu = fs::read_to_string(d.join(format!("lower_{}/mtu", slave)))?
|
||||
.trim()
|
||||
.to_string();
|
||||
trace!("try to read {:?}/lower_{}/bonding_slave/state",d, slave);
|
||||
let slave_statemode = fs::read_to_string(d.join(format!("lower_{}/bonding_slave/state", slave)))?
|
||||
.trim()
|
||||
.to_string();
|
||||
let mut mpi = bond_info.clone();
|
||||
mpi.slave = slave.to_string();
|
||||
mpi.slave_state = slave_state;
|
||||
mpi.mode = format!("Speed: {}, MTU: {}", slave_speed, slave_mtu);
|
||||
mpi.mode = format!("Mode: {bond_info_mode}, State: {slave_statemode}, Speed: {slave_speed}, MTU: {slave_mtu}");
|
||||
bl.push(mpi);
|
||||
}
|
||||
Ok(bl)
|
||||
|
||||
@@ -95,6 +95,8 @@ fn mp_status(d: &Path) -> io::Result<MultipathInfo> {
|
||||
};
|
||||
if !mp_info.uuid.starts_with("mpath-") {
|
||||
return Err(std::io::Error::other(format!("Wrong device uuid {}", mp_info.uuid)));
|
||||
} else {
|
||||
mp_info.uuid = mp_info.uuid.strip_prefix("mpath-").unwrap().to_string();
|
||||
}
|
||||
let slglob = format!("{}/slaves/*/device", d.to_string_lossy());
|
||||
match glob(&slglob) {
|
||||
|
||||
Reference in New Issue
Block a user