sflow_parser/models/
record_counters.rs

1//! Counter record data structures
2//!
3//! These represent interface and system statistics collected periodically.
4//! Enterprise = 0 (sFlow.org standard formats)
5
6/// Generic Interface Counters - Format (0,1)
7///
8/// Standard interface statistics (RFC 2233)
9///
10/// # XDR Definition ([sFlow v5](https://sflow.org/sflow_version_5.txt))
11///
12/// ```text
13/// /* Generic Interface Counters - see RFC 2233 */
14/// /* opaque = counter_data; enterprise = 0; format = 1 */
15///
16/// struct if_counters {
17///     unsigned int ifIndex;
18///     unsigned int ifType;
19///     unsigned hyper ifSpeed;
20///     unsigned int ifDirection;
21///     unsigned int ifStatus;
22///     unsigned hyper ifInOctets;
23///     unsigned int ifInUcastPkts;
24///     unsigned int ifInMulticastPkts;
25///     unsigned int ifInBroadcastPkts;
26///     unsigned int ifInDiscards;
27///     unsigned int ifInErrors;
28///     unsigned int ifInUnknownProtos;
29///     unsigned hyper ifOutOctets;
30///     unsigned int ifOutUcastPkts;
31///     unsigned int ifOutMulticastPkts;
32///     unsigned int ifOutBroadcastPkts;
33///     unsigned int ifOutDiscards;
34///     unsigned int ifOutErrors;
35///     unsigned int ifPromiscuousMode;
36/// }
37/// ```
38#[derive(Debug, Clone, PartialEq, Eq)]
39#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
40pub struct GenericInterfaceCounters {
41    /// Interface index
42    pub if_index: u32,
43
44    /// Interface type (from IANAifType)
45    pub if_type: u32,
46
47    /// Interface speed in bits per second
48    pub if_speed: u64,
49
50    /// Interface direction (1=full-duplex, 2=half-duplex, 3=in, 4=out)
51    pub if_direction: u32,
52
53    /// Interface status (bit 0=admin, bit 1=oper)
54    pub if_status: u32,
55
56    /// Total octets received
57    pub if_in_octets: u64,
58
59    /// Total unicast packets received
60    pub if_in_ucast_pkts: u32,
61
62    /// Total multicast packets received
63    pub if_in_multicast_pkts: u32,
64
65    /// Total broadcast packets received
66    pub if_in_broadcast_pkts: u32,
67
68    /// Total discarded inbound packets
69    pub if_in_discards: u32,
70
71    /// Total inbound errors
72    pub if_in_errors: u32,
73
74    /// Total inbound packets with unknown protocol
75    pub if_in_unknown_protos: u32,
76
77    /// Total octets transmitted
78    pub if_out_octets: u64,
79
80    /// Total unicast packets transmitted
81    pub if_out_ucast_pkts: u32,
82
83    /// Total multicast packets transmitted
84    pub if_out_multicast_pkts: u32,
85
86    /// Total broadcast packets transmitted
87    pub if_out_broadcast_pkts: u32,
88
89    /// Total discarded outbound packets
90    pub if_out_discards: u32,
91
92    /// Total outbound errors
93    pub if_out_errors: u32,
94
95    /// Promiscuous mode (1=true, 2=false)
96    pub if_promiscuous_mode: u32,
97}
98
99/// Ethernet Interface Counters - Format (0,2)
100///
101/// Ethernet-specific statistics (RFC 2358)
102///
103/// # XDR Definition ([sFlow v5](https://sflow.org/sflow_version_5.txt))
104///
105/// ```text
106/// /* Ethernet Interface Counters - see RFC 2358 */
107/// /* opaque = counter_data; enterprise = 0; format = 2 */
108///
109/// struct ethernet_counters {
110///     unsigned int dot3StatsAlignmentErrors;
111///     unsigned int dot3StatsFCSErrors;
112///     unsigned int dot3StatsSingleCollisionFrames;
113///     unsigned int dot3StatsMultipleCollisionFrames;
114///     unsigned int dot3StatsSQETestErrors;
115///     unsigned int dot3StatsDeferredTransmissions;
116///     unsigned int dot3StatsLateCollisions;
117///     unsigned int dot3StatsExcessiveCollisions;
118///     unsigned int dot3StatsInternalMacTransmitErrors;
119///     unsigned int dot3StatsCarrierSenseErrors;
120///     unsigned int dot3StatsFrameTooLongs;
121///     unsigned int dot3StatsInternalMacReceiveErrors;
122///     unsigned int dot3StatsSymbolErrors;
123/// }
124/// ```
125#[derive(Debug, Clone, PartialEq, Eq)]
126#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
127pub struct EthernetInterfaceCounters {
128    /// Alignment errors
129    pub dot3_stats_alignment_errors: u32,
130
131    /// FCS errors
132    pub dot3_stats_fcs_errors: u32,
133
134    /// Single collision frames
135    pub dot3_stats_single_collision_frames: u32,
136
137    /// Multiple collision frames
138    pub dot3_stats_multiple_collision_frames: u32,
139
140    /// SQE test errors
141    pub dot3_stats_sqe_test_errors: u32,
142
143    /// Deferred transmissions
144    pub dot3_stats_deferred_transmissions: u32,
145
146    /// Late collisions
147    pub dot3_stats_late_collisions: u32,
148
149    /// Excessive collisions
150    pub dot3_stats_excessive_collisions: u32,
151
152    /// Internal MAC transmit errors
153    pub dot3_stats_internal_mac_transmit_errors: u32,
154
155    /// Carrier sense errors
156    pub dot3_stats_carrier_sense_errors: u32,
157
158    /// Frame too long errors
159    pub dot3_stats_frame_too_longs: u32,
160
161    /// Internal MAC receive errors
162    pub dot3_stats_internal_mac_receive_errors: u32,
163
164    /// Symbol errors
165    pub dot3_stats_symbol_errors: u32,
166}
167
168/// Token Ring Counters - Format (0,3)
169///
170/// Token Ring statistics (RFC 1748)
171///
172/// # XDR Definition ([sFlow v5](https://sflow.org/sflow_version_5.txt))
173///
174/// ```text
175/// /* Token Ring Counters - see RFC 1748 */
176/// /* opaque = counter_data; enterprise = 0; format = 3 */
177///
178/// struct tokenring_counters {
179///     unsigned int dot5StatsLineErrors;
180///     unsigned int dot5StatsBurstErrors;
181///     unsigned int dot5StatsACErrors;
182///     unsigned int dot5StatsAbortTransErrors;
183///     unsigned int dot5StatsInternalErrors;
184///     unsigned int dot5StatsLostFrameErrors;
185///     unsigned int dot5StatsReceiveCongestions;
186///     unsigned int dot5StatsFrameCopiedErrors;
187///     unsigned int dot5StatsTokenErrors;
188///     unsigned int dot5StatsSoftErrors;
189///     unsigned int dot5StatsHardErrors;
190///     unsigned int dot5StatsSignalLoss;
191///     unsigned int dot5StatsTransmitBeacons;
192///     unsigned int dot5StatsRecoverys;
193///     unsigned int dot5StatsLobeWires;
194///     unsigned int dot5StatsRemoves;
195///     unsigned int dot5StatsSingles;
196///     unsigned int dot5StatsFreqErrors;
197/// }
198/// ```
199#[derive(Debug, Clone, PartialEq, Eq)]
200#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
201pub struct TokenRingCounters {
202    pub dot5_stats_line_errors: u32,
203    pub dot5_stats_burst_errors: u32,
204    pub dot5_stats_ac_errors: u32,
205    pub dot5_stats_abort_trans_errors: u32,
206    pub dot5_stats_internal_errors: u32,
207    pub dot5_stats_lost_frame_errors: u32,
208    pub dot5_stats_receive_congestions: u32,
209    pub dot5_stats_frame_copied_errors: u32,
210    pub dot5_stats_token_errors: u32,
211    pub dot5_stats_soft_errors: u32,
212    pub dot5_stats_hard_errors: u32,
213    pub dot5_stats_signal_loss: u32,
214    pub dot5_stats_transmit_beacons: u32,
215    pub dot5_stats_recoverys: u32,
216    pub dot5_stats_lobe_wires: u32,
217    pub dot5_stats_removes: u32,
218    pub dot5_stats_singles: u32,
219    pub dot5_stats_freq_errors: u32,
220}
221
222/// 100BaseVG Interface Counters - Format (0,4)
223///
224/// 100BaseVG statistics (RFC 2020)
225///
226/// # XDR Definition ([sFlow v5](https://sflow.org/sflow_version_5.txt))
227///
228/// ```text
229/// /* 100 BaseVG interface counters - see RFC 2020 */
230/// /* opaque = counter_data; enterprise = 0; format = 4 */
231///
232/// struct vg_counters {
233///     unsigned int dot12InHighPriorityFrames;
234///     unsigned hyper dot12InHighPriorityOctets;
235///     unsigned int dot12InNormPriorityFrames;
236///     unsigned hyper dot12InNormPriorityOctets;
237///     unsigned int dot12InIPMErrors;
238///     unsigned int dot12InOversizeFrameErrors;
239///     unsigned int dot12InDataErrors;
240///     unsigned int dot12InNullAddressedFrames;
241///     unsigned int dot12OutHighPriorityFrames;
242///     unsigned hyper dot12OutHighPriorityOctets;
243///     unsigned int dot12TransitionIntoTrainings;
244///     unsigned hyper dot12HCInHighPriorityOctets;
245///     unsigned hyper dot12HCInNormPriorityOctets;
246///     unsigned hyper dot12HCOutHighPriorityOctets;
247/// }
248/// ```
249#[derive(Debug, Clone, PartialEq, Eq)]
250#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
251pub struct Vg100InterfaceCounters {
252    pub dot12_in_high_priority_frames: u32,
253    pub dot12_in_high_priority_octets: u64,
254    pub dot12_in_norm_priority_frames: u32,
255    pub dot12_in_norm_priority_octets: u64,
256    pub dot12_in_ipm_errors: u32,
257    pub dot12_in_oversize_frame_errors: u32,
258    pub dot12_in_data_errors: u32,
259    pub dot12_in_null_addressed_frames: u32,
260    pub dot12_out_high_priority_frames: u32,
261    pub dot12_out_high_priority_octets: u64,
262    pub dot12_transition_into_trainings: u32,
263    pub dot12_hc_in_high_priority_octets: u64,
264    pub dot12_hc_in_norm_priority_octets: u64,
265    pub dot12_hc_out_high_priority_octets: u64,
266}
267
268/// VLAN Counters - Format (0,5)
269///
270/// VLAN statistics
271///
272/// # XDR Definition ([sFlow v5](https://sflow.org/sflow_version_5.txt))
273///
274/// ```text
275/// /* VLAN Counters */
276/// /* opaque = counter_data; enterprise = 0; format = 5 */
277///
278/// struct vlan_counters {
279///     unsigned int vlan_id;
280///     unsigned hyper octets;
281///     unsigned int ucastPkts;
282///     unsigned int multicastPkts;
283///     unsigned int broadcastPkts;
284///     unsigned int discards;
285/// }
286/// ```
287#[derive(Debug, Clone, PartialEq, Eq)]
288#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
289pub struct VlanCounters {
290    /// VLAN ID
291    pub vlan_id: u32,
292
293    /// Total octets
294    pub octets: u64,
295
296    /// Unicast packets
297    pub ucast_pkts: u32,
298
299    /// Multicast packets
300    pub multicast_pkts: u32,
301
302    /// Broadcast packets
303    pub broadcast_pkts: u32,
304
305    /// Discarded packets
306    pub discards: u32,
307}
308
309/// IEEE 802.11 Counters - Format (0,6)
310///
311/// Wireless interface statistics
312///
313/// # XDR Definition ([sFlow 802.11](https://sflow.org/sflow_80211.txt))
314///
315/// ```text
316/// /* IEEE802.11 interface counters - see IEEE802dot11-MIB */
317/// /* opaque = counter_data; enterprise = 0; format = 6 */
318///
319/// struct ieee80211_counters {
320///     unsigned int dot11TransmittedFragmentCount;
321///     unsigned int dot11MulticastTransmittedFrameCount;
322///     unsigned int dot11FailedCount;
323///     unsigned int dot11RetryCount;
324///     unsigned int dot11MultipleRetryCount;
325///     unsigned int dot11FrameDuplicateCount;
326///     unsigned int dot11RTSSuccessCount;
327///     unsigned int dot11RTSFailureCount;
328///     unsigned int dot11ACKFailureCount;
329///     unsigned int dot11ReceivedFragmentCount;
330///     unsigned int dot11MulticastReceivedFrameCount;
331///     unsigned int dot11FCSErrorCount;
332///     unsigned int dot11TransmittedFrameCount;
333///     unsigned int dot11WEPUndecryptableCount;
334///     unsigned int dot11QoSDiscardedFragmentCount;
335///     unsigned int dot11AssociatedStationCount;
336///     unsigned int dot11QoSCFPollsReceivedCount;
337///     unsigned int dot11QoSCFPollsUnusedCount;
338///     unsigned int dot11QoSCFPollsUnusableCount;
339///     unsigned int dot11QoSCFPollsLostCount;
340/// }
341/// ```
342#[derive(Debug, Clone, PartialEq, Eq)]
343#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
344pub struct Ieee80211Counters {
345    pub dot11_transmitted_fragment_count: u32,
346    pub dot11_multicast_transmitted_frame_count: u32,
347    pub dot11_failed_count: u32,
348    pub dot11_retry_count: u32,
349    pub dot11_multiple_retry_count: u32,
350    pub dot11_frame_duplicate_count: u32,
351    pub dot11_rts_success_count: u32,
352    pub dot11_rts_failure_count: u32,
353    pub dot11_ack_failure_count: u32,
354    pub dot11_received_fragment_count: u32,
355    pub dot11_multicast_received_frame_count: u32,
356    pub dot11_fcs_error_count: u32,
357    pub dot11_transmitted_frame_count: u32,
358    pub dot11_wep_undecryptable_count: u32,
359    pub dot11_qos_discarded_fragment_count: u32,
360    pub dot11_associated_station_count: u32,
361    pub dot11_qos_cf_polls_received_count: u32,
362    pub dot11_qos_cf_polls_unused_count: u32,
363    pub dot11_qos_cf_polls_unusable_count: u32,
364    pub dot11_qos_cf_polls_lost_count: u32,
365}
366
367/// Processor Counters - Format (0,1001)
368///
369/// CPU and memory utilization
370///
371/// # XDR Definition ([sFlow v5](https://sflow.org/sflow_version_5.txt))
372///
373/// ```text
374/// /* Processor Information */
375/// /* opaque = counter_data; enterprise = 0; format = 1001 */
376///
377/// struct processor {
378///     percentage 5s_cpu;          /* 5 second average CPU utilization */
379///     percentage 1m_cpu;          /* 1 minute average CPU utilization */
380///     percentage 5m_cpu;          /* 5 minute average CPU utilization */
381///     unsigned hyper total_memory /* total memory (in bytes) */
382///     unsigned hyper free_memory  /* free memory (in bytes) */
383/// }
384/// ```
385#[derive(Debug, Clone, PartialEq, Eq)]
386#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
387pub struct ProcessorCounters {
388    /// 5 second average CPU utilization (0-100%) (spec: 5s_cpu)
389    pub cpu_5s: u32,
390
391    /// 1 minute average CPU utilization (0-100%) (spec: 1m_cpu)
392    pub cpu_1m: u32,
393
394    /// 5 minute average CPU utilization (0-100%) (spec: 5m_cpu)
395    pub cpu_5m: u32,
396
397    /// Total memory in bytes
398    pub total_memory: u64,
399
400    /// Free memory in bytes
401    pub free_memory: u64,
402}
403
404/// Radio Utilization - Format (0,1002)
405///
406/// 802.11 radio channel utilization
407///
408/// # XDR Definition ([sFlow 802.11](https://sflow.org/sflow_80211.txt))
409///
410/// ```text
411/// /* 802.11 radio utilization */
412/// /* opaque = counter_data; enterprise = 0; format = 1002 */
413///
414/// struct radio_utilization {
415///     unsigned int elapsed_time;        /* Elapsed time in ms */
416///     unsigned int on_channel_time;     /* Time on assigned channel */
417///     unsigned int on_channel_busy_time;/* Time busy on channel */
418/// }
419/// ```
420#[derive(Debug, Clone, PartialEq, Eq)]
421#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
422pub struct RadioUtilization {
423    /// Elapsed time in milliseconds
424    pub elapsed_time: u32,
425
426    /// On channel time
427    pub on_channel_time: u32,
428
429    /// On channel busy time
430    pub on_channel_busy_time: u32,
431}
432
433/// OpenFlow Port - Format (0,1004)
434///
435/// OpenFlow port statistics
436///
437/// # XDR Definition ([sFlow OpenFlow](https://sflow.org/sflow_openflow.txt))
438///
439/// ```text
440/// /* OpenFlow port */
441/// /* opaque = counter_data; enterprise = 0; format = 1004 */
442///
443/// struct of_port {
444///     unsigned hyper datapath_id;
445///     unsigned int port_no;
446/// }
447/// ```
448#[derive(Debug, Clone, PartialEq, Eq)]
449#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
450pub struct OpenFlowPort {
451    /// Datapath ID
452    pub datapath_id: u64,
453
454    /// Port number
455    pub port_no: u32,
456}
457
458/// OpenFlow Port Name - Format (0,1005)
459///
460/// OpenFlow port name string
461///
462/// # XDR Definition ([sFlow OpenFlow](https://sflow.org/sflow_openflow.txt))
463///
464/// ```text
465/// /* Port name */
466/// /* opaque = counter_data; enterprise = 0; format = 1005 */
467///
468/// struct port_name {
469///     string name<>;
470/// }
471/// ```
472#[derive(Debug, Clone, PartialEq, Eq)]
473#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
474pub struct OpenFlowPortName {
475    /// Port name
476    pub port_name: String,
477}
478
479/// Machine Type enumeration
480///
481/// Processor family types as defined in sFlow v5 specification
482///
483/// # XDR Definition ([sFlow Host](https://sflow.org/sflow_host.txt))
484///
485/// ```text
486/// enum machine_type {
487///    unknown = 0,
488///    other   = 1,
489///    x86     = 2,
490///    x86_64  = 3,
491///    ia64    = 4,
492///    sparc   = 5,
493///    alpha   = 6,
494///    powerpc = 7,
495///    m68k    = 8,
496///    mips    = 9,
497///    arm     = 10,
498///    hppa    = 11,
499///    s390    = 12
500/// }
501/// ```
502#[derive(Debug, Clone, Copy, PartialEq, Eq)]
503#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
504#[repr(u32)]
505pub enum MachineType {
506    Unknown = 0,
507    Other = 1,
508    X86 = 2,
509    X86_64 = 3,
510    Ia64 = 4,
511    Sparc = 5,
512    Alpha = 6,
513    Powerpc = 7,
514    M68k = 8,
515    Mips = 9,
516    Arm = 10,
517    Hppa = 11,
518    S390 = 12,
519}
520
521impl From<u32> for MachineType {
522    fn from(value: u32) -> Self {
523        match value {
524            0 => MachineType::Unknown,
525            1 => MachineType::Other,
526            2 => MachineType::X86,
527            3 => MachineType::X86_64,
528            4 => MachineType::Ia64,
529            5 => MachineType::Sparc,
530            6 => MachineType::Alpha,
531            7 => MachineType::Powerpc,
532            8 => MachineType::M68k,
533            9 => MachineType::Mips,
534            10 => MachineType::Arm,
535            11 => MachineType::Hppa,
536            12 => MachineType::S390,
537            _ => MachineType::Unknown,
538        }
539    }
540}
541
542/// Operating System Name enumeration
543///
544/// OS types as defined in sFlow v5 specification
545///
546/// # XDR Definition ([sFlow Host](https://sflow.org/sflow_host.txt))
547///
548/// ```text
549/// enum os_name {
550///    unknown   = 0,
551///    other     = 1,
552///    linux     = 2,
553///    windows   = 3,
554///    darwin    = 4,
555///    hpux      = 5,
556///    aix       = 6,
557///    dragonfly = 7,
558///    freebsd   = 8,
559///    netbsd    = 9,
560///    openbsd   = 10,
561///    osf       = 11,
562///    solaris   = 12
563/// }
564/// ```
565///
566/// **Note:** The enumeration may be expanded over time. Applications receiving
567/// sFlow must be prepared to receive host_descr structures with unknown os_name values.
568#[derive(Debug, Clone, Copy, PartialEq, Eq)]
569#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
570#[repr(u32)]
571pub enum OsName {
572    Unknown = 0,
573    Other = 1,
574    Linux = 2,
575    Windows = 3,
576    Darwin = 4,
577    Hpux = 5,
578    Aix = 6,
579    Dragonfly = 7,
580    Freebsd = 8,
581    Netbsd = 9,
582    Openbsd = 10,
583    Osf = 11,
584    Solaris = 12,
585}
586
587impl From<u32> for OsName {
588    fn from(value: u32) -> Self {
589        match value {
590            0 => OsName::Unknown,
591            1 => OsName::Other,
592            2 => OsName::Linux,
593            3 => OsName::Windows,
594            4 => OsName::Darwin,
595            5 => OsName::Hpux,
596            6 => OsName::Aix,
597            7 => OsName::Dragonfly,
598            8 => OsName::Freebsd,
599            9 => OsName::Netbsd,
600            10 => OsName::Openbsd,
601            11 => OsName::Osf,
602            12 => OsName::Solaris,
603            _ => OsName::Unknown,
604        }
605    }
606}
607
608/// Host Description - Format (0,2000)
609///
610/// Physical or virtual host description
611///
612/// # XDR Definition ([sFlow Host](https://sflow.org/sflow_host.txt))
613///
614/// ```text
615/// /* Physical or virtual host description */
616/// /* opaque = counter_data; enterprise = 0; format = 2000 */
617///
618/// struct host_descr {
619///    string hostname<64>;       /* hostname, empty if unknown */
620///    opaque uuid<16>;           /* 16 bytes binary UUID, empty if unknown */
621///    machine_type machine_type; /* the processor family */
622///    os_name os_name;           /* Operating system */
623///    string os_release<32>;     /* e.g. 2.6.9-42.ELsmp,xp-sp3, empty if unknown */
624/// }
625/// ```
626///
627/// **ERRATUM:** UUID field changed from `opaque uuid<16>` to `opaque uuid[16]` (fixed array).
628#[derive(Debug, Clone, PartialEq, Eq)]
629#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
630pub struct HostDescription {
631    /// Hostname
632    pub hostname: String,
633
634    /// UUID (16 bytes)
635    /// **ERRATUM:** All zeros if unknown (changed from variable-length to fixed-length array)
636    pub uuid: [u8; 16],
637
638    /// Machine type (processor family)
639    pub machine_type: MachineType,
640
641    /// Operating system name
642    pub os_name: OsName,
643
644    /// OS release (e.g., "5.10.0")
645    pub os_release: String,
646}
647
648/// Host Adapters - Format (0,2001)
649///
650/// Set of network adapters associated with entity
651///
652/// # XDR Definition ([sFlow Host](https://sflow.org/sflow_host.txt))
653///
654/// ```text
655/// /* Set of adapters associated with entity */
656/// /* opaque = counter_data; enterprise = 0; format = 2001 */
657///
658/// struct host_adapters {
659///     adapter adapters<>; /* adapter(s) associated with entity */
660/// }
661/// ```
662#[derive(Debug, Clone, PartialEq, Eq)]
663#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
664pub struct HostAdapters {
665    /// Adapters
666    pub adapters: Vec<HostAdapter>,
667}
668
669#[derive(Debug, Clone, PartialEq, Eq)]
670#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
671pub struct HostAdapter {
672    /// Interface index
673    pub if_index: u32,
674
675    /// MAC addresses
676    pub mac_addresses: Vec<crate::models::MacAddress>,
677}
678
679/// Host Parent - Format (0,2002)
680///
681/// Containment hierarchy between logical and physical entities
682///
683/// # XDR Definition ([sFlow Host](https://sflow.org/sflow_host.txt))
684///
685/// ```text
686/// /* Define containment hierarchy */
687/// /* opaque = counter_data; enterprise = 0; format = 2002 */
688///
689/// struct host_parent {
690///     unsigned int container_type;  /* sFlowDataSource type */
691///     unsigned int container_index; /* sFlowDataSource index */
692/// }
693/// ```
694#[derive(Debug, Clone, PartialEq, Eq)]
695#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
696pub struct HostParent {
697    /// Container type (e.g., "docker", "lxc")
698    pub container_type: u32,
699
700    /// Container index
701    pub container_index: u32,
702}
703
704/// Host CPU - Format (0,2003)
705///
706/// Physical server CPU statistics
707///
708/// # XDR Definition ([sFlow Host](https://sflow.org/sflow_host.txt))
709///
710/// ```text
711/// /* Physical Server CPU */
712/// /* opaque = counter_data; enterprise = 0; format = 2003 */
713///
714/// struct host_cpu {
715///     float load_one;          /* 1 minute load avg */
716///     float load_five;         /* 5 minute load avg */
717///     float load_fifteen;      /* 15 minute load avg */
718///     unsigned int proc_run;   /* running processes */
719///     unsigned int proc_total; /* total processes */
720///     unsigned int cpu_num;    /* number of CPUs */
721///     unsigned int cpu_speed;  /* CPU speed in MHz */
722///     unsigned int uptime;     /* seconds since last reboot */
723///     unsigned int cpu_user;   /* user time (ms) */
724///     unsigned int cpu_nice;   /* nice time (ms) */
725///     unsigned int cpu_system; /* system time (ms) */
726///     unsigned int cpu_idle;   /* idle time (ms) */
727///     unsigned int cpu_wio;    /* I/O wait time (ms) */
728///     unsigned int cpu_intr;   /* interrupt time (ms) */
729///     unsigned int cpu_sintr;  /* soft interrupt time (ms) */
730///     unsigned int interrupts; /* interrupt count */
731///     unsigned int contexts;   /* context switch count */
732/// }
733/// ```
734#[derive(Debug, Clone, PartialEq, Eq)]
735#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
736pub struct HostCpu {
737    /// Load average (1 minute) - stored as hundredths (multiply by 100)
738    pub load_one: u32,
739
740    /// Load average (5 minutes) - stored as hundredths (multiply by 100)
741    pub load_five: u32,
742
743    /// Load average (15 minutes) - stored as hundredths (multiply by 100)
744    pub load_fifteen: u32,
745
746    /// Number of running processes
747    pub proc_run: u32,
748
749    /// Total number of processes
750    pub proc_total: u32,
751
752    /// Number of CPUs
753    pub cpu_num: u32,
754
755    /// CPU speed in MHz
756    pub cpu_speed: u32,
757
758    /// CPU uptime in seconds
759    pub uptime: u32,
760
761    /// CPU time in user mode (ms)
762    pub cpu_user: u32,
763
764    /// CPU time in nice mode (ms)
765    pub cpu_nice: u32,
766
767    /// CPU time in system mode (ms)
768    pub cpu_system: u32,
769
770    /// CPU idle time (ms)
771    pub cpu_idle: u32,
772
773    /// CPU time waiting for I/O (ms)
774    pub cpu_wio: u32,
775
776    /// CPU time servicing interrupts (ms)
777    pub cpu_intr: u32,
778
779    /// CPU time servicing soft interrupts (ms)
780    pub cpu_sintr: u32,
781
782    /// Number of interrupts
783    pub interrupts: u32,
784
785    /// Number of context switches
786    pub contexts: u32,
787}
788
789/// Host Memory - Format (0,2004)
790///
791/// Physical server memory statistics
792///
793/// # XDR Definition ([sFlow Host](https://sflow.org/sflow_host.txt))
794///
795/// ```text
796/// /* Physical Server Memory */
797/// /* opaque = counter_data; enterprise = 0; format = 2004 */
798///
799/// struct host_memory {
800///     unsigned hyper mem_total;   /* total bytes */
801///     unsigned hyper mem_free;    /* free bytes */
802///     unsigned hyper mem_shared;  /* shared bytes */
803///     unsigned hyper mem_buffers; /* buffers bytes */
804///     unsigned hyper mem_cached;  /* cached bytes */
805///     unsigned hyper swap_total;  /* swap total bytes */
806///     unsigned hyper swap_free;   /* swap free bytes */
807///     unsigned int page_in;       /* page in count */
808///     unsigned int page_out;      /* page out count */
809///     unsigned int swap_in;       /* swap in count */
810///     unsigned int swap_out;      /* swap out count */
811/// }
812/// ```
813#[derive(Debug, Clone, PartialEq, Eq)]
814#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
815pub struct HostMemory {
816    /// Total memory in bytes
817    pub mem_total: u64,
818
819    /// Free memory in bytes
820    pub mem_free: u64,
821
822    /// Shared memory in bytes
823    pub mem_shared: u64,
824
825    /// Memory used for buffers in bytes
826    pub mem_buffers: u64,
827
828    /// Memory used for cache in bytes
829    pub mem_cached: u64,
830
831    /// Total swap space in bytes
832    pub swap_total: u64,
833
834    /// Free swap space in bytes
835    pub swap_free: u64,
836
837    /// Page in count
838    pub page_in: u32,
839
840    /// Page out count
841    pub page_out: u32,
842
843    /// Swap in count
844    pub swap_in: u32,
845
846    /// Swap out count
847    pub swap_out: u32,
848}
849
850/// Host Disk I/O - Format (0,2005)
851///
852/// Physical server disk I/O statistics
853///
854/// # XDR Definition ([sFlow Host](https://sflow.org/sflow_host.txt))
855///
856/// ```text
857/// /* Physical Server Disk I/O */
858/// /* opaque = counter_data; enterprise = 0; format = 2005 */
859///
860/// struct host_disk_io {
861///     unsigned hyper disk_total;    /* total disk size in bytes */
862///     unsigned hyper disk_free;     /* total disk free in bytes */
863///     percentage part_max_used;     /* utilization of most utilized partition */
864///     unsigned int reads;           /* reads issued */
865///     unsigned hyper bytes_read;    /* bytes read */
866///     unsigned int read_time;       /* read time (ms) */
867///     unsigned int writes;          /* writes completed */
868///     unsigned hyper bytes_written; /* bytes written */
869///     unsigned int write_time;      /* write time (ms) */
870/// }
871/// ```
872#[derive(Debug, Clone, PartialEq, Eq)]
873#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
874pub struct HostDiskIo {
875    /// Total disk capacity in bytes
876    pub disk_total: u64,
877
878    /// Free disk space in bytes
879    pub disk_free: u64,
880
881    /// Percentage of disk used (0-100)
882    pub part_max_used: u32,
883
884    /// Number of disk reads
885    pub reads: u32,
886
887    /// Bytes read from disk
888    pub bytes_read: u64,
889
890    /// Read time in milliseconds
891    pub read_time: u32,
892
893    /// Number of disk writes
894    pub writes: u32,
895
896    /// Bytes written to disk
897    pub bytes_written: u64,
898
899    /// Write time in milliseconds
900    pub write_time: u32,
901}
902
903/// Host Network I/O - Format (0,2006)
904///
905/// Physical server network I/O statistics
906///
907/// # XDR Definition ([sFlow Host](https://sflow.org/sflow_host.txt))
908///
909/// ```text
910/// /* Physical Server Network I/O */
911/// /* opaque = counter_data; enterprise = 0; format = 2006 */
912///
913/// struct host_net_io {
914///     unsigned hyper bytes_in;  /* total bytes in */
915///     unsigned int pkts_in;     /* total packets in */
916///     unsigned int errs_in;     /* total errors in */
917///     unsigned int drops_in;    /* total drops in */
918///     unsigned hyper bytes_out; /* total bytes out */
919///     unsigned int packets_out; /* total packets out */
920///     unsigned int errs_out;    /* total errors out */
921///     unsigned int drops_out;   /* total drops out */
922/// }
923/// ```
924#[derive(Debug, Clone, PartialEq, Eq)]
925#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
926pub struct HostNetIo {
927    /// Bytes received
928    pub bytes_in: u64,
929
930    /// Packets received
931    pub pkts_in: u32,
932
933    /// Receive errors
934    pub errs_in: u32,
935
936    /// Receive drops
937    pub drops_in: u32,
938
939    /// Bytes transmitted
940    pub bytes_out: u64,
941
942    /// Packets transmitted
943    pub packets_out: u32,
944
945    /// Transmit errors
946    pub errs_out: u32,
947
948    /// Transmit drops
949    pub drops_out: u32,
950}
951
952/// Virtual Node - Format (0,2100)
953///
954/// Hypervisor statistics
955///
956/// # XDR Definition ([sFlow Host](https://sflow.org/sflow_host.txt))
957///
958/// ```text
959/// /* Virtual Node Statistics */
960/// /* opaque = counter_data; enterprise = 0; format = 2100 */
961///
962/// struct virt_node {
963///     unsigned int mhz;           /* expected CPU frequency */
964///     unsigned int cpus;          /* number of active CPUs */
965///     unsigned hyper memory;      /* memory size in bytes */
966///     unsigned hyper memory_free; /* unassigned memory in bytes */
967///     unsigned int num_domains;   /* number of active domains */
968/// }
969/// ```
970#[derive(Debug, Clone, PartialEq, Eq)]
971#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
972pub struct VirtualNode {
973    /// Expected CPU frequency in MHz
974    pub mhz: u32,
975
976    /// Number of active CPUs
977    pub cpus: u32,
978
979    /// Memory size in bytes
980    pub memory: u64,
981
982    /// Unassigned memory in bytes
983    pub memory_free: u64,
984
985    /// Number of active domains
986    pub num_domains: u32,
987}
988
989/// Virtual CPU - Format (0,2101)
990///
991/// Virtual domain CPU statistics
992///
993/// # XDR Definition ([sFlow Host](https://sflow.org/sflow_host.txt))
994///
995/// ```text
996/// /* Virtual Domain CPU statistics */
997/// /* See libvirt, struct virDomainInfo */
998/// /* opaque = counter_data; enterprise = 0; format = 2101 */
999///
1000/// struct virt_cpu {
1001///     unsigned int state;    /* virtDomainState */
1002///     unsigned int cpuTime;  /* CPU time used (ms) */
1003///     unsigned int nrVirtCpu;/* number of virtual CPUs */
1004/// }
1005/// ```
1006///
1007/// **ERRATUM:** Comment reference corrected from `virtDomainInfo` to `virDomainInfo`.
1008#[derive(Debug, Clone, PartialEq, Eq)]
1009#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1010pub struct VirtualCpu {
1011    /// CPU state (0=running, 1=idle, 2=blocked)
1012    pub state: u32,
1013
1014    /// CPU time in milliseconds
1015    pub cpu_time: u32,
1016
1017    /// Number of virtual CPUs
1018    pub nr_virt_cpu: u32,
1019}
1020
1021/// Virtual Memory - Format (0,2102)
1022///
1023/// Virtual domain memory statistics
1024///
1025/// # XDR Definition ([sFlow Host](https://sflow.org/sflow_host.txt))
1026///
1027/// ```text
1028/// /* Virtual Domain Memory statistics */
1029/// /* See libvirt, struct virDomainInfo */
1030/// /* opaque = counter_data; enterprise = 0; format = 2102 */
1031///
1032/// struct virt_memory {
1033///     unsigned hyper memory;    /* memory in bytes used by domain */
1034///     unsigned hyper maxMemory; /* memory in bytes allowed */
1035/// }
1036/// ```
1037///
1038/// **ERRATUM:** Comment reference corrected from `virtDomainInfo` to `virDomainInfo`.
1039#[derive(Debug, Clone, PartialEq, Eq)]
1040#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1041pub struct VirtualMemory {
1042    /// Memory in bytes
1043    pub memory: u64,
1044
1045    /// Maximum memory in bytes
1046    pub max_memory: u64,
1047}
1048
1049/// Virtual Disk I/O - Format (0,2103)
1050///
1051/// Virtual domain disk statistics
1052///
1053/// # XDR Definition ([sFlow Host](https://sflow.org/sflow_host.txt))
1054///
1055/// ```text
1056/// /* Virtual Domain Disk statistics */
1057/// /* See libvirt, struct virDomainBlockInfo */
1058/// /* See libvirt, struct virDomainBlockStatsStruct */
1059/// /* opaque = counter_data; enterprise = 0; format = 2103 */
1060///
1061/// struct virt_disk_io {
1062///     unsigned hyper capacity;   /* logical size in bytes */
1063///     unsigned hyper allocation; /* current allocation in bytes */
1064///     unsigned hyper physical;   /* physical size in bytes of the container of the backing image */
1065///     unsigned int rd_req;       /* number of read requests */
1066///     unsigned hyper rd_bytes;   /* number of read bytes */
1067///     unsigned int wr_req;       /* number of write requests */
1068///     unsigned hyper wr_bytes;   /* number of written bytes */
1069///     unsigned int errs;         /* read/write errors */
1070/// }
1071/// ```
1072///
1073/// **ERRATUM:** Field name changed from `available` to `physical`, and comment references corrected
1074/// from `virtDomainBlockInfo`/`virtDomainBlockStatsStruct` to `virDomainBlockInfo`/`virDomainBlockStatsStruct`.
1075#[derive(Debug, Clone, PartialEq, Eq)]
1076#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1077pub struct VirtualDiskIo {
1078    /// Capacity in bytes
1079    pub capacity: u64,
1080
1081    /// Allocation in bytes
1082    pub allocation: u64,
1083
1084    /// Physical size in bytes of the container of the backing image (spec: physical)
1085    /// **ERRATUM:** Field renamed from `available` (remaining free bytes) to `physical`
1086    pub available: u64,
1087
1088    /// Read requests
1089    pub rd_req: u32,
1090
1091    /// Bytes read
1092    pub rd_bytes: u64,
1093
1094    /// Write requests
1095    pub wr_req: u32,
1096
1097    /// Bytes written
1098    pub wr_bytes: u64,
1099
1100    /// Errors
1101    pub errs: u32,
1102}
1103
1104/// Virtual Network I/O - Format (0,2104)
1105///
1106/// Virtual domain network statistics
1107///
1108/// # XDR Definition ([sFlow Host](https://sflow.org/sflow_host.txt))
1109///
1110/// ```text
1111/// /* Virtual Domain Network statistics */
1112/// /* See libvirt, struct virDomainInterfaceStatsStruct */
1113/// /* opaque = counter_data; enterprise = 0; format = 2104 */
1114///
1115/// struct virt_net_io {
1116///     unsigned hyper rx_bytes;  /* total bytes received */
1117///     unsigned int rx_packets;  /* total packets received */
1118///     unsigned int rx_errs;     /* total receive errors */
1119///     unsigned int rx_drop;     /* total receive drops */
1120///     unsigned hyper tx_bytes;  /* total bytes transmitted */
1121///     unsigned int tx_packets;  /* total packets transmitted */
1122///     unsigned int tx_errs;     /* total transmit errors */
1123///     unsigned int tx_drop;     /* total transmit drops */
1124/// }
1125/// ```
1126///
1127/// **ERRATUM:** Comment reference corrected from `virtDomainInterfaceStatsStruct` to `virDomainInterfaceStatsStruct`.
1128#[derive(Debug, Clone, PartialEq, Eq)]
1129#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1130pub struct VirtualNetIo {
1131    /// Bytes received
1132    pub rx_bytes: u64,
1133
1134    /// Packets received
1135    pub rx_packets: u32,
1136
1137    /// Receive errors
1138    pub rx_errs: u32,
1139
1140    /// Receive drops
1141    pub rx_drop: u32,
1142
1143    /// Bytes transmitted
1144    pub tx_bytes: u64,
1145
1146    /// Packets transmitted
1147    pub tx_packets: u32,
1148
1149    /// Transmit errors
1150    pub tx_errs: u32,
1151
1152    /// Transmit drops
1153    pub tx_drop: u32,
1154}
1155
1156/// HTTP Counters - Format (0,2201)
1157///
1158/// HTTP performance counters
1159///
1160/// # XDR Definition ([sFlow HTTP](https://sflow.org/sflow_http.txt))
1161///
1162/// ```text
1163/// /* HTTP counters */
1164/// /* opaque = counter_data; enterprise = 0; format = 2201 */
1165/// struct http_counters {
1166///   unsigned int method_option_count;
1167///   unsigned int method_get_count;
1168///   unsigned int method_head_count;
1169///   unsigned int method_post_count;
1170///   unsigned int method_put_count;
1171///   unsigned int method_delete_count;
1172///   unsigned int method_trace_count;
1173///   unsigned int method_connect_count;
1174///   unsigned int method_other_count;
1175///   unsigned int status_1XX_count;
1176///   unsigned int status_2XX_count;
1177///   unsigned int status_3XX_count;
1178///   unsigned int status_4XX_count;
1179///   unsigned int status_5XX_count;
1180///   unsigned int status_other_count;
1181/// }
1182/// ```
1183#[derive(Debug, Clone, PartialEq, Eq)]
1184#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1185pub struct HttpCounters {
1186    /// OPTIONS method count
1187    pub method_option_count: u32,
1188
1189    /// GET method count
1190    pub method_get_count: u32,
1191
1192    /// HEAD method count
1193    pub method_head_count: u32,
1194
1195    /// POST method count
1196    pub method_post_count: u32,
1197
1198    /// PUT method count
1199    pub method_put_count: u32,
1200
1201    /// DELETE method count
1202    pub method_delete_count: u32,
1203
1204    /// TRACE method count
1205    pub method_trace_count: u32,
1206
1207    /// CONNECT method count
1208    pub method_connect_count: u32,
1209
1210    /// Other method count
1211    pub method_other_count: u32,
1212
1213    /// 1XX status code count (spec: status_1XX_count)
1214    pub status_1xx_count: u32,
1215
1216    /// 2XX status code count (spec: status_2XX_count)
1217    pub status_2xx_count: u32,
1218
1219    /// 3XX status code count (spec: status_3XX_count)
1220    pub status_3xx_count: u32,
1221
1222    /// 4XX status code count (spec: status_4XX_count)
1223    pub status_4xx_count: u32,
1224
1225    /// 5XX status code count (spec: status_5XX_count)
1226    pub status_5xx_count: u32,
1227
1228    /// Other status code count
1229    pub status_other_count: u32,
1230}
1231
1232/// App Operations - Format (0,2202)
1233///
1234/// Count of operations by status code
1235///
1236/// # XDR Definition ([sFlow Application](https://sflow.org/sflow_application.txt))
1237///
1238/// ```text
1239/// /* Application counters */
1240/// /* opaque = counter_data; enterprise = 0; format = 2202 */
1241///
1242/// struct app_operations {
1243///     application application;
1244///     unsigned int success;
1245///     unsigned int other;
1246///     unsigned int timeout;
1247///     unsigned int internal_error;
1248///     unsigned int bad_request;
1249///     unsigned int forbidden;
1250///     unsigned int too_large;
1251///     unsigned int not_implemented;
1252///     unsigned int not_found;
1253///     unsigned int unavailable;
1254///     unsigned int unauthorized;
1255/// }
1256/// ```
1257#[derive(Debug, Clone, PartialEq, Eq)]
1258#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1259pub struct AppOperations {
1260    /// Application identifier
1261    pub application: String,
1262
1263    /// Successful operations
1264    pub success: u32,
1265
1266    /// Other status
1267    pub other: u32,
1268
1269    /// Timeout
1270    pub timeout: u32,
1271
1272    /// Internal error
1273    pub internal_error: u32,
1274
1275    /// Bad request
1276    pub bad_request: u32,
1277
1278    /// Forbidden
1279    pub forbidden: u32,
1280
1281    /// Too large
1282    pub too_large: u32,
1283
1284    /// Not implemented
1285    pub not_implemented: u32,
1286
1287    /// Not found
1288    pub not_found: u32,
1289
1290    /// Unavailable
1291    pub unavailable: u32,
1292
1293    /// Unauthorized
1294    pub unauthorized: u32,
1295}
1296
1297/// App Resources - Format (0,2203)
1298///
1299/// Application resource usage
1300///
1301/// # XDR Definition ([sFlow Application](https://sflow.org/sflow_application.txt))
1302///
1303/// ```text
1304/// /* Application resources */
1305/// /* opaque = counter_data; enterprise = 0; format = 2203 */
1306///
1307/// struct app_resources {
1308///     unsigned int user_time;   /* user time (ms) */
1309///     unsigned int system_time; /* system time (ms) */
1310///     unsigned hyper mem_used;  /* memory used in bytes */
1311///     unsigned hyper mem_max;   /* max memory in bytes */
1312///     unsigned int fd_open;     /* open file descriptors */
1313///     unsigned int fd_max;      /* max file descriptors */
1314///     unsigned int conn_open;   /* open network connections */
1315///     unsigned int conn_max;    /* max network connections */
1316/// }
1317/// ```
1318#[derive(Debug, Clone, PartialEq, Eq)]
1319#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1320pub struct AppResources {
1321    /// User time in milliseconds
1322    pub user_time: u32,
1323
1324    /// System time in milliseconds
1325    pub system_time: u32,
1326
1327    /// Memory used in bytes
1328    pub mem_used: u64,
1329
1330    /// Maximum memory in bytes
1331    pub mem_max: u64,
1332
1333    /// Number of open file descriptors
1334    pub fd_open: u32,
1335
1336    /// Maximum number of file descriptors
1337    pub fd_max: u32,
1338
1339    /// Number of open connections
1340    pub conn_open: u32,
1341
1342    /// Maximum number of connections
1343    pub conn_max: u32,
1344}
1345
1346/// App Workers - Format (0,2206)
1347///
1348/// Application worker thread/process statistics
1349///
1350/// # XDR Definition ([sFlow Application](https://sflow.org/sflow_application.txt))
1351///
1352/// ```text
1353/// /* Application workers */
1354/// /* opaque = counter_data; enterprise = 0; format = 2206 */
1355///
1356/// struct app_workers {
1357///     unsigned int workers_active; /* number of active workers */
1358///     unsigned int workers_idle;   /* number of idle workers */
1359///     unsigned int workers_max;    /* max number of workers */
1360///     unsigned int req_delayed;    /* requests delayed */
1361///     unsigned int req_dropped;    /* requests dropped */
1362/// }
1363/// ```
1364#[derive(Debug, Clone, PartialEq, Eq)]
1365#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1366pub struct AppWorkers {
1367    /// Number of active workers
1368    pub workers_active: u32,
1369
1370    /// Number of idle workers
1371    pub workers_idle: u32,
1372
1373    /// Maximum number of workers
1374    pub workers_max: u32,
1375
1376    /// Number of delayed requests
1377    pub req_delayed: u32,
1378
1379    /// Number of dropped requests
1380    pub req_dropped: u32,
1381}