update to new schema
This commit is contained in:
parent
02ea81cae3
commit
a514cef8d0
2 changed files with 17 additions and 17 deletions
|
|
@ -6,10 +6,10 @@ package towerops.agent;
|
||||||
message AgentConfig {
|
message AgentConfig {
|
||||||
string version = 1;
|
string version = 1;
|
||||||
uint32 poll_interval_seconds = 2;
|
uint32 poll_interval_seconds = 2;
|
||||||
repeated Equipment equipment = 3;
|
repeated Device devices = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Equipment {
|
message Device {
|
||||||
string id = 1;
|
string id = 1;
|
||||||
string name = 2;
|
string name = 2;
|
||||||
string ip_address = 3;
|
string ip_address = 3;
|
||||||
|
|
@ -116,8 +116,8 @@ message AgentJobList {
|
||||||
message AgentJob {
|
message AgentJob {
|
||||||
string job_id = 1;
|
string job_id = 1;
|
||||||
JobType job_type = 2;
|
JobType job_type = 2;
|
||||||
string equipment_id = 3;
|
string device_id = 3;
|
||||||
SnmpDevice device = 4;
|
SnmpDevice snmp_device = 4;
|
||||||
repeated SnmpQuery queries = 5;
|
repeated SnmpQuery queries = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -134,7 +134,7 @@ message SnmpQuery {
|
||||||
}
|
}
|
||||||
|
|
||||||
message SnmpResult {
|
message SnmpResult {
|
||||||
string equipment_id = 1;
|
string device_id = 1;
|
||||||
JobType job_type = 2;
|
JobType job_type = 2;
|
||||||
map<string, string> oid_values = 3;
|
map<string, string> oid_values = 3;
|
||||||
int64 timestamp = 4;
|
int64 timestamp = 4;
|
||||||
|
|
@ -148,7 +148,7 @@ message AgentHeartbeat {
|
||||||
}
|
}
|
||||||
|
|
||||||
message AgentError {
|
message AgentError {
|
||||||
string equipment_id = 1;
|
string device_id = 1;
|
||||||
string error_message = 2;
|
string error_message = 2;
|
||||||
int64 timestamp = 3;
|
int64 timestamp = 3;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -241,14 +241,14 @@ impl AgentClient {
|
||||||
let text = serde_json::to_string(&msg)?;
|
let text = serde_json::to_string(&msg)?;
|
||||||
self.ws_stream.send(WsMessage::Text(text)).await?;
|
self.ws_stream.send(WsMessage::Text(text)).await?;
|
||||||
|
|
||||||
log::debug!("Sent SNMP result for equipment {}", result.equipment_id);
|
log::debug!("Sent SNMP result for device {}", result.device_id);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Execute an SNMP job and collect results.
|
/// Execute an SNMP job and collect results.
|
||||||
async fn execute_job(job: AgentJob, result_tx: mpsc::UnboundedSender<SnmpResult>) -> Result<()> {
|
async fn execute_job(job: AgentJob, result_tx: mpsc::UnboundedSender<SnmpResult>) -> Result<()> {
|
||||||
let device = job.device.context("Job missing device info")?;
|
let snmp_device = job.snmp_device.context("Job missing SNMP device info")?;
|
||||||
let mut oid_values: HashMap<String, String> = HashMap::new();
|
let mut oid_values: HashMap<String, String> = HashMap::new();
|
||||||
let snmp_client = SnmpClient::new();
|
let snmp_client = SnmpClient::new();
|
||||||
|
|
||||||
|
|
@ -261,10 +261,10 @@ async fn execute_job(job: AgentJob, result_tx: mpsc::UnboundedSender<SnmpResult>
|
||||||
for oid in &query.oids {
|
for oid in &query.oids {
|
||||||
match snmp_client
|
match snmp_client
|
||||||
.get(
|
.get(
|
||||||
&device.ip,
|
&snmp_device.ip,
|
||||||
&device.community,
|
&snmp_device.community,
|
||||||
&device.version,
|
&snmp_device.version,
|
||||||
device.port as u16,
|
snmp_device.port as u16,
|
||||||
oid,
|
oid,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|
@ -283,10 +283,10 @@ async fn execute_job(job: AgentJob, result_tx: mpsc::UnboundedSender<SnmpResult>
|
||||||
for base_oid in &query.oids {
|
for base_oid in &query.oids {
|
||||||
match snmp_client
|
match snmp_client
|
||||||
.walk(
|
.walk(
|
||||||
&device.ip,
|
&snmp_device.ip,
|
||||||
&device.community,
|
&snmp_device.community,
|
||||||
&device.version,
|
&snmp_device.version,
|
||||||
device.port as u16,
|
snmp_device.port as u16,
|
||||||
base_oid,
|
base_oid,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|
@ -307,7 +307,7 @@ async fn execute_job(job: AgentJob, result_tx: mpsc::UnboundedSender<SnmpResult>
|
||||||
|
|
||||||
// Build result
|
// Build result
|
||||||
let result = SnmpResult {
|
let result = SnmpResult {
|
||||||
equipment_id: job.equipment_id,
|
device_id: job.device_id,
|
||||||
job_type: job.job_type,
|
job_type: job.job_type,
|
||||||
oid_values,
|
oid_values,
|
||||||
timestamp: std::time::SystemTime::now()
|
timestamp: std::time::SystemTime::now()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue