SNMP agent configuration windows/linux -


i need retrieve information via snmp , use information create sort of graphic application in unity.

i find snmpsharp library http://www.snmpsharpnet.com/

i create little program in unity using library , installed snmp on windows machine(using windows official guide) , on localhost works!

now problem how can connect other agent on lan network ? how can install agent on other device example linux pc ? i'm little confused beacuse try install snmp on other windows pc can't retrieve snmp information ; try install snmp agent on linux pc don't understand how correctly install agent have communicate across lan

this code work on localhost

using unityengine; using unityengine.ui; using system.collections; using snmpsharpnet; using system.net;   public class snmp_walk : monobehaviour {  [serializefield] public inputfield community_str; [serializefield] public inputfield agent_ip_address; [serializefield] public button mybutton ; string str_community  = null; string ip  = null; void start () {     //test button      mybutton.onclick.addlistener (() => {         str_community = community_str.text;          ip = agent_ip_address.text;         debug.log (str_community);         debug.log(ip);         snmp_walk (str_community, ip);     }); }  // update called once per frame void update () {  }  void snmp_walk(string str_community, string ip){      octetstring community = new octetstring (str_community);     // define agent parameters class     agentparameters param = new agentparameters (community);     // set snmp version 1 (or 2)     // settare in base alla versione usata     param.version = snmpversion.ver1;     // construct agent address object     // ipaddress class easy use here because     //  try resolve constructor parameter if doesn't *     //  parse ip address     ipaddress agent = new ipaddress (ip);      // construct target     // ip, port,timeout,retry     udptarget target = new udptarget ((ipaddress)agent, 161, 4000, 2);     //necessario per tutte le richieste     pdu pdu = new pdu (pdutype.get);      pdu.vblist.add ("1.3.6.1.2.1.1.1.0"); //sysdescr     pdu.vblist.add("1.3.6.1.2.1.1.2.0"); //sysobjectid     pdu.vblist.add("1.3.6.1.2.1.1.3.0"); //sysuptime     pdu.vblist.add("1.3.6.1.2.1.1.4.0"); //syscontact     pdu.vblist.add("1.3.6.1.2.1.1.5.0"); //sysname     pdu.vblist.add ("1.3.6.1.2.1.25.2.2.0"); //load 1 core     //pdu.vblist.add ("1.3.6.1.2.1.25.6.3.1.1.11"); //memory ? occupata     //pdu.vblist.add ("1.3.6.1.2.1.25.3.3.1.2.4"); //cpu ?      snmpv1packet result = (snmpv1packet)target.request (pdu, param);       // if result null agent didn't reply or couldn't parse reply.     if (result != null) {         // errorstatus other 0 error returned          // agent - see snmpconstants error definitions         if (result.pdu.errorstatus != 0) {             // agent reported error request             debug.log ("error in snmp reply. error {"+result.pdu.errorstatus+"} " +                        "index {"+result.pdu.errorindex+"}");          } else {             // reply variables returned in same order added             //  vblist             debug.log ("sysdescr({"+result.pdu.vblist [0].oid.tostring ()+"}) " +                 "({"+snmpconstants.gettypename (result.pdu.vblist [0].value.type)+"}): " +                 "{"+result.pdu.vblist [0].value.tostring ()+"}");                debug.log("sysobjectid({"+result.pdu.vblist [1].oid.tostring ()+"}) " +                       "({"+snmpconstants.gettypename (result.pdu.vblist [1].value.type)+"}): " +                       "{"+result.pdu.vblist [1].value.tostring ()+"}");               debug.log("sysuptime(({"+result.pdu.vblist [2].oid.tostring ()+"}) " +                       "({"+snmpconstants.gettypename (result.pdu.vblist [2].value.type)+"}): " +                       "{"+result.pdu.vblist [2].value.tostring ()+"}");               debug.log("syscontact(({"+result.pdu.vblist [3].oid.tostring ()+"}) " +                       "({"+snmpconstants.gettypename (result.pdu.vblist [3].value.type)+"}): " +                       "{"+result.pdu.vblist [3].value.tostring ()+"}");               debug.log("sysname(({"+result.pdu.vblist [4].oid.tostring ()+"}) " +                       "({"+snmpconstants.gettypename (result.pdu.vblist [4].value.type)+"}): " +                       "{"+result.pdu.vblist [4].value.tostring ()+"}");               debug.log("total mem ({"+result.pdu.vblist [5].oid.tostring ()+"}) " +                       "({"+snmpconstants.gettypename (result.pdu.vblist [5].value.type)+"}): " +                       "{"+result.pdu.vblist [5].value.tostring ()+"}");           /*  debug.log("cpu ? " + result.pdu.vblist[6].oid.tostring()+                       snmpconstants.gettypename(result.pdu.vblist[6].value.type)+                       result.pdu.vblist[6].value.tostring());*/          }     } else {         debug.log ("no response received snmp agent.");     }     target.close (); } 

}

thanks , sorry english !

by default, once installed, snmp agent on windows allows queries localhost.

to allow remote snmp queries, need setup snmp service :

  • open windows services manager

  • right click on snmp service , edit properties

  • select security tab

enter image description here

from here, add remote host(s) allowed query snmp agent.


edit:

i aware answer part of question : cannot query windows snmp agent hosts other localhost.

how install/configure snmp agent on linux full other question, describing have tried , not working.

c# code review/debug shoud posted on sf sister site : stackoverflow


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -