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

Commit

Permalink
Export stats
Browse files Browse the repository at this point in the history
  • Loading branch information
RDruon committed Jul 24, 2023
1 parent a996a70 commit ec6b8cb
Show file tree
Hide file tree
Showing 11 changed files with 1,315 additions and 52 deletions.
18 changes: 10 additions & 8 deletions src/base_parsers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,6 @@ where
take_until(period())
}

pub(crate) fn till_equals<I>() -> impl Parser<I, Output = String>
where
I: Stream<Token = char>,
I::Error: ParseError<I::Token, I::Range, I::Position>,
{
take_until(equals())
}

pub(crate) fn string_to<I>(x: &'static str, y: &'static str) -> impl Parser<I, Output = String>
where
I: Stream<Token = char>,
Expand Down Expand Up @@ -128,6 +120,16 @@ where
.message("while getting param")
}

pub(crate) fn param_period<I>(x: &'static str) -> impl Parser<I, Output = Param>
where
I: Stream<Token = char>,
I::Error: ParseError<I::Token, I::Range, I::Position>,
{
attempt(string(x).skip(token('.')))
.map(|x| Param(x.to_string()))
.message("while getting param")
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
56 changes: 56 additions & 0 deletions src/exports_parser.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright (c) 2023 DDN. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

use crate::{
base_parsers::{equals, period},
stats_parser::stats,
ExportStats,
};
use combine::{
attempt,
error::ParseError,
many, many1,
parser::char::{alpha_num, string},
stream::Stream,
token, Parser,
};

/// Parses a single nid
pub(crate) fn nid<I>() -> impl Parser<I, Output = String>
where
I: Stream<Token = char>,
I::Error: ParseError<I::Token, I::Range, I::Position>,
{
(
many1::<String, _, _>(alpha_num().or(period())),
token('@'),
many1::<String, _, _>(alpha_num()),
)
.map(|(ip, _, lnet)| format!("{ip}@{lnet}"))
.message("while parsing nid")
}

/// Parses a single obdfilter.*OST*.exports.*.stats line
fn exports_stat<I>() -> impl Parser<I, Output = ExportStats>
where
I: Stream<Token = char>,
I::Error: ParseError<I::Token, I::Range, I::Position>,
{
attempt((
nid().skip(period()),
string("stats").skip(equals()),
stats(),
))
.map(|(nid, _, stats)| ExportStats { nid, stats })
.message("while parsing export_stats")
}

/// Parses multiple obdfilter.*OST*.exports.*.stats lines
pub(crate) fn exports_stats<I>() -> impl Parser<I, Output = Vec<ExportStats>>
where
I: Stream<Token = char>,
I::Error: ParseError<I::Token, I::Range, I::Position>,
{
(many(exports_stat())).map(|x| x)
}
101 changes: 78 additions & 23 deletions src/fixtures/valid/valid.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,29 +159,6 @@ I/O time (1/1000s) ios % cum % | ios % cum %

read | write
disk I/O size ios % cum % | ios % cum %
mdt.ai400-MDT0000.exports.0@lo.uuid=
52cb8dca-ba5c-4725-9cff-41cd0d45e3e7
ai400-MDT0000-lwp-OST0000_UUID
ai400-MDT0000-lwp-OST0001_UUID
ai400-MDT0000-lwp-MDT0000_UUID
mdt.ai400-MDT0000.exports.172.16.0.85@o2ib.uuid=
cf8d4a32-132f-48ea-9159-044a7823ca67
ai400-MDT0000-lwp-OST0005_UUID
ai400-MDT0000-lwp-OST0004_UUID
ai400-MDT0000-lwp-MDT0002_UUID
ai400-MDT0002-mdtlov_UUID
mdt.ai400-MDT0000.exports.172.16.0.87@o2ib.uuid=
bea2448e-43cc-46da-84cd-21d8d403d44a
ai400-MDT0000-lwp-MDT0001_UUID
ai400-MDT0000-lwp-OST0003_UUID
ai400-MDT0000-lwp-OST0002_UUID
ai400-MDT0001-mdtlov_UUID
mdt.ai400-MDT0000.exports.172.16.0.89@o2ib.uuid=
115d6045-2534-4ca1-a637-0b1544ead16f
ai400-MDT0000-lwp-OST0006_UUID
ai400-MDT0000-lwp-MDT0003_UUID
ai400-MDT0000-lwp-OST0007_UUID
ai400-MDT0003-mdtlov_UUID
obdfilter.ai400-OST0000.job_stats=job_stats:
obdfilter.ai400-OST0001.job_stats=job_stats:
obdfilter.ai400-OST0000.stats=
Expand All @@ -208,6 +185,62 @@ obdfilter.ai400-OST0000.tot_granted=1887764159
obdfilter.ai400-OST0001.tot_granted=278208
obdfilter.ai400-OST0000.tot_pending=0
obdfilter.ai400-OST0001.tot_pending=0
obdfilter.ai400x2-OST0000.exports.0@lo.stats=
snapshot_time 1687448377.140066624 secs.nsecs
create 10 samples [usecs] 44 4724 8911 25377661
statfs 5842 samples [usecs] 0 32132 77736 1248293008
get_info 1 samples [usecs] 3541 3541 3541 12538681
obdfilter.ai400x2-OST0000.exports.172.16.240.130@o2ib.stats=
snapshot_time 1687448377.140115041 secs.nsecs
create 2 samples [usecs] 1 389 390 151322
statfs 5841 samples [usecs] 0 62 13812 69042
get_info 1 samples [usecs] 622 622 622 386884
obdfilter.ai400x2-OST0000.exports.172.16.240.131@o2ib.stats=
snapshot_time 1687448377.140142119 secs.nsecs
create 2 samples [usecs] 2 255 257 65029
statfs 5841 samples [usecs] 0 34 10078 33920
get_info 1 samples [usecs] 629 629 629 395641
obdfilter.ai400x2-OST0000.exports.172.16.240.132@o2ib.stats=
snapshot_time 1687448377.140170939 secs.nsecs
create 2 samples [usecs] 1 228 229 51985
statfs 5841 samples [usecs] 0 40 10622 35572
get_info 1 samples [usecs] 567 567 567 321489
obdfilter.ai400x2-OST0000.exports.172.16.67.87@o2ib.stats=
snapshot_time 1687448377.140194771 secs.nsecs
read_bytes 107577035 samples [bytes] 4096 1048576 81479562702848 8320232521438593024
write_bytes 29075888 samples [bytes] 4096 1048576 24761003618304 6804030488517279744
read 107577035 samples [usecs] 12 83702 199439280448 599777200106672
write 29075888 samples [usecs] 1 58976 11063054274 11687540810422
punch 256 samples [usecs] 12 4872 11892 26649796
sync 256 samples [usecs] 0 8117 213794 439664352
obdfilter.ai400x2-OST0001.exports.0@lo.stats=
snapshot_time 1687448377.140228326 secs.nsecs
create 10 samples [usecs] 46 4253 8459 21219179
statfs 5842 samples [usecs] 0 15452 43854 238950292
get_info 1 samples [usecs] 3583 3583 3583 12837889
obdfilter.ai400x2-OST0001.exports.172.16.240.130@o2ib.stats=
snapshot_time 1687448377.140267031 secs.nsecs
create 2 samples [usecs] 0 244 244 59536
statfs 5841 samples [usecs] 0 53 12887 56549
get_info 1 samples [usecs] 837 837 837 700569
obdfilter.ai400x2-OST0001.exports.172.16.240.131@o2ib.stats=
snapshot_time 1687448377.140291963 secs.nsecs
create 2 samples [usecs] 1 253 254 64010
statfs 5841 samples [usecs] 0 35 9813 34577
get_info 1 samples [usecs] 560 560 560 313600
obdfilter.ai400x2-OST0001.exports.172.16.240.132@o2ib.stats=
snapshot_time 1687448377.140315446 secs.nsecs
create 2 samples [usecs] 1 241 242 58082
statfs 5841 samples [usecs] 0 67 10736 40894
get_info 1 samples [usecs] 533 533 533 284089
obdfilter.ai400x2-OST0001.exports.172.16.67.87@o2ib.stats=
snapshot_time 1687448377.140341383 secs.nsecs
read_bytes 134061108 samples [bytes] 4096 1048576 100430434398208 9589617164080381952
write_bytes 35563179 samples [bytes] 4096 1048576 31043924631552 13380320504942952448
read 134061108 samples [usecs] 11 85796 212314090599 612123348028333
write 35563179 samples [usecs] 1 70953 12502225306 12332383204112
punch 256 samples [usecs] 12 207 5489 158987
sync 256 samples [usecs] 0 8733 220742 490874780
ost.OSS.ost.stats=
snapshot_time 1689060419.303756478 secs.nsecs
req_waittime 219 samples [usec] 11 753 6162 771804
Expand Down Expand Up @@ -272,6 +305,28 @@ getattr 23 samples [usecs] 2 192 629 52487
getxattr 2 samples [usecs] 18 29 47 1165
statfs 44863 samples [usecs] 0 43 323074 3055172
mdt.ai400-MDT0000.num_exports=19
mdt.testfs-MDT0000.exports.0@lo.stats=
snapshot_time 1687448322.813894158 secs.nsecs
mdt.testfs-MDT0000.exports.1.2.3.130@o2ib.stats=
snapshot_time 1687448322.813921821 secs.nsecs
statfs 5830 samples [usecs] 2 144 63916 927644
mdt.testfs-MDT0000.exports.1.2.3.131@o2ib.stats=
snapshot_time 1687448322.813936409 secs.nsecs
statfs 5830 samples [usecs] 0 67 25272 159582
mdt.testfs-MDT0000.exports.1.2.3.132@o2ib.stats=
snapshot_time 1687448322.813948436 secs.nsecs
statfs 5830 samples [usecs] 0 233 30686 277350
mdt.testfs-MDT0000.exports.1.2.3.87@o2ib.stats=
snapshot_time 1687448322.813962980 secs.nsecs
open 2049 samples [usecs] 39 1239 191256 27343170
close 171273 samples [usecs] 6 609 3971940 128888350
mknod 2048 samples [usecs] 35 1231 176023 24464321
mkdir 1 samples [usecs] 431 431 431 185761
getattr 273635 samples [usecs] 1 986 957611 12472685
setattr 2049 samples [usecs] 16 100 74209 2940713
getxattr 69111 samples [usecs] 6 154 933062 13781230
statfs 6 samples [usecs] 0 33 79 1951
sync 2048 samples [usecs] 2 477 19019 918471
ldlm.namespaces.mdt-ai400-MDT0000_UUID.contended_locks=32
ldlm.namespaces.filter-ai400-OST0000_UUID.contended_locks=32
ldlm.namespaces.filter-ai400-OST0001_UUID.contended_locks=32
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
mod base_parsers;
pub(crate) mod brw_stats_parser;
pub mod error;
pub(crate) mod exports_parser;
pub(crate) mod ldlm;
mod lnetctl_parser;
mod mds;
Expand Down
13 changes: 11 additions & 2 deletions src/mds/client_count_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
// license that can be found in the LICENSE file.

use crate::{
base_parsers::{equals, period, till_equals},
base_parsers::{equals, period},
exports_parser::nid,
types::{Param, Record, Target, TargetStat, TargetStats, TargetVariant},
};
use combine::{
Expand Down Expand Up @@ -82,7 +83,15 @@ where
I: Stream<Token = char>,
I::Error: ParseError<I::Token, I::Range, I::Position>,
{
(string("exports"), period(), till_equals(), equals()).map(drop)
(
string("exports"),
period(),
nid(),
period(),
string("uuid"),
equals(),
)
.map(drop)
}

fn mdt_interface<I>() -> impl Parser<I, Output = String>
Expand Down
17 changes: 16 additions & 1 deletion src/mds/mds_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
// license that can be found in the LICENSE file.

use crate::{
base_parsers::{digits, param, period, target},
base_parsers::{digits, param, param_period, period, target},
exports_parser::exports_stats,
mds::job_stats,
oss::obdfilter_parser::{EXPORTS, EXPORTS_PARAMS},
stats_parser::stats,
types::{JobStatMdt, Param, Record, Stat, Target, TargetStat, TargetStats, TargetVariant},
ExportStats,
};
use combine::{
attempt, choice,
Expand Down Expand Up @@ -39,6 +42,7 @@ enum MdtStat {
KBytesFree(u64),
/// Total disk space
KBytesTotal(u64),
ExportStats(Vec<ExportStats>),
}

fn mdt_stat<I>() -> impl Parser<I, Output = (Param, MdtStat)>
Expand Down Expand Up @@ -74,6 +78,10 @@ where
param(KBYTES_TOTAL),
digits().skip(newline()).map(MdtStat::KBytesTotal),
),
(
param_period(EXPORTS),
exports_stats().map(MdtStat::ExportStats),
),
))
}

