Skip to main content

flowparser_sflow/counter_records/
processor.rs

1use nom::IResult;
2use nom::number::complete::{be_u32, be_u64};
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
6pub struct Processor {
7    pub cpu_5s: u32,
8    pub cpu_1m: u32,
9    pub cpu_5m: u32,
10    pub total_memory: u64,
11    pub free_memory: u64,
12}
13
14pub(crate) fn parse_processor(input: &[u8]) -> IResult<&[u8], Processor> {
15    let (input, cpu_5s) = be_u32(input)?;
16    let (input, cpu_1m) = be_u32(input)?;
17    let (input, cpu_5m) = be_u32(input)?;
18    let (input, total_memory) = be_u64(input)?;
19    let (input, free_memory) = be_u64(input)?;
20
21    Ok((
22        input,
23        Processor {
24            cpu_5s,
25            cpu_1m,
26            cpu_5m,
27            total_memory,
28            free_memory,
29        },
30    ))
31}