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#[derive(Debug, Clone, Copy, PartialEq, Eq)]
483#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
484#[repr(u32)]
485pub enum MachineType {
486 Unknown = 0,
487 Other = 1,
488 X86 = 2,
489 X86_64 = 3,
490 Ia64 = 4,
491 Sparc = 5,
492 Alpha = 6,
493 Powerpc = 7,
494 M68k = 8,
495 Mips = 9,
496 Arm = 10,
497 Hppa = 11,
498 S390 = 12,
499}
500
501impl From<u32> for MachineType {
502 fn from(value: u32) -> Self {
503 match value {
504 0 => MachineType::Unknown,
505 1 => MachineType::Other,
506 2 => MachineType::X86,
507 3 => MachineType::X86_64,
508 4 => MachineType::Ia64,
509 5 => MachineType::Sparc,
510 6 => MachineType::Alpha,
511 7 => MachineType::Powerpc,
512 8 => MachineType::M68k,
513 9 => MachineType::Mips,
514 10 => MachineType::Arm,
515 11 => MachineType::Hppa,
516 12 => MachineType::S390,
517 _ => MachineType::Unknown,
518 }
519 }
520}
521
522/// Operating System Name enumeration
523///
524/// OS types as defined in sFlow v5 specification
525#[derive(Debug, Clone, Copy, PartialEq, Eq)]
526#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
527#[repr(u32)]
528pub enum OsName {
529 Unknown = 0,
530 Other = 1,
531 Linux = 2,
532 Windows = 3,
533 Darwin = 4,
534 Hpux = 5,
535 Aix = 6,
536 Dragonfly = 7,
537 Freebsd = 8,
538 Netbsd = 9,
539 Openbsd = 10,
540 Osf = 11,
541 Solaris = 12,
542}
543
544impl From<u32> for OsName {
545 fn from(value: u32) -> Self {
546 match value {
547 0 => OsName::Unknown,
548 1 => OsName::Other,
549 2 => OsName::Linux,
550 3 => OsName::Windows,
551 4 => OsName::Darwin,
552 5 => OsName::Hpux,
553 6 => OsName::Aix,
554 7 => OsName::Dragonfly,
555 8 => OsName::Freebsd,
556 9 => OsName::Netbsd,
557 10 => OsName::Openbsd,
558 11 => OsName::Osf,
559 12 => OsName::Solaris,
560 _ => OsName::Unknown,
561 }
562 }
563}
564
565/// Host Description - Format (0,2000)
566///
567/// Physical or virtual host description
568///
569/// # XDR Definition ([sFlow Host](https://sflow.org/sflow_host.txt))
570///
571/// ```text
572/// /* Physical or virtual host description */
573/// /* opaque = counter_data; enterprise = 0; format = 2000 */
574///
575/// struct host_descr {
576/// string hostname<64>; /* hostname, empty if unknown */
577/// opaque uuid<16>; /* 16 bytes binary UUID, empty if unknown */
578/// machine_type machine_type; /* the processor family */
579/// os_name os_name; /* Operating system */
580/// string os_release<32>; /* e.g. 2.6.9-42.ELsmp,xp-sp3, empty if unknown */
581/// }
582/// ```
583///
584/// **ERRATUM:** UUID field changed from `opaque uuid<16>` to `opaque uuid[16]` (fixed array).
585#[derive(Debug, Clone, PartialEq, Eq)]
586#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
587pub struct HostDescription {
588 /// Hostname
589 pub hostname: String,
590
591 /// UUID (16 bytes)
592 /// **ERRATUM:** All zeros if unknown (changed from variable-length to fixed-length array)
593 pub uuid: [u8; 16],
594
595 /// Machine type (processor family)
596 pub machine_type: MachineType,
597
598 /// Operating system name
599 pub os_name: OsName,
600
601 /// OS release (e.g., "5.10.0")
602 pub os_release: String,
603}
604
605/// Host Adapters - Format (0,2001)
606///
607/// Set of network adapters associated with entity
608///
609/// # XDR Definition ([sFlow Host](https://sflow.org/sflow_host.txt))
610///
611/// ```text
612/// /* Set of adapters associated with entity */
613/// /* opaque = counter_data; enterprise = 0; format = 2001 */
614///
615/// struct host_adapters {
616/// adapter adapters<>; /* adapter(s) associated with entity */
617/// }
618/// ```
619#[derive(Debug, Clone, PartialEq, Eq)]
620#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
621pub struct HostAdapters {
622 /// Adapters
623 pub adapters: Vec<HostAdapter>,
624}
625
626#[derive(Debug, Clone, PartialEq, Eq)]
627#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
628pub struct HostAdapter {
629 /// Interface index
630 pub if_index: u32,
631
632 /// MAC addresses
633 pub mac_addresses: Vec<crate::models::MacAddress>,
634}
635
636/// Host Parent - Format (0,2002)
637///
638/// Containment hierarchy between logical and physical entities
639///
640/// # XDR Definition ([sFlow Host](https://sflow.org/sflow_host.txt))
641///
642/// ```text
643/// /* Define containment hierarchy */
644/// /* opaque = counter_data; enterprise = 0; format = 2002 */
645///
646/// struct host_parent {
647/// unsigned int container_type; /* sFlowDataSource type */
648/// unsigned int container_index; /* sFlowDataSource index */
649/// }
650/// ```
651#[derive(Debug, Clone, PartialEq, Eq)]
652#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
653pub struct HostParent {
654 /// Container type (e.g., "docker", "lxc")
655 pub container_type: u32,
656
657 /// Container index
658 pub container_index: u32,
659}
660
661/// Host CPU - Format (0,2003)
662///
663/// Physical server CPU statistics
664///
665/// # XDR Definition ([sFlow Host](https://sflow.org/sflow_host.txt))
666///
667/// ```text
668/// /* Physical Server CPU */
669/// /* opaque = counter_data; enterprise = 0; format = 2003 */
670///
671/// struct host_cpu {
672/// float load_one; /* 1 minute load avg */
673/// float load_five; /* 5 minute load avg */
674/// float load_fifteen; /* 15 minute load avg */
675/// unsigned int proc_run; /* running processes */
676/// unsigned int proc_total; /* total processes */
677/// unsigned int cpu_num; /* number of CPUs */
678/// unsigned int cpu_speed; /* CPU speed in MHz */
679/// unsigned int uptime; /* seconds since last reboot */
680/// unsigned int cpu_user; /* user time (ms) */
681/// unsigned int cpu_nice; /* nice time (ms) */
682/// unsigned int cpu_system; /* system time (ms) */
683/// unsigned int cpu_idle; /* idle time (ms) */
684/// unsigned int cpu_wio; /* I/O wait time (ms) */
685/// unsigned int cpu_intr; /* interrupt time (ms) */
686/// unsigned int cpu_sintr; /* soft interrupt time (ms) */
687/// unsigned int interrupts; /* interrupt count */
688/// unsigned int contexts; /* context switch count */
689/// }
690/// ```
691#[derive(Debug, Clone, PartialEq, Eq)]
692#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
693pub struct HostCpu {
694 /// Load average (1 minute) - stored as hundredths (multiply by 100)
695 pub load_one: u32,
696
697 /// Load average (5 minutes) - stored as hundredths (multiply by 100)
698 pub load_five: u32,
699
700 /// Load average (15 minutes) - stored as hundredths (multiply by 100)
701 pub load_fifteen: u32,
702
703 /// Number of running processes
704 pub proc_run: u32,
705
706 /// Total number of processes
707 pub proc_total: u32,
708
709 /// Number of CPUs
710 pub cpu_num: u32,
711
712 /// CPU speed in MHz
713 pub cpu_speed: u32,
714
715 /// CPU uptime in seconds
716 pub uptime: u32,
717
718 /// CPU time in user mode (ms)
719 pub cpu_user: u32,
720
721 /// CPU time in nice mode (ms)
722 pub cpu_nice: u32,
723
724 /// CPU time in system mode (ms)
725 pub cpu_system: u32,
726
727 /// CPU idle time (ms)
728 pub cpu_idle: u32,
729
730 /// CPU time waiting for I/O (ms)
731 pub cpu_wio: u32,
732
733 /// CPU time servicing interrupts (ms)
734 pub cpu_intr: u32,
735
736 /// CPU time servicing soft interrupts (ms)
737 pub cpu_sintr: u32,
738
739 /// Number of interrupts
740 pub interrupts: u32,
741
742 /// Number of context switches
743 pub contexts: u32,
744}
745
746/// Host Memory - Format (0,2004)
747///
748/// Physical server memory statistics
749///
750/// # XDR Definition ([sFlow Host](https://sflow.org/sflow_host.txt))
751///
752/// ```text
753/// /* Physical Server Memory */
754/// /* opaque = counter_data; enterprise = 0; format = 2004 */
755///
756/// struct host_memory {
757/// unsigned hyper mem_total; /* total bytes */
758/// unsigned hyper mem_free; /* free bytes */
759/// unsigned hyper mem_shared; /* shared bytes */
760/// unsigned hyper mem_buffers; /* buffers bytes */
761/// unsigned hyper mem_cached; /* cached bytes */
762/// unsigned hyper swap_total; /* swap total bytes */
763/// unsigned hyper swap_free; /* swap free bytes */
764/// unsigned int page_in; /* page in count */
765/// unsigned int page_out; /* page out count */
766/// unsigned int swap_in; /* swap in count */
767/// unsigned int swap_out; /* swap out count */
768/// }
769/// ```
770#[derive(Debug, Clone, PartialEq, Eq)]
771#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
772pub struct HostMemory {
773 /// Total memory in bytes
774 pub mem_total: u64,
775
776 /// Free memory in bytes
777 pub mem_free: u64,
778
779 /// Shared memory in bytes
780 pub mem_shared: u64,
781
782 /// Memory used for buffers in bytes
783 pub mem_buffers: u64,
784
785 /// Memory used for cache in bytes
786 pub mem_cached: u64,
787
788 /// Total swap space in bytes
789 pub swap_total: u64,
790
791 /// Free swap space in bytes
792 pub swap_free: u64,
793
794 /// Page in count
795 pub page_in: u32,
796
797 /// Page out count
798 pub page_out: u32,
799
800 /// Swap in count
801 pub swap_in: u32,
802
803 /// Swap out count
804 pub swap_out: u32,
805}
806
807/// Host Disk I/O - Format (0,2005)
808///
809/// Physical server disk I/O statistics
810///
811/// # XDR Definition ([sFlow Host](https://sflow.org/sflow_host.txt))
812///
813/// ```text
814/// /* Physical Server Disk I/O */
815/// /* opaque = counter_data; enterprise = 0; format = 2005 */
816///
817/// struct host_disk_io {
818/// unsigned hyper disk_total; /* total disk size in bytes */
819/// unsigned hyper disk_free; /* total disk free in bytes */
820/// percentage part_max_used; /* utilization of most utilized partition */
821/// unsigned int reads; /* reads issued */
822/// unsigned hyper bytes_read; /* bytes read */
823/// unsigned int read_time; /* read time (ms) */
824/// unsigned int writes; /* writes completed */
825/// unsigned hyper bytes_written; /* bytes written */
826/// unsigned int write_time; /* write time (ms) */
827/// }
828/// ```
829#[derive(Debug, Clone, PartialEq, Eq)]
830#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
831pub struct HostDiskIo {
832 /// Total disk capacity in bytes
833 pub disk_total: u64,
834
835 /// Free disk space in bytes
836 pub disk_free: u64,
837
838 /// Percentage of disk used (0-100)
839 pub part_max_used: u32,
840
841 /// Number of disk reads
842 pub reads: u32,
843
844 /// Bytes read from disk
845 pub bytes_read: u64,
846
847 /// Read time in milliseconds
848 pub read_time: u32,
849
850 /// Number of disk writes
851 pub writes: u32,
852
853 /// Bytes written to disk
854 pub bytes_written: u64,
855
856 /// Write time in milliseconds
857 pub write_time: u32,
858}
859
860/// Host Network I/O - Format (0,2006)
861///
862/// Physical server network I/O statistics
863///
864/// # XDR Definition ([sFlow Host](https://sflow.org/sflow_host.txt))
865///
866/// ```text
867/// /* Physical Server Network I/O */
868/// /* opaque = counter_data; enterprise = 0; format = 2006 */
869///
870/// struct host_net_io {
871/// unsigned hyper bytes_in; /* total bytes in */
872/// unsigned int pkts_in; /* total packets in */
873/// unsigned int errs_in; /* total errors in */
874/// unsigned int drops_in; /* total drops in */
875/// unsigned hyper bytes_out; /* total bytes out */
876/// unsigned int packets_out; /* total packets out */
877/// unsigned int errs_out; /* total errors out */
878/// unsigned int drops_out; /* total drops out */
879/// }
880/// ```
881#[derive(Debug, Clone, PartialEq, Eq)]
882#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
883pub struct HostNetIo {
884 /// Bytes received
885 pub bytes_in: u64,
886
887 /// Packets received
888 pub pkts_in: u32,
889
890 /// Receive errors
891 pub errs_in: u32,
892
893 /// Receive drops
894 pub drops_in: u32,
895
896 /// Bytes transmitted
897 pub bytes_out: u64,
898
899 /// Packets transmitted
900 pub packets_out: u32,
901
902 /// Transmit errors
903 pub errs_out: u32,
904
905 /// Transmit drops
906 pub drops_out: u32,
907}
908
909/// Virtual Node - Format (0,2100)
910///
911/// Hypervisor statistics
912///
913/// # XDR Definition ([sFlow Host](https://sflow.org/sflow_host.txt))
914///
915/// ```text
916/// /* Virtual Node Statistics */
917/// /* opaque = counter_data; enterprise = 0; format = 2100 */
918///
919/// struct virt_node {
920/// unsigned int mhz; /* expected CPU frequency */
921/// unsigned int cpus; /* number of active CPUs */
922/// unsigned hyper memory; /* memory size in bytes */
923/// unsigned hyper memory_free; /* unassigned memory in bytes */
924/// unsigned int num_domains; /* number of active domains */
925/// }
926/// ```
927#[derive(Debug, Clone, PartialEq, Eq)]
928#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
929pub struct VirtualNode {
930 /// Expected CPU frequency in MHz
931 pub mhz: u32,
932
933 /// Number of active CPUs
934 pub cpus: u32,
935
936 /// Memory size in bytes
937 pub memory: u64,
938
939 /// Unassigned memory in bytes
940 pub memory_free: u64,
941
942 /// Number of active domains
943 pub num_domains: u32,
944}
945
946/// Virtual CPU - Format (0,2101)
947///
948/// Virtual domain CPU statistics
949///
950/// # XDR Definition ([sFlow Host](https://sflow.org/sflow_host.txt))
951///
952/// ```text
953/// /* Virtual Domain CPU statistics */
954/// /* See libvirt, struct virDomainInfo */
955/// /* opaque = counter_data; enterprise = 0; format = 2101 */
956///
957/// struct virt_cpu {
958/// unsigned int state; /* virtDomainState */
959/// unsigned int cpuTime; /* CPU time used (ms) */
960/// unsigned int nrVirtCpu;/* number of virtual CPUs */
961/// }
962/// ```
963///
964/// **ERRATUM:** Comment reference corrected from `virtDomainInfo` to `virDomainInfo`.
965#[derive(Debug, Clone, PartialEq, Eq)]
966#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
967pub struct VirtualCpu {
968 /// CPU state (0=running, 1=idle, 2=blocked)
969 pub state: u32,
970
971 /// CPU time in milliseconds
972 pub cpu_time: u32,
973
974 /// Number of virtual CPUs
975 pub nr_virt_cpu: u32,
976}
977
978/// Virtual Memory - Format (0,2102)
979///
980/// Virtual domain memory statistics
981///
982/// # XDR Definition ([sFlow Host](https://sflow.org/sflow_host.txt))
983///
984/// ```text
985/// /* Virtual Domain Memory statistics */
986/// /* See libvirt, struct virDomainInfo */
987/// /* opaque = counter_data; enterprise = 0; format = 2102 */
988///
989/// struct virt_memory {
990/// unsigned hyper memory; /* memory in bytes used by domain */
991/// unsigned hyper maxMemory; /* memory in bytes allowed */
992/// }
993/// ```
994///
995/// **ERRATUM:** Comment reference corrected from `virtDomainInfo` to `virDomainInfo`.
996#[derive(Debug, Clone, PartialEq, Eq)]
997#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
998pub struct VirtualMemory {
999 /// Memory in bytes
1000 pub memory: u64,
1001
1002 /// Maximum memory in bytes
1003 pub max_memory: u64,
1004}
1005
1006/// Virtual Disk I/O - Format (0,2103)
1007///
1008/// Virtual domain disk statistics
1009///
1010/// # XDR Definition ([sFlow Host](https://sflow.org/sflow_host.txt))
1011///
1012/// ```text
1013/// /* Virtual Domain Disk statistics */
1014/// /* See libvirt, struct virDomainBlockInfo */
1015/// /* See libvirt, struct virDomainBlockStatsStruct */
1016/// /* opaque = counter_data; enterprise = 0; format = 2103 */
1017///
1018/// struct virt_disk_io {
1019/// unsigned hyper capacity; /* logical size in bytes */
1020/// unsigned hyper allocation; /* current allocation in bytes */
1021/// unsigned hyper physical; /* physical size in bytes of the container of the backing image */
1022/// unsigned int rd_req; /* number of read requests */
1023/// unsigned hyper rd_bytes; /* number of read bytes */
1024/// unsigned int wr_req; /* number of write requests */
1025/// unsigned hyper wr_bytes; /* number of written bytes */
1026/// unsigned int errs; /* read/write errors */
1027/// }
1028/// ```
1029///
1030/// **ERRATUM:** Field name changed from `available` to `physical`, and comment references corrected
1031/// from `virtDomainBlockInfo`/`virtDomainBlockStatsStruct` to `virDomainBlockInfo`/`virDomainBlockStatsStruct`.
1032#[derive(Debug, Clone, PartialEq, Eq)]
1033#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1034pub struct VirtualDiskIo {
1035 /// Capacity in bytes
1036 pub capacity: u64,
1037
1038 /// Allocation in bytes
1039 pub allocation: u64,
1040
1041 /// Physical size in bytes of the container of the backing image (spec: physical)
1042 /// **ERRATUM:** Field renamed from `available` (remaining free bytes) to `physical`
1043 pub available: u64,
1044
1045 /// Read requests
1046 pub rd_req: u32,
1047
1048 /// Bytes read
1049 pub rd_bytes: u64,
1050
1051 /// Write requests
1052 pub wr_req: u32,
1053
1054 /// Bytes written
1055 pub wr_bytes: u64,
1056
1057 /// Errors
1058 pub errs: u32,
1059}
1060
1061/// Virtual Network I/O - Format (0,2104)
1062///
1063/// Virtual domain network statistics
1064///
1065/// # XDR Definition ([sFlow Host](https://sflow.org/sflow_host.txt))
1066///
1067/// ```text
1068/// /* Virtual Domain Network statistics */
1069/// /* See libvirt, struct virDomainInterfaceStatsStruct */
1070/// /* opaque = counter_data; enterprise = 0; format = 2104 */
1071///
1072/// struct virt_net_io {
1073/// unsigned hyper rx_bytes; /* total bytes received */
1074/// unsigned int rx_packets; /* total packets received */
1075/// unsigned int rx_errs; /* total receive errors */
1076/// unsigned int rx_drop; /* total receive drops */
1077/// unsigned hyper tx_bytes; /* total bytes transmitted */
1078/// unsigned int tx_packets; /* total packets transmitted */
1079/// unsigned int tx_errs; /* total transmit errors */
1080/// unsigned int tx_drop; /* total transmit drops */
1081/// }
1082/// ```
1083///
1084/// **ERRATUM:** Comment reference corrected from `virtDomainInterfaceStatsStruct` to `virDomainInterfaceStatsStruct`.
1085#[derive(Debug, Clone, PartialEq, Eq)]
1086#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1087pub struct VirtualNetIo {
1088 /// Bytes received
1089 pub rx_bytes: u64,
1090
1091 /// Packets received
1092 pub rx_packets: u32,
1093
1094 /// Receive errors
1095 pub rx_errs: u32,
1096
1097 /// Receive drops
1098 pub rx_drop: u32,
1099
1100 /// Bytes transmitted
1101 pub tx_bytes: u64,
1102
1103 /// Packets transmitted
1104 pub tx_packets: u32,
1105
1106 /// Transmit errors
1107 pub tx_errs: u32,
1108
1109 /// Transmit drops
1110 pub tx_drop: u32,
1111}
1112
1113/// HTTP Counters - Format (0,2201)
1114///
1115/// HTTP performance counters
1116///
1117/// # XDR Definition ([sFlow HTTP](https://sflow.org/sflow_http.txt))
1118///
1119/// ```text
1120/// /* HTTP counters */
1121/// /* opaque = counter_data; enterprise = 0; format = 2201 */
1122/// struct http_counters {
1123/// unsigned int method_option_count;
1124/// unsigned int method_get_count;
1125/// unsigned int method_head_count;
1126/// unsigned int method_post_count;
1127/// unsigned int method_put_count;
1128/// unsigned int method_delete_count;
1129/// unsigned int method_trace_count;
1130/// unsigned int method_connect_count;
1131/// unsigned int method_other_count;
1132/// unsigned int status_1XX_count;
1133/// unsigned int status_2XX_count;
1134/// unsigned int status_3XX_count;
1135/// unsigned int status_4XX_count;
1136/// unsigned int status_5XX_count;
1137/// unsigned int status_other_count;
1138/// }
1139/// ```
1140#[derive(Debug, Clone, PartialEq, Eq)]
1141#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1142pub struct HttpCounters {
1143 /// OPTIONS method count
1144 pub method_option_count: u32,
1145
1146 /// GET method count
1147 pub method_get_count: u32,
1148
1149 /// HEAD method count
1150 pub method_head_count: u32,
1151
1152 /// POST method count
1153 pub method_post_count: u32,
1154
1155 /// PUT method count
1156 pub method_put_count: u32,
1157
1158 /// DELETE method count
1159 pub method_delete_count: u32,
1160
1161 /// TRACE method count
1162 pub method_trace_count: u32,
1163
1164 /// CONNECT method count
1165 pub method_connect_count: u32,
1166
1167 /// Other method count
1168 pub method_other_count: u32,
1169
1170 /// 1XX status code count (spec: status_1XX_count)
1171 pub status_1xx_count: u32,
1172
1173 /// 2XX status code count (spec: status_2XX_count)
1174 pub status_2xx_count: u32,
1175
1176 /// 3XX status code count (spec: status_3XX_count)
1177 pub status_3xx_count: u32,
1178
1179 /// 4XX status code count (spec: status_4XX_count)
1180 pub status_4xx_count: u32,
1181
1182 /// 5XX status code count (spec: status_5XX_count)
1183 pub status_5xx_count: u32,
1184
1185 /// Other status code count
1186 pub status_other_count: u32,
1187}
1188
1189/// App Operations - Format (0,2202)
1190///
1191/// Count of operations by status code
1192///
1193/// # XDR Definition ([sFlow Application](https://sflow.org/sflow_application.txt))
1194///
1195/// ```text
1196/// /* Application counters */
1197/// /* opaque = counter_data; enterprise = 0; format = 2202 */
1198///
1199/// struct app_operations {
1200/// application application;
1201/// unsigned int success;
1202/// unsigned int other;
1203/// unsigned int timeout;
1204/// unsigned int internal_error;
1205/// unsigned int bad_request;
1206/// unsigned int forbidden;
1207/// unsigned int too_large;
1208/// unsigned int not_implemented;
1209/// unsigned int not_found;
1210/// unsigned int unavailable;
1211/// unsigned int unauthorized;
1212/// }
1213/// ```
1214#[derive(Debug, Clone, PartialEq, Eq)]
1215#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1216pub struct AppOperations {
1217 /// Application identifier
1218 pub application: String,
1219
1220 /// Successful operations
1221 pub success: u32,
1222
1223 /// Other status
1224 pub other: u32,
1225
1226 /// Timeout
1227 pub timeout: u32,
1228
1229 /// Internal error
1230 pub internal_error: u32,
1231
1232 /// Bad request
1233 pub bad_request: u32,
1234
1235 /// Forbidden
1236 pub forbidden: u32,
1237
1238 /// Too large
1239 pub too_large: u32,
1240
1241 /// Not implemented
1242 pub not_implemented: u32,
1243
1244 /// Not found
1245 pub not_found: u32,
1246
1247 /// Unavailable
1248 pub unavailable: u32,
1249
1250 /// Unauthorized
1251 pub unauthorized: u32,
1252}
1253
1254/// App Resources - Format (0,2203)
1255///
1256/// Application resource usage
1257///
1258/// # XDR Definition ([sFlow Application](https://sflow.org/sflow_application.txt))
1259///
1260/// ```text
1261/// /* Application resources */
1262/// /* opaque = counter_data; enterprise = 0; format = 2203 */
1263///
1264/// struct app_resources {
1265/// unsigned int user_time; /* user time (ms) */
1266/// unsigned int system_time; /* system time (ms) */
1267/// unsigned hyper mem_used; /* memory used in bytes */
1268/// unsigned hyper mem_max; /* max memory in bytes */
1269/// unsigned int fd_open; /* open file descriptors */
1270/// unsigned int fd_max; /* max file descriptors */
1271/// unsigned int conn_open; /* open network connections */
1272/// unsigned int conn_max; /* max network connections */
1273/// }
1274/// ```
1275#[derive(Debug, Clone, PartialEq, Eq)]
1276#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1277pub struct AppResources {
1278 /// User time in milliseconds
1279 pub user_time: u32,
1280
1281 /// System time in milliseconds
1282 pub system_time: u32,
1283
1284 /// Memory used in bytes
1285 pub mem_used: u64,
1286
1287 /// Maximum memory in bytes
1288 pub mem_max: u64,
1289
1290 /// Number of open file descriptors
1291 pub fd_open: u32,
1292
1293 /// Maximum number of file descriptors
1294 pub fd_max: u32,
1295
1296 /// Number of open connections
1297 pub conn_open: u32,
1298
1299 /// Maximum number of connections
1300 pub conn_max: u32,
1301}
1302
1303/// App Workers - Format (0,2206)
1304///
1305/// Application worker thread/process statistics
1306///
1307/// # XDR Definition ([sFlow Application](https://sflow.org/sflow_application.txt))
1308///
1309/// ```text
1310/// /* Application workers */
1311/// /* opaque = counter_data; enterprise = 0; format = 2206 */
1312///
1313/// struct app_workers {
1314/// unsigned int workers_active; /* number of active workers */
1315/// unsigned int workers_idle; /* number of idle workers */
1316/// unsigned int workers_max; /* max number of workers */
1317/// unsigned int req_delayed; /* requests delayed */
1318/// unsigned int req_dropped; /* requests dropped */
1319/// }
1320/// ```
1321#[derive(Debug, Clone, PartialEq, Eq)]
1322#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1323pub struct AppWorkers {
1324 /// Number of active workers
1325 pub workers_active: u32,
1326
1327 /// Number of idle workers
1328 pub workers_idle: u32,
1329
1330 /// Maximum number of workers
1331 pub workers_max: u32,
1332
1333 /// Number of delayed requests
1334 pub req_delayed: u32,
1335
1336 /// Number of dropped requests
1337 pub req_dropped: u32,
1338}