Expand All @@ -82,6 +90,7 @@ pub(crate) fn params() -> Vec<String> {
format!("mdt.*.{}", JOB_STATS),
format!("mdt.*.{}", STATS),
format!("mdt.*MDT*.{}", NUM_EXPORTS),
format!("mdt.*MDT*.{}", EXPORTS_PARAMS),
]
.iter()
.map(|x| x.to_owned())
Expand Down Expand Up @@ -156,6 +165,12 @@ where
param,
value,
}),
MdtStat::ExportStats(value) => TargetStats::ExportStats(TargetStat {
kind: TargetVariant::Mdt,
target,
param,
value,
}),
})
.map(Record::Target)
.message("while parsing mdt")
Expand Down
21 changes: 19 additions & 2 deletions src/oss/obdfilter_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
// license that can be found in the LICENSE file.

use crate::{
base_parsers::{digits, param, period, target},
base_parsers::{digits, param, param_period, period, target},
exports_parser::exports_stats,
oss::job_stats,
stats_parser::stats,
types::{JobStatOst, Param, Record, Stat, Target, TargetStat, TargetStats, TargetVariant},
ExportStats,
};
use combine::{
choice,
Expand All @@ -24,13 +26,17 @@ pub(crate) const TOT_DIRTY: &str = "tot_dirty";
pub(crate) const TOT_GRANTED: &str = "tot_granted";
pub(crate) const TOT_PENDING: &str = "tot_pending";

pub(crate) const OBD_STATS: [&str; 6] = [
pub(crate) const EXPORTS: &str = "exports";
pub(crate) const EXPORTS_PARAMS: &str = "exports.*.stats";

pub(crate) const OBD_STATS: [&str; 7] = [
JOBSTATS,
STATS,
NUM_EXPORTS,
TOT_DIRTY,
TOT_GRANTED,
TOT_PENDING,
EXPORTS_PARAMS,
];

/// Takes OBD_STATS and produces a list of params for
Expand All @@ -57,6 +63,7 @@ where
enum ObdfilterStat {
JobStats(Option<Vec<JobStatOst>>),
Stats(Vec<Stat>),
ExportStats(Vec<ExportStats>),
NumExports(u64),
TotDirty(u64),
TotGranted(u64),
Expand Down Expand Up @@ -90,6 +97,10 @@ where
param(TOT_PENDING),
digits().skip(newline()).map(ObdfilterStat::TotPending),
),
(
param_period(EXPORTS),
exports_stats().map(ObdfilterStat::ExportStats),
),
))
.message("while parsing obdfilter")
}
Expand Down Expand Up @@ -137,6 +148,12 @@ where
param,
value,
}),
ObdfilterStat::ExportStats(value) => TargetStats::ExportStats(TargetStat {
kind: TargetVariant::Ost,
target,
param,
value,
}),
})
.map(Record::Target)
.message("while parsing obdfilter")
Expand Down
1 change: 0 additions & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pub fn params() -> Vec<String> {
.into_iter()
.chain(client_count_parser::params())
.chain(osd_parser::params())
.chain(client_count_parser::params())
.chain(mgs_parser::params())
.chain(oss::params())
.chain(mds_parser::params())
Expand Down
Loading

0 comments on commit ec6b8cb

Please sign in to comment.