Skip to content

Commit 0e8ff00

Browse files
committed
Separate quotas
1 parent 8dfabd0 commit 0e8ff00

6 files changed

Lines changed: 141 additions & 78 deletions

File tree

lustre-collector/src/parser.rs

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5+
use std::collections::BTreeSet;
6+
57
use crate::{
68
ldlm, llite, mdd_parser,
79
mds::{self, client_count_parser},
@@ -11,22 +13,61 @@ use crate::{
1113
};
1214
use combine::{Parser, Stream, choice, error::ParseError, many};
1315

14-
pub fn params() -> Vec<String> {
15-
top_level_parser::top_level_params()
16+
#[derive(Copy, Clone)]
17+
pub enum Component {
18+
Clients,
19+
Osd,
20+
Mgs,
21+
Oss,
22+
Mds,
23+
Ldlm,
24+
Llite,
25+
Mdd,
26+
Quota,
27+
Nodemap,
28+
}
29+
30+
pub fn get_params(components: &[Component]) -> Vec<String> {
31+
components
32+
.iter()
33+
.fold(
34+
BTreeSet::from_iter(top_level_parser::top_level_params()),
35+
|mut acc, e| {
36+
acc.extend(match e {
37+
Component::Clients => client_count_parser::params(),
38+
Component::Osd => osd_parser::params(),
39+
Component::Mgs => mgs_parser::params(),
40+
Component::Oss => oss::params(),
41+
Component::Mds => mds::params(),
42+
Component::Ldlm => ldlm::params(),
43+
Component::Llite => llite::params(),
44+
Component::Mdd => mdd_parser::params(),
45+
Component::Quota => quota::params(),
46+
Component::Nodemap => nodemap::params(),
47+
});
48+
49+
acc
50+
},
51+
)
1652
.into_iter()
17-
.chain(client_count_parser::params())
18-
.chain(osd_parser::params())
19-
.chain(mgs_parser::params())
20-
.chain(oss::params())
21-
.chain(mds::params())
22-
.chain(ldlm::params())
23-
.chain(llite::params())
24-
.chain(mdd_parser::params())
25-
.chain(quota::params())
26-
.chain(nodemap::params())
2753
.collect()
2854
}
2955

56+
pub fn params() -> Vec<String> {
57+
get_params(&[
58+
Component::Clients,
59+
Component::Osd,
60+
Component::Mgs,
61+
Component::Oss,
62+
Component::Mds,
63+
Component::Ldlm,
64+
Component::Llite,
65+
Component::Mdd,
66+
Component::Quota,
67+
Component::Nodemap,
68+
])
69+
}
70+
3071
pub fn parse<I>() -> impl Parser<I, Output = Vec<Record>>
3172
where
3273
I: Stream<Token = char>,

lustre-collector/src/quota.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ pub(crate) const QMT: &str = "qmt";
2222
pub(crate) const USR_QUOTAS: &str = "usr";
2323
pub(crate) const PRJ_QUOTAS: &str = "prj";
2424
pub(crate) const GRP_QUOTAS: &str = "grp";
25-
pub(crate) const QMT_STATS: [&str; 3] = [USR_QUOTAS, PRJ_QUOTAS, GRP_QUOTAS];
25+
26+
const PARAMS: [&str; 3] = ["qmt.*.*.glb-usr", "qmt.*.*.glb-prj", "qmt.*.*.glb-grp"];
27+
28+
/// Takes QMT_STATS and produces a list of params for
29+
/// consumption in proper ltcl get_param format.
30+
pub(crate) fn params() -> Vec<String> {
31+
PARAMS.into_iter().map(String::from).collect()
32+
}
2633

2734
pub fn parse<I>() -> impl Parser<I, Output = Record>
2835
where
@@ -32,15 +39,6 @@ where
3239
(string(QMT), period()).with(qmt_parse())
3340
}
3441

35-
/// Takes QMT_STATS and produces a list of params for
36-
/// consumption in proper ltcl get_param format.
37-
pub(crate) fn params() -> Vec<String> {
38-
QMT_STATS
39-
.iter()
40-
.map(|x| format!("{QMT}.*.*.glb-{x}"))
41-
.collect()
42-
}
43-
4442
/// Parses a target name
4543
pub(crate) fn qmt_pool<I>() -> impl Parser<I, Output = (Target, Target)>
4644
where

lustre-collector/src/snapshots/lustre_collector__parser__tests__params.snap

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,7 @@ source: lustre-collector/src/parser.rs
33
expression: params()
44
---
55
[
6-
"memused",
7-
"memused_max",
8-
"lnet_memused",
96
"health_check",
10-
"mdt.*.exports.*.uuid",
11-
"osd-*.*.stats",
12-
"osd-*.*.filesfree",
13-
"osd-*.*.filestotal",
14-
"osd-*.*.fstype",
15-
"osd-*.*.kbytesavail",
16-
"osd-*.*.kbytesfree",
17-
"osd-*.*.kbytestotal",
18-
"osd-*.*.brw_stats",
19-
"osd-*.*.quota_slave.acct_group",
20-
"osd-*.*.quota_slave.acct_user",
21-
"osd-*.*.quota_slave.acct_project",
22-
"mgs.*.mgs.stats",
23-
"mgs.*.mgs.threads_max",
24-
"mgs.*.mgs.threads_min",
25-
"mgs.*.mgs.threads_started",
26-
"mgs.*.num_exports",
27-
"obdfilter.*OST*.stats",
28-
"obdfilter.*OST*.num_exports",
29-
"obdfilter.*OST*.tot_dirty",
30-
"obdfilter.*OST*.tot_granted",
31-
"obdfilter.*OST*.tot_pending",
32-
"obdfilter.*OST*.exports.*.stats",
33-
"ost.OSS.ost.stats",
34-
"ost.OSS.ost_io.stats",
35-
"ost.OSS.ost_create.stats",
36-
"ost.OSS.ost_out.stats",
37-
"ost.OSS.ost_seq.stats",
38-
"mds.MDS.mdt.stats",
39-
"mds.MDS.mdt_fld.stats",
40-
"mds.MDS.mdt_io.stats",
41-
"mds.MDS.mdt_out.stats",
42-
"mds.MDS.mdt_readpage.stats",
43-
"mds.MDS.mdt_seqm.stats",
44-
"mds.MDS.mdt_seqs.stats",
45-
"mds.MDS.mdt_setattr.stats",
46-
"mdt.*.md_stats",
47-
"mdt.*MDT*.num_exports",
48-
"mdt.*MDT*.exports.*.stats",
497
"ldlm.namespaces.{mdt-,filter-}*.contended_locks",
508
"ldlm.namespaces.{mdt-,filter-}*.contention_seconds",
519
"ldlm.namespaces.{mdt-,filter-}*.ctime_age_limit",
@@ -61,10 +19,52 @@ expression: params()
6119
"ldlm.services.ldlm_canceld.stats",
6220
"ldlm.services.ldlm_cbd.stats",
6321
"llite.*.stats",
22+
"lnet_memused",
6423
"mdd.*.changelog_users",
65-
"qmt.*.*.glb-usr",
66-
"qmt.*.*.glb-prj",
67-
"qmt.*.*.glb-grp",
24+
"mds.MDS.mdt.stats",
25+
"mds.MDS.mdt_fld.stats",
26+
"mds.MDS.mdt_io.stats",
27+
"mds.MDS.mdt_out.stats",
28+
"mds.MDS.mdt_readpage.stats",
29+
"mds.MDS.mdt_seqm.stats",
30+
"mds.MDS.mdt_seqs.stats",
31+
"mds.MDS.mdt_setattr.stats",
32+
"mdt.*.exports.*.uuid",
33+
"mdt.*.md_stats",
34+
"mdt.*MDT*.exports.*.stats",
35+
"mdt.*MDT*.num_exports",
36+
"memused",
37+
"memused_max",
38+
"mgs.*.mgs.stats",
39+
"mgs.*.mgs.threads_max",
40+
"mgs.*.mgs.threads_min",
41+
"mgs.*.mgs.threads_started",
42+
"mgs.*.num_exports",
6843
"nodemap.*.dt_stats",
6944
"nodemap.*.md_stats",
45+
"obdfilter.*OST*.exports.*.stats",
46+
"obdfilter.*OST*.num_exports",
47+
"obdfilter.*OST*.stats",
48+
"obdfilter.*OST*.tot_dirty",
49+
"obdfilter.*OST*.tot_granted",
50+
"obdfilter.*OST*.tot_pending",
51+
"osd-*.*.brw_stats",
52+
"osd-*.*.filesfree",
53+
"osd-*.*.filestotal",
54+
"osd-*.*.fstype",
55+
"osd-*.*.kbytesavail",
56+
"osd-*.*.kbytesfree",
57+
"osd-*.*.kbytestotal",
58+
"osd-*.*.quota_slave.acct_group",
59+
"osd-*.*.quota_slave.acct_project",
60+
"osd-*.*.quota_slave.acct_user",
61+
"osd-*.*.stats",
62+
"ost.OSS.ost.stats",
63+
"ost.OSS.ost_create.stats",
64+
"ost.OSS.ost_io.stats",
65+
"ost.OSS.ost_out.stats",
66+
"ost.OSS.ost_seq.stats",
67+
"qmt.*.*.glb-grp",
68+
"qmt.*.*.glb-prj",
69+
"qmt.*.*.glb-usr",
7070
]

lustre-collector/src/snapshots/lustre_collector__tests__params.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
source: lustre-collector/src/lib.rs
33
expression: "xs.join(\" \")"
44
---
5-
memused memused_max lnet_memused health_check mdt.*.exports.*.uuid osd-*.*.stats osd-*.*.filesfree osd-*.*.filestotal osd-*.*.fstype osd-*.*.kbytesavail osd-*.*.kbytesfree osd-*.*.kbytestotal osd-*.*.brw_stats osd-*.*.quota_slave.acct_group osd-*.*.quota_slave.acct_user osd-*.*.quota_slave.acct_project mgs.*.mgs.stats mgs.*.mgs.threads_max mgs.*.mgs.threads_min mgs.*.mgs.threads_started mgs.*.num_exports obdfilter.*OST*.stats obdfilter.*OST*.num_exports obdfilter.*OST*.tot_dirty obdfilter.*OST*.tot_granted obdfilter.*OST*.tot_pending obdfilter.*OST*.exports.*.stats ost.OSS.ost.stats ost.OSS.ost_io.stats ost.OSS.ost_create.stats ost.OSS.ost_out.stats ost.OSS.ost_seq.stats mds.MDS.mdt.stats mds.MDS.mdt_fld.stats mds.MDS.mdt_io.stats mds.MDS.mdt_out.stats mds.MDS.mdt_readpage.stats mds.MDS.mdt_seqm.stats mds.MDS.mdt_seqs.stats mds.MDS.mdt_setattr.stats mdt.*.md_stats mdt.*MDT*.num_exports mdt.*MDT*.exports.*.stats ldlm.namespaces.{mdt-,filter-}*.contended_locks ldlm.namespaces.{mdt-,filter-}*.contention_seconds ldlm.namespaces.{mdt-,filter-}*.ctime_age_limit ldlm.namespaces.{mdt-,filter-}*.early_lock_cancel ldlm.namespaces.{mdt-,filter-}*.lock_count ldlm.namespaces.{mdt-,filter-}*.lock_timeouts ldlm.namespaces.{mdt-,filter-}*.lock_unused_count ldlm.namespaces.{mdt-,filter-}*.lru_max_age ldlm.namespaces.{mdt-,filter-}*.lru_size ldlm.namespaces.{mdt-,filter-}*.max_nolock_bytes ldlm.namespaces.{mdt-,filter-}*.max_parallel_ast ldlm.namespaces.{mdt-,filter-}*.resource_count ldlm.services.ldlm_canceld.stats ldlm.services.ldlm_cbd.stats llite.*.stats mdd.*.changelog_users qmt.*.*.glb-usr qmt.*.*.glb-prj qmt.*.*.glb-grp nodemap.*.dt_stats nodemap.*.md_stats
5+
health_check ldlm.namespaces.{mdt-,filter-}*.contended_locks ldlm.namespaces.{mdt-,filter-}*.contention_seconds ldlm.namespaces.{mdt-,filter-}*.ctime_age_limit ldlm.namespaces.{mdt-,filter-}*.early_lock_cancel ldlm.namespaces.{mdt-,filter-}*.lock_count ldlm.namespaces.{mdt-,filter-}*.lock_timeouts ldlm.namespaces.{mdt-,filter-}*.lock_unused_count ldlm.namespaces.{mdt-,filter-}*.lru_max_age ldlm.namespaces.{mdt-,filter-}*.lru_size ldlm.namespaces.{mdt-,filter-}*.max_nolock_bytes ldlm.namespaces.{mdt-,filter-}*.max_parallel_ast ldlm.namespaces.{mdt-,filter-}*.resource_count ldlm.services.ldlm_canceld.stats ldlm.services.ldlm_cbd.stats llite.*.stats lnet_memused mdd.*.changelog_users mds.MDS.mdt.stats mds.MDS.mdt_fld.stats mds.MDS.mdt_io.stats mds.MDS.mdt_out.stats mds.MDS.mdt_readpage.stats mds.MDS.mdt_seqm.stats mds.MDS.mdt_seqs.stats mds.MDS.mdt_setattr.stats mdt.*.exports.*.uuid mdt.*.md_stats mdt.*MDT*.exports.*.stats mdt.*MDT*.num_exports memused memused_max mgs.*.mgs.stats mgs.*.mgs.threads_max mgs.*.mgs.threads_min mgs.*.mgs.threads_started mgs.*.num_exports nodemap.*.dt_stats nodemap.*.md_stats obdfilter.*OST*.exports.*.stats obdfilter.*OST*.num_exports obdfilter.*OST*.stats obdfilter.*OST*.tot_dirty obdfilter.*OST*.tot_granted obdfilter.*OST*.tot_pending osd-*.*.brw_stats osd-*.*.filesfree osd-*.*.filestotal osd-*.*.fstype osd-*.*.kbytesavail osd-*.*.kbytesfree osd-*.*.kbytestotal osd-*.*.quota_slave.acct_group osd-*.*.quota_slave.acct_project osd-*.*.quota_slave.acct_user osd-*.*.stats ost.OSS.ost.stats ost.OSS.ost_create.stats ost.OSS.ost_io.stats ost.OSS.ost_out.stats ost.OSS.ost_seq.stats qmt.*.*.glb-grp qmt.*.*.glb-prj qmt.*.*.glb-usr

lustrefs-exporter/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use axum::{
2020
http::{self, StatusCode},
2121
response::{IntoResponse, Response},
2222
};
23-
use lustre_collector::{LustreCollectorError, TargetVariant};
23+
use lustre_collector::{LustreCollectorError, TargetVariant, parser};
2424
use prometheus_client::metrics::family::Family as PrometheusFamily;
2525

2626
pub type LabelContainer = Vec<(&'static str, String)>;
@@ -93,7 +93,7 @@ impl LabelProm for TargetVariant {
9393
pub async fn dump_stats() -> Result<(), Error> {
9494
println!("# Dumping lctl get_param output");
9595

96-
let mut lctl = lustre_metrics_output();
96+
let mut lctl = lustre_metrics_output(&parser::params());
9797

9898
let lctl = lctl.output().await?;
9999

lustrefs-exporter/src/routes.rs

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ use axum::{
1616
response::{IntoResponse, Response},
1717
routing::get,
1818
};
19-
use lustre_collector::{parse_lctl_output, parse_lnetctl_output, parse_lnetctl_stats, parser};
19+
use lustre_collector::{
20+
parse_lctl_output, parse_lnetctl_output, parse_lnetctl_stats,
21+
parser::{self, Component},
22+
};
2023
use prometheus_client::{encoding::text::encode, registry::Registry};
2124
use serde::Deserialize;
2225
use std::{
@@ -34,9 +37,12 @@ use tower_http::compression::CompressionLayer;
3437
#[derive(Debug, Deserialize, PartialEq, PartialOrd, Eq, Ord, Hash, Copy, Clone)]
3538
#[serde(rename_all = "snake_case")]
3639
pub enum Dimension {
40+
/// `obdfilter.*OST*.job_stats mdt.*.job_stats`
3741
Jobstats,
38-
Lnet,
42+
/// `qmt.*.*.glb-usr qmt.*.*.glb-prj qmt.*.*.glb-grp`
43+
Quotas,
3944
Lustre,
45+
Lnet,
4046
LnetStats,
4147
}
4248

@@ -104,12 +110,10 @@ pub fn jobstats_metrics_cmd() -> std::process::Command {
104110
cmd
105111
}
106112

107-
pub fn lustre_metrics_output() -> Command {
113+
pub fn lustre_metrics_output(params: &[String]) -> Command {
108114
let mut cmd = Command::new("lctl");
109115

110-
cmd.arg("get_param")
111-
.args(parser::params())
112-
.kill_on_drop(true);
116+
cmd.arg("get_param").args(params).kill_on_drop(true);
113117

114118
cmd
115119
}
@@ -216,7 +220,24 @@ pub async fn scrape(Query(params): Query<Params>) -> Result<Response<Body>, Erro
216220
let mut output = vec![];
217221

218222
if targets.enabled(&Dimension::Lustre) {
219-
let lctl = lustre_metrics_output().output().await?;
223+
let params = parser::get_params(&[
224+
Component::Clients,
225+
Component::Osd,
226+
Component::Mgs,
227+
Component::Oss,
228+
Component::Mds,
229+
Component::Ldlm,
230+
Component::Llite,
231+
Component::Mdd,
232+
Component::Nodemap,
233+
]);
234+
let lctl = lustre_metrics_output(&params).output().await?;
235+
output.extend(parse_lctl_output(&lctl.stdout)?);
236+
}
237+
238+
if targets.enabled(&Dimension::Quotas) {
239+
let params = parser::get_params(&[Component::Quota]);
240+
let lctl = lustre_metrics_output(&params).output().await?;
220241
output.extend(parse_lctl_output(&lctl.stdout)?);
221242
}
222243

@@ -456,7 +477,10 @@ mod tests {
456477
#[tokio::test]
457478
#[serial]
458479
async fn test_lustre_metrics_output_with_mock() {
459-
let output = lustre_metrics_output().output().await.unwrap();
480+
let output = lustre_metrics_output(&lustre_collector::parser::params())
481+
.output()
482+
.await
483+
.unwrap();
460484

461485
insta::assert_snapshot!(String::from_utf8(output.stdout).unwrap());
462486
}

0 commit comments

Comments
 (0)