SNMPD.EXAMPLES(5) Net-SNMP SNMPD.EXAMPLES(5) (NAME) snmpd.examples - Net-SNMP (DESCRIPTION) snmpd.conf(5) Net-SNMP . . (AGENT BEHAVIOUR) (Listening addresses) ( SNMP UDP ) : agentaddress udp:161 : agentaddress 161 loopback ( SNMP UDP) : agentaddress localhost:161 # (udp implicit) : agentaddress 127.0.0.1 # (udp and standard port implicit) UDP TCP ( IPv4 IPv6) : agentaddress udp:161,tcp:161,udp6:161,tcp6:161 . (Run-time privileges) () . "snmp" ( /etc/group) : agentuser nobody agentgroup snmp UID / GID : agentuser #10 agentgroup #10 SNMPv3 (SNMPv3 Configuration) (engine ID) MAC (eth1) : engineIDType 3 engineIDNic eth1 () IP : engineIDType 1 : engineID "XXX - WHAT FORMAT" (ACCESS CONTROL) SNMPv3 (SNMPv3 Users) : createUser me MD5 "single pass phrase" createUser myself MD5 "single pass phrase" DES createUser andI MD5 "single pass phrase" DES "single pass phrase" . . : createUser onering SHA "to rule them all" AES "to bind them" createUser /var/net-snmp/snmpd.conf . (Traditional Access Control) SNMPv3 MIB : rouser me rwuser onering : rouser myself .1.3.6.1.2 rwuser andI system : rouser onering rwuser onering . onering - ( rwuser ). (community) . : rocommunity public rwcommunity private SNMPv1 SNMPv2c . . : private ! : rocommunity public default system : rwcommunity private 10.10.10.0/24 . VACM (VACM Configuration) VACM : # sec.name source community com2sec public default public com2sec mynet 10.10.10.0/24 private com2sec6 mynet fec0::/64 private # sec.model sec.name group worldGroup v1 public group worldGroup v2c public group myGroup v1 mynet group myGroup v2c mynet # incl/excl subtree [mask] view all included .1 view sysView included system # context model level prefix read write notify (unused) access worldGroup "" any noauth exact system none none access myGroup "" any noauth exact all all none : group SNMPv1 SNMPv2c . com2sec . ("public") ("mynet"/"private") - group . view OID . " " . ( ) . VACM . . (Typed-View Configuration) : view sys2View included system view sys2View included .1.3.6.1.2.1.25.1 authcommunity read public default -v sys2View authcommunity read,write private 10.10.10.0/8 ( ) rocommunity . "-" . (SYSTEM INFORMATION) (System Group) 'system' ( sysUpTime) : # 'uname -a' OID - - sysDescr Universal Turing Machine mk I sysObjectID .1.3.6.1.4.1.8072.3.2.1066 # 'configure' - - sysContact Alan.Turing@pre-cs.man.ac.uk sysName tortoise.turing.com sysLocation An idea in the mind of AT # (end-host) sysServices 72 (Host Resources Group) hrDiskStorageTable ( hrDeviceTable) : ignoredisk /dev/rdsk/c0t2d0 /dev/rdsk/c0t2d0 ignoredisk /dev/rdsk/c0t[!6]d0 ignoredisk /dev/rdsk/c0t[0-57-9a-f]d0 /dev/rdsk/c0tXd0 ( .../c0t6d0) ignoredisk /dev/rdsk/c1* /dev/rdsk/c1 ignoredisk /dev/rdsk/c?t0d0 /dev/rdsk/cXt0d0 ( 'X' ) . (Process Monitoring) ( ) : # proc httpd procfix httpd /etc/rc.d/init.d/httpd restart # # ( ) proc sendmail 10 procfix sendmail /etc/rc.d/init.d/sendmail stop # # (" ") proc snmpd 1 1 " DisMan" . (Disk Usage Monitoring) : includeAllDisks 10% disk /var 20% disk /usr 3% # crash dump disk /mnt/crash 100000 (System Load Monitoring) : load 10 ( ) : load 30 10 5 (Log File Monitoring) TODO file FILE [MAXSIZE] logmatch NAME PATH CYCLETIME REGEX (ACTIVE MONITORING) (Notification Handling) : authtrapenable 1 trapcommunity public trap2sink localhost ( ) : informsink localhost public : trapsink localhost trap2sink localhost informsink localhost (trap) . TODO - discuss SNMPv3 traps trapsess snmpv3 options localhost:162 TODO - mention trapd access configuration DisMan (DisMan Event MIB) : # createUser _internal MD5 "the first sign of madness" iquerySecName _internal rouser _internal # defaultMonitors yes linkUpDownNotifications yes # ! trap2sink localhost . DisMan - . : monitor -u me -o hrSWRunName "high process memory" hrSWRunPerfMem > 10000 . DisMan mteTriggerFired varbind hrSWRunName ( ) . (me ) . : monitor -D -r 10 "network traffic" ifInOctets 1000000 5000000 () mteTriggerRising mteTriggerFalling . (-D) . : monitor -r 10 "network traffic" ifInOctets - - 1000000 5000000 linkUpDownNotifications : notificationEvent linkUpTrap linkUp ifIndex ifAdminStatus ifOperStatus notificationEvent linkDownTrap linkDown ifIndex ifAdminStatus ifOperStatus monitor -r 60 -e linkUpTrap "Generate linkUp" ifOperStatus != 2 monitor -r 60 -e linkDownTrap "Generate linkDown" ifOperStatus == 2 ( notificationEvent) ( DisMan). defaultMonitors () : monitor -o prNames -o prErrMessage "procTable" prErrorFlag != 0 monitor -o memErrorName -o memSwapErrorMsg "memory" memSwapError != 0 monitor -o extNames -o extOutput "extTable" extResult != 0 monitor -o dskPath -o dskErrorMsg "dskTable" dskErrorFlag != 0 monitor -o laNames -o laErrMessage "laTable" laErrorFlag != 0 monitor -o fileName -o fileErrorMsg "fileTable" fileErrorFlag != 0 . "" (fix) : setEvent prFixIt prErrFix = 1 monitor -e prFixIt "procTable" prErrorFlag != 0 ( defaultMonitor). DisMan (DisMan Schedule MIB) : repeat 3600 versionUpdateConfig.0 = 1 ( ): cron 10 0 * * * versionUpdateConfig.0 = 1 SNMP : at 13 13 13 * 5 snmpVirus.0 = 1 (EXTENDING AGENT FUNCTIONALITY) (Arbitrary Extension Commands) exec [MIBOID] NAME PROG ARGS" sh [MIBOID] NAME PROG ARGS" execfix NAME PROG ARGS" extend [MIBOID] NAME PROG ARGS" extendfix [MIBOID] NAME PROG ARGS" MIB (MIB-Specific Extension Commands) (One-Shot) "pass [-p priority] MIBOID PROG" (Persistent) "pass_persist [-p priority] MIBOID PROG" (Embedded Perl Support) : disablePerl false perlInitFile /usr/share/snmp/snmp_perl.pl perl . ( ) MIB : perl use Data::Dumper; perl sub myroutine { print "got called: ",Dumper(@_),"\n"; } perl $agent->register('mylink', '.1.3.6.1.8765', \&myroutine); $agent snmp_perl.pl . MIB : XXX - WHAT ??? : perl 'do /usr/share/snmp/perl_example.pl'; (Dynamically Loadable Modules) TODO dlmod NAME PATH" (Proxy Support) SNMP ( ) : com2sec -Cn rem1context rem1user default remotehost1 com2sec -Cn rem2context rem2user default remotehost2 proxy -Cn rem1context -v 1 -c public remotehost1 .1.3 proxy -Cn rem2context -v 1 -c public remotehost2 .1.3 ( ). proxy () SNMPv3 (context) . remotehost1 remotehost2 - . . proxy OID ( ) : proxy -v 1 -c public localhost:6161 .1.3.6.1.4.1.99 SNMP . MIB ( ): # uses SNMPv3 to access the MIB tree .1.3.6.1.2.1.1 on 'remotehost' # and maps this to the local tree .1.3.6.1.3.10 proxy -v 3 -l noAuthNoPriv -u user remotehost .1.3.6.1.3.10 .1.3.6.1.2.1.1 SMUX (SMUX Sub-Agents) smuxsocket 127.0.0.1 smuxpeer .1.3.6.1.2.1.14 ospf_pass AgentX (AgentX Sub-Agents) Net-SNMP AgentX ( ) : master agentx agentXSocket /tmp/agentx/master agentXPerms 0660 0550 nobody snmp agentXSocket : netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_X_SOCKET, "/tmp/agentx/master"); AgentX loopback : agentXSocket tcp:localhost:705 agentXTimeout 5 agentXRetries 2 (master) : agentXSocket tcp:localhost:705 agentXTimeout 10 agentXRetries 1 agentXPingInterval 600 . (timeout) (retry) ( = ) . (OTHER CONFIGURATION) override sysDescr.0 octet_str "my own sysDescr" injectHandler stash_cache NAME table_iterator (FILES) /etc/snmp/snmpd.conf (SEE ALSO) snmpconf(1), snmpd.conf(5), snmp.conf(5), snmp_config(5), snmpd(8), EXAMPLE.conf, netsnmp_config_api(3). V5.9.5.2 13 Oct 2006 SNMPD.EXAMPLES(5)