| 1 | 1 | simandl | ; |
| 2 | | | ; SNMP in HotSaNIC |
| 3 | | | ; |
| 4 | | | |
| 5 | | | With the 0.5 release of HotSaNIC the new SNMP enhancement was introduced. |
| 6 | | | I will try to assamble all usefull information about the snmp part in this |
| 7 | | | document to give the user an overview whats happening and help developers |
| 8 | | | to make their own SNMP enhanced modules. |
| 9 | | | |
| 10 | | | -------- |
| 11 | | | Overview |
| 12 | | | -------- |
| 13 | | | |
| 14 | | | All mdoules gathering data through SNMP use the lib/HotSaNICsnmp.pm module |
| 15 | | | to communicate with the SNMP server and collect the needed information. |
| 16 | | | The module tries to guess the version of SNMP to use and the "kind" of |
| 17 | | | interface (perl module Net::SNMP or system commands). After the first |
| 18 | | | call by anyone module the guessed version is stored in a file to be |
| 19 | | | read for later calls. Located in $HotSaNIC/modules and named $host.info. |
| 20 | | | This is important to know, because if the server is down for some |
| 21 | | | reason the content might be wrong, to be sure just do the following: |
| 22 | | | |
| 23 | | | 1. Stop HotSaNIC |
| 24 | | | 2. Delete the file(s) storing version information |
| 25 | | | 3. Start HotSaNIC |
| 26 | | | |
| 27 | | | Probing for each host is done again by the first module doing some |
| 28 | | | SNMP query. |
| 29 | | | |
| 30 | | | Supported protocol versions are: SNMPv1 and SNMPv2c |
| 31 | | | |
| 32 | | | Probing is done by sending a get_bulk_request to the agent. If this |
| 33 | | | request fails it is assumed that the agent runs protocol version 1 and this |
| 34 | | | will be used for all further queries to the same address. |
| 35 | | | |
| 36 | | | ------------------------------------------------- |
| 37 | | | Modules with SNMP support with sample config line |
| 38 | | | ------------------------------------------------- |
| 39 | | | |
| 40 | | | apps: |
| 41 | | | APP=SNMP:192.168.1.1:public:sshd,sshd@gateway |
| 42 | | | |
| 43 | | | part: |
| 44 | | | DRIVE=SNMP:192.168.1.1:public:/dev/hda1,root-fs@gateway |
| 45 | | | |
| 46 | | | system: |
| 47 | | | HOST=SNMP:192.168.1.1:public,Gateway |
| 48 | | | |
| 49 | | | traffic: |
| 50 | | | DEV="SNMP:192.168.1.1:public:eth0,12500000,12500000,100MBit Ethernet" |
| 51 | | | |
| 52 | | | ------------------------- |
| 53 | | | Sample run in the logfile |
| 54 | | | ------------------------- |
| 55 | | | |
| 56 | | | To give you a clue about a correct run of SNMP query here is |
| 57 | | | a log examples. To get all information you have to set the |
| 58 | | | DEBUGLEVEL option in the main settings file to 5. |
| 59 | | | |
| 60 | | | The APPS module without preprobed version: |
| 61 | | | |
| 62 | | | <log on> |
| 63 | | | starting module: "apps" |
| 64 | | | Operating system "linux" not supported! |
| 65 | | | Falling back to "default" |
| 66 | | | .running on PID 14565 |
| 67 | | | |
| 68 | | | 1053344545: main loop running |
| 69 | | | 1053344545: signaling 14565 |
| 70 | | | 0.181(apps) 1053344545 APPS: enter snmp_walk() |
| 71 | | | |
| 72 | | | 1053344545 APPS: probe_version() module |
| 73 | | | 1053344545 APPS: set_version() [2c] |
| 74 | | | 1053344545 APPS: snmp_mod_walk() [HASH(0x82c4d6c)] |
| 75 | | | 1053344545 APPS: leave snmp_walk() |
| 76 | | | <log off> |
| 77 | | | |
| 78 | | | After normal startup the first query to the snmp daemon is done by |
| 79 | | | calling snmp_walk which logs entry and exit point enclosing the |
| 80 | | | whole process. After entering snmp_walk the set_version() function |
| 81 | | | is called which needs to call probe_version(), the occurence of |
| 82 | | | the logentries is a bit confusing because all function log at the |
| 83 | | | end before returning. But well the set_version line shows us that |
| 84 | | | the probed version is '2c' which is correct in this case and |
| 85 | | | the snmp_mod_walk() function is called because of the presence of |
| 86 | | | Net::SNMP it handles the request and returns a hash of results. |
| 87 | | | If the module is not availible to the function it would have handed |
| 88 | | | out the control to snmp_sys_walk(), which does the query by calling |
| 89 | | | apropiate system commands. |
| 90 | | | |
| 91 | | | -------------------------- |
| 92 | | | snmp_walk() and snmp_get() |
| 93 | | | -------------------------- |
| 94 | | | |
| 95 | | | These two functions are the core of the HotSaNICsnmp.pm from |
| 96 | | | the modules point of view. Their synopsis is: |
| 97 | | | |
| 98 | | | $res = snmp_walk($host, $community, @oids) |
| 99 | | | $res = snmp_get($host, community, @oids) |
| 100 | | | |
| 101 | | | $res is in both cases a reference to a hash which contains the result in |
| 102 | | | the form $res{$oid} = $value and the array argument @oids always contains |
| 103 | | | a list of oids to query either with the (bulk)walk or the get mehtod. |
| 104 | | | |
| 105 | | | I hope I documented the HotSaNICsnmp.pm good enough to make clear |
| 106 | | | whats going on, so if you want more details on the functions you |
| 107 | | | might want to look in there. |
| 108 | | | |