diagnostics: add transparent hugepage enabled information
@@ -457,6 +457,9 @@ pub fn system_info(collector: &mut Vec<ServerInfoItem>) {
item.set_name("sysctl".to_string());
item.set_pairs(pairs.into());
collector.push(item);
+ if let Some(item) = get_transparent_hugepage() {
+ collector.push(item);
+ }
}
/// Returns system wide configuration
@@ -479,6 +482,22 @@ fn get_sysctl_list() -> HashMap<String, String> {
.collect()
}
+fn get_transparent_hugepage() -> Option<ServerInfoItem> {
+ if let Ok(content) = std::fs::read_to_string("/sys/kernel/mm/transparent_hugepage/enabled") {
+ let mut pairs = vec![];
+ let mut pair = ServerInfoPair::default();
+ pair.set_key("transparent_hugepage_enabled".to_string());
+ pair.set_value(content.trim().to_string());
+ pairs.push(pair);
+ let mut item = ServerInfoItem::default();
+ item.set_tp("system".to_string());
+ item.set_name("kernel".to_string());
+ item.set_pairs(pairs.into());
+ return Some(item);
+ }
+ None
+}
+
/// process_info collects all process list
/// TODO: use different `ServerInfoType` to collect process list
#[allow(dead_code)]
@@ -635,6 +654,10 @@ mod tests {
.iter()
.filter(|x| x.get_tp() == "system" && x.get_name() == "sysctl");
assert_ne!(item.count(), 0);
+ let item = collector
+ .iter()
+ .filter(|x| x.get_tp() == "system" && x.get_name() == "kernel");
+ assert_ne!(item.count(), 0);
}
}
