flowparser_sflow/counter_records/
host_cpu.rs1use nom::IResult;
2use nom::number::complete::{be_f32, be_u32};
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6pub struct HostCpu {
7 pub load_one: f32,
9 pub load_five: f32,
11 pub load_fifteen: f32,
13 pub proc_run: u32,
14 pub proc_total: u32,
15 pub cpu_num: u32,
16 pub cpu_speed: u32,
17 pub uptime: u32,
18 pub cpu_user: u32,
19 pub cpu_nice: u32,
20 pub cpu_system: u32,
21 pub cpu_idle: u32,
22 pub cpu_wio: u32,
23 pub cpu_intr: u32,
24 pub cpu_sintr: u32,
25 pub interrupts: u32,
26 pub contexts: u32,
27}
28
29pub(crate) fn parse_host_cpu(input: &[u8]) -> IResult<&[u8], HostCpu> {
30 let (input, load_one) = be_f32(input)?;
31 let (input, load_five) = be_f32(input)?;
32 let (input, load_fifteen) = be_f32(input)?;
33 let (input, proc_run) = be_u32(input)?;
34 let (input, proc_total) = be_u32(input)?;
35 let (input, cpu_num) = be_u32(input)?;
36 let (input, cpu_speed) = be_u32(input)?;
37 let (input, uptime) = be_u32(input)?;
38 let (input, cpu_user) = be_u32(input)?;
39 let (input, cpu_nice) = be_u32(input)?;
40 let (input, cpu_system) = be_u32(input)?;
41 let (input, cpu_idle) = be_u32(input)?;
42 let (input, cpu_wio) = be_u32(input)?;
43 let (input, cpu_intr) = be_u32(input)?;
44 let (input, cpu_sintr) = be_u32(input)?;
45 let (input, interrupts) = be_u32(input)?;
46 let (input, contexts) = be_u32(input)?;
47
48 Ok((
49 input,
50 HostCpu {
51 load_one,
52 load_five,
53 load_fifteen,
54 proc_run,
55 proc_total,
56 cpu_num,
57 cpu_speed,
58 uptime,
59 cpu_user,
60 cpu_nice,
61 cpu_system,
62 cpu_idle,
63 cpu_wio,
64 cpu_intr,
65 cpu_sintr,
66 interrupts,
67 contexts,
68 },
69 ))
70}