mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2026-10-25 14:20:05 -05:00
Feat: add optional byte_counters configuration section
Adds a [byte_counters] section that is absent by default, so existing configuration files keep working unchanged. The section will gate cumulative per-circuit and per-node byte counter collection in lqosd.
This commit is contained in:
1 parent
61a83dcd14
commit
433914842a
5 files changed
+55
No files matched your search
@@ -70,6 +70,10 @@ netflow_enabled = false
|
||||
# netflow_version = 9
|
||||
do_not_track_subnets = [ "192.168.66.0/24" ]
|
||||
|
||||
[byte_counters]
|
||||
# Optional cumulative byte counters for nodes and circuits, exposed by lqos_api.
|
||||
enabled = false
|
||||
|
||||
[integration_common]
|
||||
circuit_name_as_address = false
|
||||
queue_refresh_interval_mins = 30
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
//! Configuration for optional cumulative byte counters.
|
||||
//!
|
||||
//! When enabled, `lqosd` accumulates per-circuit byte totals from the
|
||||
//! one-second throughput tracker and exposes cumulative per-circuit and
|
||||
//! per-node counters on the local bus.
|
||||
|
||||
use allocative::Allocative;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Configuration for optional cumulative byte counters.
|
||||
#[derive(Clone, Default, Serialize, Deserialize, Debug, PartialEq, Allocative)]
|
||||
pub struct ByteCountersConfig {
|
||||
/// Enables cumulative per-circuit and per-node byte counters.
|
||||
///
|
||||
/// Defaults to `false` when the `[byte_counters]` section is absent so
|
||||
/// existing configuration files keep their current behavior.
|
||||
#[serde(default)]
|
||||
pub enabled: bool,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::ByteCountersConfig;
|
||||
|
||||
#[test]
|
||||
fn absent_section_defaults_to_disabled() {
|
||||
let config: ByteCountersConfig =
|
||||
toml::from_str("").expect("empty byte_counters section should parse");
|
||||
assert!(!config.enabled);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn section_parses_enabled_flag() {
|
||||
let config: ByteCountersConfig =
|
||||
toml::from_str("enabled = true").expect("enabled flag should parse");
|
||||
assert!(config.enabled);
|
||||
}
|
||||
}
|
||||
@@ -102,6 +102,10 @@ collation_period_seconds = 10
|
||||
license_key = "(data)"
|
||||
uisp_reporting_interval_seconds = 300
|
||||
|
||||
[byte_counters]
|
||||
# Optional cumulative byte counters for nodes and circuits, exposed by lqos_api.
|
||||
enabled = false
|
||||
|
||||
[local_api]
|
||||
bearer_token = ""
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ pub use top_config::Config;
|
||||
pub use top_config::RttThresholds;
|
||||
pub use top_config::{SslConfig, normalize_external_hostname};
|
||||
mod bridge;
|
||||
mod byte_counters;
|
||||
mod dynamic_circuits;
|
||||
mod flows;
|
||||
pub mod influxdb;
|
||||
|
||||
@@ -277,6 +277,13 @@ pub struct Config {
|
||||
/// Enable per-ASN TemporalHeatmap collection.
|
||||
#[serde(default = "default_true")]
|
||||
pub enable_asn_heatmaps: bool,
|
||||
|
||||
/// Optional cumulative byte counters for nodes and circuits.
|
||||
///
|
||||
/// The section is optional so older configuration files keep working
|
||||
/// unchanged; counters are disabled when it is absent.
|
||||
#[serde(default)]
|
||||
pub byte_counters: super::byte_counters::ByteCountersConfig,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
@@ -482,6 +489,7 @@ impl Default for Config {
|
||||
enable_circuit_heatmaps: true,
|
||||
enable_site_heatmaps: true,
|
||||
enable_asn_heatmaps: true,
|
||||
byte_counters: super::byte_counters::ByteCountersConfig::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user