![]() ![]() |
hotsanic |
Subversion Repositories: |
Compare with Previous - Blame - Download
;; SNMP in HotSaNIC;With the 0.5 release of HotSaNIC the new SNMP enhancement was introduced.I will try to assamble all usefull information about the snmp part in thisdocument to give the user an overview whats happening and help developersto make their own SNMP enhanced modules.--------Overview--------All mdoules gathering data through SNMP use the lib/HotSaNICsnmp.pm moduleto communicate with the SNMP server and collect the needed information.The module tries to guess the version of SNMP to use and the "kind" ofinterface (perl module Net::SNMP or system commands). After the firstcall by anyone module the guessed version is stored in a file to beread for later calls. Located in $HotSaNIC/modules and named $host.info.This is important to know, because if the server is down for somereason the content might be wrong, to be sure just do the following:1. Stop HotSaNIC2. Delete the file(s) storing version information3. Start HotSaNICProbing for each host is done again by the first module doing someSNMP query.Supported protocol versions are: SNMPv1 and SNMPv2cProbing is done by sending a get_bulk_request to the agent. If thisrequest fails it is assumed that the agent runs protocol version 1 and thiswill be used for all further queries to the same address.-------------------------------------------------Modules with SNMP support with sample config line-------------------------------------------------apps:APP=SNMP:192.168.1.1:public:sshd,sshd@gatewaypart:DRIVE=SNMP:192.168.1.1:public:/dev/hda1,root-fs@gatewaysystem:HOST=SNMP:192.168.1.1:public,Gatewaytraffic:DEV="SNMP:192.168.1.1:public:eth0,12500000,12500000,100MBit Ethernet"-------------------------Sample run in the logfile-------------------------To give you a clue about a correct run of SNMP query here isa log examples. To get all information you have to set theDEBUGLEVEL option in the main settings file to 5.The APPS module without preprobed version:<log on>starting module: "apps"Operating system "linux" not supported!Falling back to "default".running on PID 145651053344545: main loop running1053344545: signaling 145650.181(apps) 1053344545 APPS: enter snmp_walk()1053344545 APPS: probe_version() module1053344545 APPS: set_version() [2c]1053344545 APPS: snmp_mod_walk() [HASH(0x82c4d6c)]1053344545 APPS: leave snmp_walk()<log off>After normal startup the first query to the snmp daemon is done bycalling snmp_walk which logs entry and exit point enclosing thewhole process. After entering snmp_walk the set_version() functionis called which needs to call probe_version(), the occurence ofthe logentries is a bit confusing because all function log at theend before returning. But well the set_version line shows us thatthe probed version is '2c' which is correct in this case andthe snmp_mod_walk() function is called because of the presence ofNet::SNMP it handles the request and returns a hash of results.If the module is not availible to the function it would have handedout the control to snmp_sys_walk(), which does the query by callingapropiate system commands.--------------------------snmp_walk() and snmp_get()--------------------------These two functions are the core of the HotSaNICsnmp.pm fromthe modules point of view. Their synopsis is:$res = snmp_walk($host, $community, @oids)$res = snmp_get($host, community, @oids)$res is in both cases a reference to a hash which contains the result inthe form $res{$oid} = $value and the array argument @oids always containsa list of oids to query either with the (bulk)walk or the get mehtod.I hope I documented the HotSaNICsnmp.pm good enough to make clearwhats going on, so if you want more details on the functions youmight want to look in there.