File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,7 @@ const ES_INDEX_NAME: &str = "scaphandre";
121121#[ derive( Debug , Serialize , Deserialize , PartialEq ) ]
122122pub struct ScaphandreData {
123123 pub scaphandre_version : String ,
124+ pub scaphandre_cpu_usage_percentage : Option < u32 > ,
124125}
125126
126127impl ElasticExporter {
@@ -151,6 +152,7 @@ impl ElasticExporter {
151152 ) )
152153 . body ( ScaphandreData {
153154 scaphandre_version : get_scaphandre_version ( ) ,
155+ scaphandre_cpu_usage_percentage : self . get_scaphandre_cpu_usage_percentage ( ) ,
154156 } )
155157 . send ( )
156158 . await
@@ -166,6 +168,14 @@ impl ElasticExporter {
166168 }
167169 }
168170
171+ fn get_scaphandre_cpu_usage_percentage ( & self ) -> Option < u32 > {
172+ self . topology
173+ . get_process_cpu_consumption_percentage ( procfs:: process:: Process :: myself ( ) . ok ( ) ?. pid ( ) ) ?
174+ . value
175+ . parse :: < u32 > ( )
176+ . ok ( )
177+ }
178+
169179 async fn ensure_index ( & self , client : & Elasticsearch ) -> Result < ( ) , Error > {
170180 let index_exist_resp = client
171181 . indices ( )
You can’t perform that action at this time.
0 commit comments