NET-SNMP setting and utilization
1. How to build the basic application of net-snmp? (written on Sep.2 2008)
1、 Download net-snmp- 5.3.2 .tar.gz.
2、 Depress the file:tar –xvf net-snmp- 5.3.2 .tar.gz
3、 Enter the directory
4、 Execute: ./configure --prefix=/usr/local/net-snmp --enable-mfd-rewrites --with-default-snmp-version="2" --with-sys-contact="自己的联系信息" --with-sys-location=" China " --with-logfile="/var/log/snmpd.log" --with-persistent-directory="/var/net-snmp"
5、 Execute: make
6、 Execute: make install
7、 Copy the Example.conf file: cp Example.conf /usr/local./net-snmp/share/snmp/snmpd.conf
8、 Modify the sec.name and community from snmpd.conf: sec.name is local or mynetwork, and source is the visiting host. Community use public.
9、 Set the environment variables and self boot. This is different with the shell and system.
10、 Execute the snmpd and snmptrapd which are in the directory named /usr/local/net-snmp/sbin. On the same level, there is a directory named bin which contains some useful get or write commands.
Detailed command is: snmpd –f –L
Snmpd:
Usage: ./snmpd [OPTIONS] [LISTENING ADDRESSES]
Version: 5.3.2 Web: http://www.net-snmp.org/ Email: net-snmp-coders@lists.sourceforge.net
-a log addresses -A append to the logfile rather than truncating it -c FILE[,...] read FILE(s) as configuration file(s) -C do not read the default configuration files -d dump sent and received SNMP packets -D TOKEN[,...] turn on debugging output for the given TOKEN(s) (try ALL for extremely verbose output) -f do not fork from the shell -g GID change to this numeric gid after opening transport endpoints -h, --help display this usage message -H display configuration file directives understood -I [-]INITLIST list of mib modules to initialize (or not) (run snmpd with -Dmib_init for a list) -L <LOGOPTS> toggle options controlling where to log to e: log to standard error o: log to standard output n: don't log at all f file: log to the specified file s facility: log to syslog (via the specified facility)
(variants) [EON] pri: log to standard error, output or /dev/null for level 'pri' and above [EON] p1-p2: log to standard error, output or /dev/null for levels 'p1' to 'p2' [FS] pri token: log to file/syslog for level 'pri' and above [FS] p1-p2 token: log to file/syslog for levels 'p1' to 'p2' -m MIBLIST use MIBLIST instead of the default MIB list -M DIRLIST use DIRLIST as the list of locations to look for MIBs -p FILE store process id in FILE -q print information in a more parsable format -r do not exit if files only accessible to root cannot be opened -u UID change to this uid (numeric or textual) after opening transport endpoints -v, --version display version information -V verbose display -x ADDRESS use ADDRESS as AgentX address -X run as an AgentX subagent rather than as an SNMP master agent
Deprecated options: -l FILE use -Lf <FILE> instead -P use -p instead -s use -Lsd instead -S d|i|0-7 use -Ls <facility> instead |
Snmptrapd
Usage: snmptrapd [OPTIONS] [LISTENING ADDRESSES]
NET-SNMP Version: 5.3.2 Web: http://www.net-snmp.org/ Email: net-snmp-coders@lists.sourceforge.net
-a ignore authentication failure traps -A append to log file rather than truncating it -c FILE read FILE as a configuration file -C do not read the default configuration files -d dump sent and received SNMP packets -D turn on debugging output -e print event # (rising/falling alarm, etc.) -f do not fork from the shell -F FORMAT use specified format for logging to standard error -h, --help display this usage message -H display configuration file directives understood -m MIBLIST use MIBLIST instead of the default MIB list -M DIRLIST use DIRLIST as the list of locations to look for MIBs -n use numeric addresses instead of attempting hostname lookups (no DNS) -p FILE store process id in FILE -t Prevent traps from being logged to syslog -v, --version display version information -x ADDRESS use ADDRESS as AgentX address -O <OUTOPTS> toggle options controlling output display 0: print leading 0 for single-digit hex characters a: print all strings in ascii format b: do not break OID indexes down e: print enums numerically E: escape quotes in string indices f: print full OIDs on output n: print OIDs numerically q: quick print for easier parsing Q: quick print with equal-signs s: print only last symbolic element of OID S: print MIB module-id plus last element t: print timeticks unparsed as numeric integers T: print human-readable text along with hex strings u: print OIDs using UCD-style prefix suppression U: don't print units v: print values only (not OID = value) x: print all strings in hex format X: extended index format -L <LOGOPTS> toggle options controlling where to log to e: log to standard error o: log to standard output n: don't log at all f file: log to the specified file s facility: log to syslog (via the specified facility)
(variants) [EON] pri: log to standard error, output or /dev/null for level 'pri' and above [EON] p1-p2: log to standard error, output or /dev/null for levels 'p1' to 'p2' [FS] pri token: log to file/syslog for level 'pri' and above [FS] p1-p2 token: log to file/syslog for levels 'p1' to 'p2'
Deprecated options: -o FILE use -Lf <FILE> instead -P use -f -Le instead -s use -Lsd instead -S d|i|0-7 use -Ls <facility> instead -u FILE use -p <FILE> instead |
11、 You can use snmpwalk –v 2c –c public localhost if to check whether the snmp is on.
12、 Download MibBrowser such as adventnet mibbrowser or brainstorm mibbrowser to test the mib utilization. When we use this, we can search the mib file on the directory of net-snmp named mibs
ARM的netsnmp移植
CFLAGS="-isystem /xscale/ 3.4.1 /arm-linux/include"
CPPFLAGS="-isystem /xscale/ 3.4.1 /arm-linux/include"
./configure --target=arm-linux --host=arm --build=i686 --with-cc=arm-linux-gcc --with-ar=arm-linux-ar --with-endianness=little --disable-applications --disable-manuals --disable-scripts --prefix=/usr --exec-prefix=/usr --with-install-prefix=/home/wzhiqian/nfs