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