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 {
|
||||
string version = 1;
|
||||
uint32 poll_interval_seconds = 2;
|
||||
repeated Equipment equipment = 3;
|
||||
repeated Device devices = 3;
|
||||
}
|
||||
|
||||
message Equipment {
|
||||
message Device {
|
||||
string id = 1;
|
||||
string name = 2;
|
||||
string ip_address = 3;
|
||||
|
|
@ -116,8 +116,8 @@ message AgentJobList {
|
|||
message AgentJob {
|
||||
string job_id = 1;
|
||||
JobType job_type = 2;
|
||||
string equipment_id = 3;
|
||||
SnmpDevice device = 4;
|
||||
string device_id = 3;
|
||||
SnmpDevice snmp_device = 4;
|
||||
repeated SnmpQuery queries = 5;
|
||||
}
|
||||
|
||||
|
|
@ -134,7 +134,7 @@ message SnmpQuery {
|
|||
}
|
||||
|
||||
message SnmpResult {
|
||||
string equipment_id = 1;
|
||||
string device_id = 1;
|
||||
JobType job_type = 2;
|
||||
map<string, string> oid_values = 3;
|
||||
int64 timestamp = 4;
|
||||
|
|
@ -148,7 +148,7 @@ message AgentHeartbeat {
|
|||
}
|
||||
|
||||
message AgentError {
|
||||
string equipment_id = 1;
|
||||
string device_id = 1;
|
||||
string error_message = 2;
|
||||
int64 timestamp = 3;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -241,14 +241,14 @@ impl AgentClient {
|
|||
let text = serde_json::to_string(&msg)?;
|
||||
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(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Execute an SNMP job and collect results.
|
||||
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 snmp_client = SnmpClient::new();
|
||||
|
||||
|
|
@ -261,10 +261,10 @@ async fn execute_job(job: AgentJob, result_tx: mpsc::UnboundedSender<SnmpResult>
|
|||
for oid in &query.oids {
|
||||
match snmp_client
|
||||
.get(
|
||||
&device.ip,
|
||||
&device.community,
|
||||
&device.version,
|
||||
device.port as u16,
|
||||
&snmp_device.ip,
|
||||
&snmp_device.community,
|
||||
&snmp_device.version,
|
||||
snmp_device.port as u16,
|
||||
oid,
|
||||
)
|
||||
.await
|
||||
|
|
@ -283,10 +283,10 @@ async fn execute_job(job: AgentJob, result_tx: mpsc::UnboundedSender<SnmpResult>
|
|||
for base_oid in &query.oids {
|
||||
match snmp_client
|
||||
.walk(
|
||||
&device.ip,
|
||||
&device.community,
|
||||
&device.version,
|
||||
device.port as u16,
|
||||
&snmp_device.ip,
|
||||
&snmp_device.community,
|
||||
&snmp_device.version,
|
||||
snmp_device.port as u16,
|
||||
base_oid,
|
||||
)
|
||||
.await
|
||||
|
|
@ -307,7 +307,7 @@ async fn execute_job(job: AgentJob, result_tx: mpsc::UnboundedSender<SnmpResult>
|
|||
|
||||
// Build result
|
||||
let result = SnmpResult {
|
||||
equipment_id: job.equipment_id,
|
||||
device_id: job.device_id,
|
||||
job_type: job.job_type,
|
||||
oid_values,
|
||||
timestamp: std::time::SystemTime::now()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue