Testing
This commit is contained in:
parent
d9edcda36c
commit
4d8bacef50
@ -10,22 +10,8 @@ pub mod smart;
|
|||||||
|
|
||||||
pub use error::CollectorError;
|
pub use error::CollectorError;
|
||||||
|
|
||||||
#[derive(Debug, Clone, serde::Serialize)]
|
pub use cm_dashboard_shared::envelope::AgentType;
|
||||||
pub enum AgentType {
|
|
||||||
Smart,
|
|
||||||
Service,
|
|
||||||
Backup,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AgentType {
|
|
||||||
pub fn as_str(&self) -> &'static str {
|
|
||||||
match self {
|
|
||||||
AgentType::Smart => "smart",
|
|
||||||
AgentType::Service => "service",
|
|
||||||
AgentType::Backup => "backup",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct CollectorOutput {
|
pub struct CollectorOutput {
|
||||||
|
|||||||
@ -9,8 +9,9 @@ use crate::collectors::{
|
|||||||
backup::BackupCollector,
|
backup::BackupCollector,
|
||||||
service::ServiceCollector,
|
service::ServiceCollector,
|
||||||
smart::SmartCollector,
|
smart::SmartCollector,
|
||||||
Collector, AgentType
|
Collector
|
||||||
};
|
};
|
||||||
|
use cm_dashboard_shared::envelope::AgentType;
|
||||||
use crate::discovery::AutoDiscovery;
|
use crate::discovery::AutoDiscovery;
|
||||||
use crate::notifications::{NotificationManager, NotificationConfig};
|
use crate::notifications::{NotificationManager, NotificationConfig};
|
||||||
|
|
||||||
@ -143,10 +144,10 @@ impl SimpleAgent {
|
|||||||
|
|
||||||
async fn send_metrics(&self, agent_type: &AgentType, data: &serde_json::Value) -> anyhow::Result<()> {
|
async fn send_metrics(&self, agent_type: &AgentType, data: &serde_json::Value) -> anyhow::Result<()> {
|
||||||
let message = serde_json::json!({
|
let message = serde_json::json!({
|
||||||
"host": self.hostname,
|
"hostname": self.hostname,
|
||||||
"agent_type": agent_type,
|
"agent_type": agent_type,
|
||||||
"data": data,
|
"timestamp": Utc::now().timestamp() as u64,
|
||||||
"timestamp": Utc::now()
|
"metrics": data
|
||||||
});
|
});
|
||||||
|
|
||||||
let serialized = serde_json::to_string(&message)?;
|
let serialized = serde_json::to_string(&message)?;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user