jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [trunk/] [Documentation/] [README.snmp] - Rev 24 Go to most recent revision

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 this 
document to give the user an overview whats happening and help developers 
to make their own SNMP enhanced modules. 

--------
Overview
--------

All mdoules gathering data through SNMP use the lib/HotSaNICsnmp.pm module 
to communicate with the SNMP server and collect the needed information. 
The module tries to guess the version of SNMP to use and the "kind" of 
interface (perl module Net::SNMP or system commands). After the first 
call by anyone module the guessed version is stored in a file to be 
read for later calls. Located in $HotSaNIC/modules and named $host.info.
This is important to know, because if the server is down for some 
reason the content might be wrong, to be sure just do the following:

1. Stop HotSaNIC
2. Delete the file(s) storing version information
3. Start HotSaNIC

Probing for each host is done again by the first module doing some 
SNMP query.

Supported protocol versions are: SNMPv1 and SNMPv2c

Probing is done by sending a get_bulk_request to the agent. If this 
request fails it is assumed that the agent runs protocol version 1 and this 
will 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@gateway

part:
DRIVE=SNMP:192.168.1.1:public:/dev/hda1,root-fs@gateway

system:
HOST=SNMP:192.168.1.1:public,Gateway

traffic:
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 is 
a log examples. To get all information you have to set the 
DEBUGLEVEL 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 14565

1053344545: main loop running
1053344545: signaling 14565 
0.181(apps) 1053344545 APPS: enter snmp_walk()

1053344545 APPS: probe_version() module
1053344545 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 by 
calling snmp_walk which logs entry and exit point enclosing the 
whole process. After entering snmp_walk the set_version() function 
is called which needs to call probe_version(), the occurence of 
the logentries is a bit confusing because all function log at the 
end before returning. But well the set_version line shows us that 
the probed version is '2c' which is correct in this case and 
the snmp_mod_walk() function is called because of the presence of 
Net::SNMP it handles the request  and returns a hash of results. 
If the module is not availible to the function it would have handed 
out the control to snmp_sys_walk(), which does the query by calling 
apropiate system commands. 

--------------------------
snmp_walk() and snmp_get()
--------------------------

These two functions are the core of the HotSaNICsnmp.pm from 
the 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 in
the form $res{$oid} = $value and the array argument @oids always contains 
a 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 clear 
whats going on, so if you want more details on the functions you 
might want to look in there.


Powered by WebSVN 2.2.1