44
55use crate :: {
66 LNetStatGlobal , LustreCollectorError ,
7- lnet_exports:: LNetStatsStatistics ,
7+ lnet_exports:: { LNetGlobal , LNetStatsStatistics } ,
88 types:: { LNetStat , LNetStats , Param , Record , lnet_exports:: Net } ,
99} ;
1010
@@ -33,6 +33,11 @@ pub(crate) fn build_lnet_stats(x: &Net) -> Vec<Record> {
3333 param: Param ( "drop_count" . to_string( ) ) ,
3434 value: y. statistics. drop_count,
3535 } ) ,
36+ LNetStats :: HealthValue ( LNetStat {
37+ nid: y. nid. to_string( ) ,
38+ param: Param ( "health_value" . to_string( ) ) ,
39+ value: y. health_stats. health_value,
40+ } ) ,
3641 ]
3742 } )
3843 . map ( Record :: LNetStat )
@@ -65,6 +70,11 @@ struct LnetStats {
6570 statistics : Option < LNetStatsStatistics > ,
6671}
6772
73+ #[ derive( serde:: Serialize , serde:: Deserialize ) ]
74+ struct LnetGlobalShow {
75+ global : Option < LNetGlobal > ,
76+ }
77+
6878pub ( crate ) fn build_lnetctl_stats ( x : & LNetStatsStatistics ) -> Vec < Record > {
6979 vec ! [
7080 Record :: LNetStat ( LNetStats :: SendLength ( LNetStatGlobal {
@@ -82,6 +92,15 @@ pub(crate) fn build_lnetctl_stats(x: &LNetStatsStatistics) -> Vec<Record> {
8292 ]
8393}
8494
95+ pub ( crate ) fn build_lnetctl_global_show ( x : & LNetGlobal ) -> Vec < Record > {
96+ vec ! [ Record :: LNetStat ( LNetStats :: HealthSensitiveValue (
97+ LNetStatGlobal {
98+ param: Param ( "health_sensitivity" . to_string( ) ) ,
99+ value: x. health_sensitivity,
100+ } ,
101+ ) ) ]
102+ }
103+
85104pub fn parse_lnetctl_stats ( xs : & [ u8 ] ) -> Result < Vec < Record > , LustreCollectorError > {
86105 let xs = xs. trim_ascii ( ) ;
87106
@@ -96,6 +115,20 @@ pub fn parse_lnetctl_stats(xs: &[u8]) -> Result<Vec<Record>, LustreCollectorErro
96115 . unwrap_or_default ( ) )
97116}
98117
118+ pub fn parse_lnetctl_global_show ( xs : & [ u8 ] ) -> Result < Vec < Record > , LustreCollectorError > {
119+ let xs = xs. trim_ascii ( ) ;
120+
121+ if xs. is_empty ( ) {
122+ return Ok ( vec ! [ ] ) ;
123+ }
124+
125+ let y: LnetGlobalShow = yaml_serde:: from_slice ( xs) ?;
126+
127+ Ok ( y. global
128+ . map ( |x| build_lnetctl_global_show ( & x) )
129+ . unwrap_or_default ( ) )
130+ }
131+
99132#[ cfg( test) ]
100133mod tests {
101134 use super :: * ;
@@ -501,4 +534,28 @@ mod tests {
501534
502535 assert_debug_snapshot ! ( x) ;
503536 }
537+
538+ #[ test]
539+ fn test_lnet_global_show ( ) {
540+ let x = parse_lnetctl_global_show (
541+ br#"global:
542+ numa_range: 0
543+ max_intf: 200
544+ discovery: 1
545+ drop_asym_route: 0
546+ retry_count: 2
547+ transaction_timeout: 150
548+ health_sensitivity: 100
549+ recovery_interval: 1
550+ router_sensitivity: 100
551+ lnd_timeout: 49
552+ response_tracking: 3
553+ recovery_limit: 0
554+ max_recovery_ping_interval: 900
555+ "# ,
556+ )
557+ . unwrap ( ) ;
558+
559+ assert_debug_snapshot ! ( x) ;
560+ }
504561}
0 commit comments