fix: now everything is a tag in the device data point
Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
This commit is contained in:
parent
d72d1530dc
commit
f7876ad105
23
src/main.rs
23
src/main.rs
@ -4,7 +4,7 @@ use std::time::{Duration, Instant};
|
||||
use futures::prelude::*;
|
||||
use influxdb2::models::DataPoint;
|
||||
use livebox::{devices::Device, status::Status, wan::WANConfiguration, client::Client};
|
||||
use log::{debug, info, error};
|
||||
use log::{debug, info};
|
||||
use tokio::join;
|
||||
|
||||
|
||||
@ -127,14 +127,21 @@ async fn devices_to_datapoints(devices: &Vec<Device>, hostname: &String)
|
||||
DataPoint::builder("devices")
|
||||
.tag("hostname", hostname)
|
||||
.tag("key", d.key.clone())
|
||||
.field("name", d.name.clone())
|
||||
.field("discovery_source", d.discovery_source.clone())
|
||||
.field("active", d.active)
|
||||
.field("device_type", d.device_type.clone())
|
||||
.tag("discovery_source", d.discovery_source.clone())
|
||||
.tag("active", if d.active { "true" } else { "false" })
|
||||
.tag("device_type",
|
||||
if d.device_type.is_empty() { "N/A" }
|
||||
else { d.device_type.as_str() })
|
||||
.tag("ip_address",
|
||||
if d.ip_address.is_none()
|
||||
|| d.ip_address.clone().unwrap().is_empty() { "N/A".to_string() }
|
||||
else { d.ip_address.clone().unwrap() })
|
||||
.tag("ssid", d.ssid.clone().unwrap_or("N/A".to_string()))
|
||||
.tag("channel",
|
||||
if d.channel.is_none() { "N/A".to_string() }
|
||||
else { d.channel.unwrap().to_string() })
|
||||
.tag("name", d.name.clone())
|
||||
.field("tags", d.tags.clone())
|
||||
.field("ip_address", d.ip_address.clone().unwrap_or("N/A".to_string()))
|
||||
.field("ssid", d.ssid.clone().unwrap_or("N/A".to_string()))
|
||||
.field("channel", d.channel.unwrap_or(0) as i64).tag("key", d.key.clone())
|
||||
.build().unwrap(),
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user