1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| extern crate snmp;
fn main() {
println!("Hello, world!");
use std::time::Duration;
use snmp::{SyncSession, Value};
let sys_descr_oid = &[1,3,6,1,2,1,1,2,0,];
let agent_addr = "192.168.0.19:161";
let community = b"public";
let timeout = Duration::from_secs(2);
let mut sess = SyncSession::new(agent_addr, community, Some(timeout), 0).unwrap();
let mut response = sess.getnext(sys_descr_oid).unwrap();
if let Some((_oid, Value::OctetString(sys_descr))) = response.varbinds.next() {
println!("myrouter sysDescr: {}", String::from_utf8_lossy(sys_descr));
}
} |
Partager