Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Implement osd quota stats
Browse files Browse the repository at this point in the history
  • Loading branch information
RDruon committed Jul 18, 2023
1 parent e86fa86 commit 417ec13
Show file tree
Hide file tree
Showing 9 changed files with 272 additions and 10 deletions.
26 changes: 26 additions & 0 deletions src/fixtures/valid/valid.txt
Original file line number Diff line number Diff line change
Expand Up @@ -384,4 +384,30 @@ qmt.testfs-QMT0000.md-0x0.glb-usr=
global_pool0_md_usr
- id: 0
limits: { hard: 0, soft: 0, granted: 0, time: 604800 }
osd-ldiskfs.testfs-MDT0000.quota_slave.acct_group=
grp_accounting:
- id: 0
usage: { inodes: 396, kbytes: 529400 }
osd-ldiskfs.testfs-MDT0000.quota_slave.acct_project=
prj_accounting:
- id: 0
usage: { inodes: 393, kbytes: 529396 }
- id: 1337
usage: { inodes: 3, kbytes: 4 }
osd-ldiskfs.testfs-MDT0000.quota_slave.acct_user=
usr_accounting:
- id: 0
usage: { inodes: 396, kbytes: 529400 }
osd-ldiskfs.testfs-MDT0001.quota_slave.acct_group=
grp_accounting:
- id: 0
usage: { inodes: 265, kbytes: 356672 }
osd-ldiskfs.testfs-MDT0001.quota_slave.acct_project=
prj_accounting:
- id: 0
usage: { inodes: 265, kbytes: 356672 }
osd-ldiskfs.testfs-MDT0001.quota_slave.acct_user=
usr_accounting:
- id: 0
usage: { inodes: 265, kbytes: 356672 }
ldlm.namespaces.filter-ai400-OST0001_UUID.resource_count=0
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mod node_stats_parsers;
mod osd_parser;
mod oss;
pub mod parser;
pub(crate) mod qmt;
pub(crate) mod quota;
pub mod recovery_status_parser;
mod stats_parser;
mod time;
Expand Down
43 changes: 43 additions & 0 deletions src/osd_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
use crate::{
base_parsers::{digits, param, period, target, till_newline, till_period},
brw_stats_parser::brw_stats,
quota::quota_parser::quota_stats_osd,
types::{BrwStats, Param, Record, Target, TargetStat, TargetStats, TargetVariant},
QuotaKind, QuotaStatsOsd,
};
use combine::{
attempt, choice,
Expand All @@ -24,6 +26,10 @@ pub(crate) const FS_TYPE: &str = "fstype";

pub(crate) const BRW_STATS: &str = "brw_stats";

pub(crate) const QUOTA_ACCT_GRP: &str = "quota_slave.acct_group";
pub(crate) const QUOTA_ACCT_USR: &str = "quota_slave.acct_user";
pub(crate) const QUOTA_ACCT_PRJ: &str = "quota_slave.acct_project";

pub(crate) fn params() -> Vec<String> {
vec![
format!("osd-*.*.{FILES_FREE}"),
Expand All @@ -33,6 +39,9 @@ pub(crate) fn params() -> Vec<String> {
format!("osd-*.*.{KBYTES_FREE}"),
format!("osd-*.*.{KBYTES_TOTAL}"),
format!("osd-*.*.{BRW_STATS}"),
format!("osd-*.{QUOTA_ACCT_GRP}"),
format!("osd-*.{QUOTA_ACCT_USR}"),
format!("osd-*.{QUOTA_ACCT_PRJ}"),
]
}

Expand All @@ -51,6 +60,7 @@ enum OsdStat {
/// Total disk space
BytesTotal(u64),
BrwStats(Vec<BrwStats>),
QuotaStats(QuotaStatsOsd),
}

fn target_and_variant<I>() -> impl Parser<I, Output = (Target, TargetVariant)>
Expand Down Expand Up @@ -116,6 +126,33 @@ where
.map(|x| x * 1024)
.map(OsdStat::BytesTotal),
),
(
param(QUOTA_ACCT_GRP),
quota_stats_osd().map(|stats| {
OsdStat::QuotaStats(QuotaStatsOsd {
kind: QuotaKind::Grp,
stats,
})
}),
),
(
param(QUOTA_ACCT_PRJ),
quota_stats_osd().map(|stats| {
OsdStat::QuotaStats(QuotaStatsOsd {
kind: QuotaKind::Prj,
stats,
})
}),
),
(
param(QUOTA_ACCT_USR),
quota_stats_osd().map(|stats| {
OsdStat::QuotaStats(QuotaStatsOsd {
kind: QuotaKind::Usr,
stats,
})
}),
),
))
}

Expand Down Expand Up @@ -168,6 +205,12 @@ where
param,
value,
}),
OsdStat::QuotaStats(value) => TargetStats::QuotaStatsOsd(TargetStat {
kind,
target,
param,
value,
}),
})
.map(Record::Target)
.message("while parsing osd")
Expand Down
6 changes: 3 additions & 3 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
ldlm,
mds::{client_count_parser, mds_parser},
mgs::mgs_parser,
osd_parser, oss, qmt, top_level_parser,
osd_parser, oss, quota, top_level_parser,
types::Record,
};
use combine::{choice, error::ParseError, many, Parser, Stream};
Expand All @@ -21,7 +21,7 @@ pub fn params() -> Vec<String> {
.chain(oss::params())
.chain(mds_parser::params())
.chain(ldlm::params())
.chain(qmt::params())
.chain(quota::params())
.collect()
}

Expand All @@ -38,7 +38,7 @@ where
mds_parser::parse().map(|x| vec![x]),
oss::parse().map(|x| vec![x]),
ldlm::parse().map(|x| vec![x]),
qmt::parse().map(|x| vec![x]),
quota::parse().map(|x| vec![x]),
)))
.map(|xs: Vec<_>| xs.into_iter().flatten().collect())
}
Expand Down
6 changes: 3 additions & 3 deletions src/qmt/mod.rs → src/quota/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
use crate::{base_parsers::period, Record};
use combine::{parser::char::string, ParseError, Parser, Stream};

mod qmt_parser;
pub(crate) mod quota_parser;

pub(crate) const QMT: &str = "qmt";

pub(crate) fn params() -> Vec<String> {
qmt_parser::params()
quota_parser::params()
}

pub(crate) fn parse<I>() -> impl Parser<I, Output = Record>
where
I: Stream<Token = char>,
I::Error: ParseError<I::Token, I::Range, I::Position>,
{
(string(QMT), period()).with(qmt_parser::parse())
(string(QMT), period()).with(quota_parser::parse())
}
21 changes: 19 additions & 2 deletions src/qmt/qmt_parser.rs → src/quota/quota_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use crate::{
base_parsers::{param, period, target},
qmt::QMT,
quota::QMT,
types::{Param, Record, Target, TargetStats},
QuotaKind, QuotaStat, QuotaStats, TargetQuotaStat,
QuotaKind, QuotaStat, QuotaStatOsd, QuotaStats, TargetQuotaStat,
};
use combine::{
attempt, choice,
Expand Down Expand Up @@ -59,6 +59,23 @@ where
})
}

pub(crate) fn quota_stats_osd<I>() -> impl Parser<I, Output = Vec<QuotaStatOsd>>
where
I: Stream<Token = char>,
I::Error: ParseError<I::Token, I::Range, I::Position>,
{
(
optional(newline()), // If quota stats are present, the whole yaml blob will be on a newline
many::<Vec<_>, _, _>(alpha_num().or(one_of("_-:".chars()))), // But yaml header might not be properly formatted, ignore it
newline(),
take_until(attempt((newline(), alpha_num()))),
)
.skip(newline())
.and_then(|(_, _, _, x): (_, _, _, String)| {
serde_yaml::from_str::<Vec<QuotaStatOsd>>(&x).map_err(StreamErrorFor::<I>::other)
})
}

#[derive(Debug)]
pub enum QMTStat {
Usr(Vec<QuotaStat>),
Expand Down
157 changes: 157 additions & 0 deletions src/snapshots/lustre_collector__parser__tests__node_output.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2986,6 +2986,163 @@ expression: result
},
),
),
Target(
QuotaStatsOsd(
TargetStat {
kind: Mdt,
param: Param(
"quota_slave.acct_group",
),
target: Target(
"testfs-MDT0000",
),
value: QuotaStatsOsd {
kind: Grp,
stats: [
QuotaStatOsd {
id: 0,
usage: QuotaStatUsage {
inodes: 396,
kbytes: 529400,
},
},
],
},
},
),
),
Target(
QuotaStatsOsd(
TargetStat {
kind: Mdt,
param: Param(
"quota_slave.acct_project",
),
target: Target(
"testfs-MDT0000",
),
value: QuotaStatsOsd {
kind: Prj,
stats: [
QuotaStatOsd {
id: 0,
usage: QuotaStatUsage {
inodes: 393,
kbytes: 529396,
},
},
QuotaStatOsd {
id: 1337,
usage: QuotaStatUsage {
inodes: 3,
kbytes: 4,
},
},
],
},
},
),
),
Target(
QuotaStatsOsd(
TargetStat {
kind: Mdt,
param: Param(
"quota_slave.acct_user",
),
target: Target(
"testfs-MDT0000",
),
value: QuotaStatsOsd {
kind: Usr,
stats: [
QuotaStatOsd {
id: 0,
usage: QuotaStatUsage {
inodes: 396,
kbytes: 529400,
},
},
],
},
},
),
),
Target(
QuotaStatsOsd(
TargetStat {
kind: Mdt,
param: Param(
"quota_slave.acct_group",
),
target: Target(
"testfs-MDT0001",
),
value: QuotaStatsOsd {
kind: Grp,
stats: [
QuotaStatOsd {
id: 0,
usage: QuotaStatUsage {
inodes: 265,
kbytes: 356672,
},
},
],
},
},
),
),
Target(
QuotaStatsOsd(
TargetStat {
kind: Mdt,
param: Param(
"quota_slave.acct_project",
),
target: Target(
"testfs-MDT0001",
),
value: QuotaStatsOsd {
kind: Prj,
stats: [
QuotaStatOsd {
id: 0,
usage: QuotaStatUsage {
inodes: 265,
kbytes: 356672,
},
},
],
},
},
),
),
Target(
QuotaStatsOsd(
TargetStat {
kind: Mdt,
param: Param(
"quota_slave.acct_user",
),
target: Target(
"testfs-MDT0001",
),
value: QuotaStatsOsd {
kind: Usr,
stats: [
QuotaStatOsd {
id: 0,
usage: QuotaStatUsage {
inodes: 265,
kbytes: 356672,
},
},
],
},
},
),
),
Target(
ResourceCount(
TargetStat {
Expand Down
2 changes: 1 addition & 1 deletion src/stats_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
base_parsers::{digits, not_words, word},
ldlm::LDLM,
oss::oss_parser::OST,
qmt::QMT,
quota::QMT,
time::time_triple,
types::Stat,
};
Expand Down
Loading

0 comments on commit 417ec13

Please sign in to comment.