Curs: | SeguretatXarxesInformàtiques, LinuxAdministracioAvancada, DissenyXarxesLinux |
Fitxers: | EinesMonitoritzacio.pdf (EinesMonitoritzacio.odp) |
Repositori SVN: | https://[email protected]/svn/iceupc/SeguretatXarxesInformàtiques |
Usuari: | anonymous |
Paraula de pas: | sense paraula de pas |
Autors: | Sergi Tur Badenas |
Simple Network Management Protocol (SNMP) és un protocol del nivell d'aplicació que facilita l'intercanvi d'informació d'administració entre dispositius de xarxa.
Característiques principals:
Els components bàsics d'una xarxa administrada amb SNMP són:
Els dispositius administrats tenen instal·lat un programari (agent) que s'encarreguen de recollir i emmagatzemar informació de la màquina administrada. La informació emmagatzemada es posa a disposició dels sistemes administradors de la xarxa mitjançant SNMP. Les màquines administrades poden ser encaminadors, servidors, commutadors, estacions de treball, impressores, perifèrics de xarxa o altres màquines connectades a la xarxa (màquines dispensadores d'aliments, alarmes, estacions meteorològiques, etc.)
Característiques d'un MIB:
Es tracta doncs d'una base de dades jeràrquica on cada node de l'arbre és un objecte. Hi ha dos tipus d'objectes:
Per exemple l'objecte l'objecte ifNumber s'identifica amb una de les següents notacions:
$ ls /usr/share/mibs/ iana ietf netsnmp
$ dpkg -L snmp-mibs-downloader | grep "/usr/share/mibs" /usr/share/mibs /usr/share/mibs/ietf /usr/share/mibs/iana
$ ls /var/lib/mibs/ iana ietf
També conegut com el OID :
.1.3.6.1.2.1
IMPORTANT: Cal tenir en compte que snmpwalk mostrà per defecte aquesta part de l'arbre MIB si no s'indica cap OID concret! Per mostrar tots els OID, cal indicar explícitament que es vol mostrar tot des de l'arrel utilitzant el OID de l'arrel (un punt . )
D'aquest OID pengen alguns dels valors més importants però no pas tots, cal tenir en compte sobretot tot els valors de enterprise que no estan en aquest subarbre.
Consulteu SNMP#MIBS.
Aquí es on qualsevol institució pot demanar un espai de OIDs reservats.
.1.3.6.1.4.1
Vegeu OIDs. Per exemple l'Institut de l'Ebre té un OID propi:
1.3.6.1.4.1.37589
Vegeu:
Això depèn d'on s'hagin definit els paths per als MIBS, es poden consultar amb:
$ snmpget -Dparse-mibs 2>&1 | grep directory parse-mibs: Scanning directory /home/sergi/.snmp/mibs parse-mibs: cannot open MIB directory /home/sergi/.snmp/mibs parse-mibs: Scanning directory /usr/share/mibs/site parse-mibs: cannot open MIB directory /usr/share/mibs/site parse-mibs: Scanning directory /usr/share/snmp/mibs parse-mibs: cannot open MIB directory /usr/share/snmp/mibs parse-mibs: Scanning directory /usr/share/mibs/iana parse-mibs: Scanning directory /usr/share/mibs/ietf parse-mibs: Scanning directory /usr/share/mibs/netsnmp
Del FAQ:
/usr/share/doc/libsnmp-base/FAQ Where should I put my MIB files? ------------------------------- If you've compiled the package from source (or are using binaries from the project website), then you should probably put new MIB files in the directory /usr/local/share/snmp/mibs If you are using vendor-supplied binaries, then the MIB files may well be located somewhere else (e.g. /usr/share/snmp/mibs, /opt/snmp/mibs, or /etc/sma/snmp/mibs). Have a look for where existing MIB files are installed, and try adding your MIBs to the same directory. If you compiled the source yourself, but specified a different --prefix value when running configure, then the location of the MIB directory will be {prefix}/share/snmp/mibs. If you're still not sure where to put your MIB files, try running the command snmpget -Dparse-mibs 2>&1 | grep directory This will display the location(s) where the library is looking for MIB files.
A les noves versions de Ubuntu i Debian els fitxers MIB no venen per defecte ja que molts tenen llicències que no són lliures (vegeu snmp-mibs-downloader).
Un cop uns baixeu els MIBS amb l'eina snmp-mibs-downloader els tindreu realment:
/var/lib/mibs
Tot i que sovint s'utilitza més la carpeta:
$ ls -la /usr/share/mibs total 20 drwxr-xr-x 3 root root 4096 2012-02-20 13:34 . drwxr-xr-x 399 root root 12288 2012-02-17 18:08 .. lrwxrwxrwx 1 root root 18 2010-06-07 16:47 iana -> /var/lib/mibs/iana lrwxrwxrwx 1 root root 18 2010-06-07 16:47 ietf -> /var/lib/mibs/ietf drwxr-xr-x 2 root root 4096 2011-10-12 16:28 netsnmp
Com podeu veure les carpetes /usr/share/mib/iana i /usr/share/mib/ietf són links a /usr/share/mibs.
Com a referència es mostren els fitxers MIB que es troben a les 3 carpetes:
$ cd /usr/share/mib/netsnmp/ $ ls GNOME-SMI NET-SNMP-AGENT-MIB NET-SNMP-EXTEND-MIB NET-SNMP-MONITOR-MIB NET-SNMP-SYSTEM-MIB NET-SNMP-VACM-MIB UCD-DISKIO-MIB UCD-IPFWACC-MIB LM-SENSORS-MIB NET-SNMP-EXAMPLES-MIB NET-SNMP-MIB NET-SNMP-PASS-MIB NET-SNMP-TC UCD-DEMO-MIB UCD-DLMOD-MIB UCD-SNMP-MIB
$ ls /var/lib/mibs/iana IANA-ADDRESS-FAMILY-NUMBERS-MIB IANA-GMPLS-TC-MIB IANA-ITU-ALARM-TC-MIB IANA-MAU-MIB IANA-RTPROTO-MIB IANA-CHARSET-MIB IANAifType-MIB IANA-LANGUAGE-MIB IANA-PRINTER-MIB IANATn3270eTC-MIB IANA-FINISHER-MIB IANA-IPPM-METRICS-REGISTRY-MIB IANA-MALLOC-MIB IANA-PWE3-MIB IPFIX-SELECTOR-MIB
$ ls /var/lib/mibs/ietf/ ACCOUNTING-CONTROL-MIB FDDI-SMT73-MIB MPLS-LDP-STD-MIB SMUX-MIB ADSL2-LINE-MIB FIBRE-CHANNEL-FE-MIB MPLS-LSR-STD-MIB SNA-NAU-MIB ADSL2-LINE-TC-MIB Finisher-MIB MPLS-TC-STD-MIB SNA-SDLC-MIB ADSL-LINE-EXT-MIB FLOW-METER-MIB MPLS-TE-STD-MIB SNMP-COMMUNITY-MIB ADSL-LINE-MIB FORCES-MIB MSDP-MIB SNMP-FRAMEWORK-MIB ADSL-TC-MIB FRAME-RELAY-DTE-MIB MTA-MIB SNMP-IEEE802-TM-MIB AGENTX-MIB FR-ATM-PVC-SERVICE-IWF-MIB NAT-MIB SNMP-MPD-MIB AGGREGATE-MIB FR-MFR-MIB NEMO-MIB SNMP-NOTIFICATION-MIB ALARM-MIB FRNETSERV-MIB NETWORK-SERVICES-MIB SNMP-PROXY-MIB APM-MIB FRSLD-MIB NHRP-MIB SNMP-REPEATER-MIB APPC-MIB GMPLS-LABEL-STD-MIB NOTIFICATION-LOG-MIB SNMP-SSH-TM-MIB APPLETALK-MIB GMPLS-LSR-STD-MIB OPT-IF-MIB SNMP-TARGET-MIB APPLICATION-MIB GMPLS-TC-STD-MIB OSPF-MIB SNMP-TSM-MIB APPN-DLUR-MIB GMPLS-TE-STD-MIB OSPF-TRAP-MIB SNMP-USER-BASED-SM-MIB APPN-MIB GSMP-MIB OSPFV3-MIB SNMP-USM-AES-MIB APPN-TRAP-MIB HC-ALARM-MIB PARALLEL-MIB SNMP-USM-DH-OBJECTS-MIB APS-MIB HCNUM-TC P-BRIDGE-MIB SNMPv2-CONF ARC-MIB HC-PerfHist-TC-MIB PerfHist-TC-MIB SNMPv2-M2M-MIB ATM2-MIB HC-RMON-MIB PIM-BSR-MIB SNMPv2-MIB ATM-ACCOUNTING-INFORMATION-MIB HDSL2-SHDSL-LINE-MIB PIM-MIB SNMPv2-PARTY-MIB ATM-MIB HOST-RESOURCES-MIB PIM-STD-MIB SNMPv2-PDU ATM-TC-MIB HOST-RESOURCES-TYPES PINT-MIB SNMPv2-SMI BGP4-MIB HPR-IP-MIB PKTC-IETF-EVENT-MIB SNMPv2-TC BRIDGE-MIB HPR-MIB PKTC-IETF-MTA-MIB SNMPv2-TM CAPWAP-BASE-MIB IBM-6611-APPN-MIB PKTC-IETF-SIG-MIB SNMPv2-USEC-MIB CAPWAP-DOT11-MIB IF-CAP-STACK-MIB POLICY-BASED-MANAGEMENT-MIB SNMP-VIEW-BASED-ACM-MIB CHARACTER-MIB IFCP-MGMT-MIB POWER-ETHERNET-MIB SONET-MIB CIRCUIT-IF-MIB IF-INVERTED-STACK-MIB PPP-BRIDGE-NCP-MIB SOURCE-ROUTING-MIB CLNS-MIB IF-MIB PPP-IP-NCP-MIB SSPM-MIB COPS-CLIENT-MIB IGMP-STD-MIB PPP-LCP-MIB SYSAPPL-MIB DECNET-PHIV-MIB INET-ADDRESS-MIB PPP-SEC-MIB SYSLOG-MSG-MIB DIAL-CONTROL-MIB INTEGRATED-SERVICES-GUARANTEED-MIB Printer-MIB SYSLOG-TC-MIB DIFFSERV-CONFIG-MIB INTEGRATED-SERVICES-MIB PTOPO-MIB T11-FC-FABRIC-ADDR-MGR-MIB DIFFSERV-DSCP-TC INTERFACETOPN-MIB PW-ATM-MIB T11-FC-FABRIC-CONFIG-SERVER-MIB DIFFSERV-MIB IPATM-IPMC-MIB PW-ENET-STD-MIB T11-FC-FABRIC-LOCK-MIB DIRECTORY-SERVER-MIB IPFIX-MIB PW-MPLS-STD-MIB T11-FC-FSPF-MIB DISMAN-EVENT-MIB IP-FORWARD-MIB PW-STD-MIB T11-FC-NAME-SERVER-MIB DISMAN-EXPRESSION-MIB IPMCAST-MIB PW-TC-STD-MIB T11-FC-ROUTE-MIB DISMAN-NSLOOKUP-MIB IP-MIB PW-TDM-MIB T11-FC-RSCN-MIB DISMAN-PING-MIB IPMROUTE-STD-MIB Q-BRIDGE-MIB T11-FC-SP-AUTHENTICATION-MIB DISMAN-SCHEDULE-MIB IPOA-MIB RADIUS-ACC-CLIENT-MIB T11-FC-SP-POLICY-MIB DISMAN-SCRIPT-MIB IPS-AUTH-MIB RADIUS-ACC-SERVER-MIB T11-FC-SP-SA-MIB DISMAN-TRACEROUTE-MIB IPSEC-SPD-MIB RADIUS-AUTH-CLIENT-MIB T11-FC-SP-TC-MIB DLSW-MIB IPV6-FLOW-LABEL-MIB RADIUS-AUTH-SERVER-MIB T11-FC-SP-ZONING-MIB DNS-RESOLVER-MIB IPV6-ICMP-MIB RADIUS-DYNAUTH-CLIENT-MIB T11-FC-VIRTUAL-FABRIC-MIB DNS-SERVER-MIB IPV6-MIB RADIUS-DYNAUTH-SERVER-MIB T11-FC-ZONE-SERVER-MIB DOCS-BPI-MIB IPV6-MLD-MIB RAQMON-MIB T11-TC-MIB DOCS-CABLE-DEVICE-MIB IPV6-TC RAQMON-RDS-MIB TCP-ESTATS-MIB DOCS-IETF-BPI2-MIB IPV6-TCP-MIB RDBMS-MIB TCPIPX-MIB DOCS-IETF-CABLE-DEVICE-NOTIFICATION-MIB IPV6-UDP-MIB RFC1155-SMI TCP-MIB DOCS-IETF-QOS-MIB ISCSI-MIB RFC1213-MIB TE-LINK-STD-MIB DOCS-IETF-SUBMGT-MIB ISDN-MIB RFC1381-MIB TE-MIB DOCS-IF-MIB ISIS-MIB RFC1382-MIB TIME-AGGREGATE-MIB DOT12-IF-MIB ISNS-MIB RFC1414-MIB TN3270E-MIB DOT12-RPTR-MIB ITU-ALARM-MIB RIPv2-MIB TN3270E-RT-MIB DOT3-EPON-MIB ITU-ALARM-TC-MIB RMON2-MIB TOKENRING-MIB DOT3-OAM-MIB Job-Monitoring-MIB RMON-MIB TOKEN-RING-RMON-MIB DPI20-MIB L2TP-MIB ROHC-MIB TOKENRING-STATION-SR-MIB DS0BUNDLE-MIB LANGTAG-TC-MIB ROHC-RTP-MIB TPM-MIB DS0-MIB LMP-MIB ROHC-UNCOMPRESSED-MIB TRANSPORT-ADDRESS-MIB DS1-MIB MALLOC-MIB RS-232-MIB TRIP-MIB DS3-MIB MAU-MIB RSERPOOL-MIB TRIP-TC-MIB DSA-MIB MGMD-STD-MIB RSTP-MIB TUNNEL-MIB DSMON-MIB MIDCOM-MIB RSVP-MIB UDPLITE-MIB DVB-RCS-MIB MIOX25-MIB RTP-MIB UDP-MIB EBN-MIB MIP-MIB SCSI-MIB UPS-MIB EFM-CU-MIB MOBILEIPV6-MIB SCTP-MIB URI-TC-MIB ENTITY-MIB Modem-MIB SFLOW-MIB VDSL2-LINE-MIB ENTITY-SENSOR-MIB MPLS-FTN-STD-MIB SIP-COMMON-MIB VDSL2-LINE-TC-MIB ENTITY-STATE-MIB MPLS-L3VPN-STD-MIB SIP-MIB VDSL-LINE-EXT-MCM-MIB ENTITY-STATE-TC-MIB MPLS-LC-ATM-STD-MIB SIP-SERVER-MIB VDSL-LINE-EXT-SCM-MIB ETHER-CHIPSET-MIB MPLS-LC-FR-STD-MIB SIP-TC-MIB VDSL-LINE-MIB EtherLike-MIB MPLS-LDP-ATM-STD-MIB SIP-UA-MIB VPN-TC-STD-MIB FCIP-MGMT-MIB MPLS-LDP-FRAME-RELAY-STD-MIB SLAPM-MIB VRRP-MIB FC-MGMT-MIB MPLS-LDP-GENERIC-STD-MIB SMON-MIB WWW-MIB
Aquí fem un resum dels MIBs més habituals:
Hi ha una sèrie de OIDs que són essencials i solen estar a tots els sistemes amb SNMP. Estem parlant del MIB SNMPv2-MIB (fitxer /var/lib/mibs/ietf/SNMPv2-MIB, The MIB module for SNMP entities part del RFC 3418).
Per exemple sempre podreu obtenir les següents dades (es mostra la descripció original en anglès segons el RFC, vegeu el fitxer /var/lib/mibs/ietf/SNMPv2-MIB):
NOTA: El nom complet dels OIDs és SNMPv2-MIB::nom curt, per exemple el de sysDescr és SNMPv2-MIB::sysDescr. Per obtenir el OID es pot utilitzar snmptranslate -On SNMPv2-MIB::sysDescr
Tot el grup sistema es troba a .1.3.6.1.2.1.1 és a dir a mibs-2 (.1.3.6.1.2.1 + .1)
També conté informació sobre les bases de dades MIBs que suporta el dispositiu: Subsistemes:
Un exemple d'un dispositiu Mikrotik:
$ snmpwalk -v 1 -c public 10.139.221.100 . | grep SNMPv2-MIB SNMPv2-MIB::sysDescr.0 = STRING: Linux 2.6.15-5.2 #1 Fri Jan 14 14:43:07 EET 2011 mips SNMPv2-MIB::sysObjectID.0 = OID: FROGFOOT-RESOURCES-MIB::servers SNMPv2-MIB::sysContact.0 = STRING: [email protected] SNMPv2-MIB::sysName.0 = STRING: TortosaHospitalINSEbre SNMPv2-MIB::sysLocation.0 = STRING: TortosaHospìtalINSEbre SNMPv2-MIB::sysServices.0 = INTEGER: 79 SNMPv2-MIB::sysORLastChange.0 = Timeticks: (1226904800) 142 days, 0:04:08.00 SNMPv2-MIB::sysORIndex.1 = INTEGER: 1 SNMPv2-MIB::sysORIndex.2 = INTEGER: 2 SNMPv2-MIB::sysORIndex.3 = INTEGER: 3 SNMPv2-MIB::sysORIndex.4 = INTEGER: 4 SNMPv2-MIB::sysORIndex.5 = INTEGER: 5 SNMPv2-MIB::sysORID.1 = OID: SNMPv2-MIB::snmpMIB SNMPv2-MIB::sysORID.2 = OID: IEEE802dot11-MIB::ieee802dot11 SNMPv2-MIB::sysORID.3 = OID: IF-MIB::ifMIB SNMPv2-MIB::sysORID.4 = OID: MIKROTIK-EXPERIMENTAL-MIB::mikrotik SNMPv2-MIB::sysORID.5 = OID: FROGFOOT-RESOURCES-MIB::resMIB SNMPv2-MIB::sysORDescr.1 = STRING: The MIB module for SNMP entities SNMPv2-MIB::sysORDescr.2 = STRING: The MIB module for IEEE 802.11 entities. SNMPv2-MIB::sysORDescr.3 = STRING: The MIB module to describe generic objects for network interface sub-layers SNMPv2-MIB::sysORDescr.4 = STRING: The Mikrotik experimental wireless MIB module SNMPv2-MIB::sysORDescr.5 = STRING: The MIB module to describe system resources SNMPv2-MIB::sysORUpTime.1 = Timeticks: (1226904800) 142 days, 0:04:08.00 SNMPv2-MIB::sysORUpTime.2 = Timeticks: (1226904800) 142 days, 0:04:08.00 SNMPv2-MIB::sysORUpTime.3 = Timeticks: (1226904800) 142 days, 0:04:08.00 SNMPv2-MIB::sysORUpTime.4 = Timeticks: (1226904800) 142 days, 0:04:08.00 SNMPv2-MIB::sysORUpTime.5 = Timeticks: (1226904800) 142 days, 0:04:08.00 ...
El fet d'afegir un MIB permet referirse als objectes pel seu nom sense necessitat d'especificar tot el OID. També permet que els resultats de comandes com snmpwalk siguin més descriptives al mostrar noms i no pas números OID.
Hi ha dos formes d'instal·lar un MIB
$ sudo mkdir /usr/share/snmp/mibs/
NOTA: De fet els podeu posar en qualsevol de les carpetes que apareixen a la secció A on es troben els fitxers MIB
NOTA: A Ubuntu 11.10 la carpeta /usr/share/snmp/mibs/ no existeix i per això la creem !
Ara copiem el fitxer MIB que ens interessa (a l'exemple el FROGFOOT-RESOURCES-MIB que per exemple utilitzar Airos, consulteu Airos i SNMP )
$ sudo cp mibs/FROGFOOT-RESOURCES-MIB.txt /usr/share/snmp/mibs/
Després cal indicar a les eines client que tinguin en compte aquest MIB. Hi ha 4 opcions:
1) Definir una variable d'entorn
$ export MIBS=+MY-MIB
2) Definir per a l'usuari:
$ echo "mibs +MY-MIB" >> $HOME/.snmp/snmp.conf
O modificar el fitxer /etc/snmp/snmp.conf i afegir:
mibs +FROGFOOT-RESOURCES-MIB
4)S'indica en cada comanda:
$ snmpwalk -m +FROGFOOT-RESOURCES-MIB -v1 -c public 10.139.221.99 . | grep FROGFOOT SNMPv2-MIB::sysObjectID.0 = OID: FROGFOOT-RESOURCES-MIB::servers SNMPv2-MIB::sysORID.5 = OID: FROGFOOT-RESOURCES-MIB::resMIB FROGFOOT-RESOURCES-MIB::memTotal.0 = Gauge32: 30264 FROGFOOT-RESOURCES-MIB::memFree.0 = Gauge32: 5416 FROGFOOT-RESOURCES-MIB::memBuffer.0 = Gauge32: 3436 FROGFOOT-RESOURCES-MIB::memCache.0 = Gauge32: 0 FROGFOOT-RESOURCES-MIB::swapTotal.0 = Gauge32: 0 FROGFOOT-RESOURCES-MIB::swapFree.0 = Gauge32: 0 FROGFOOT-RESOURCES-MIB::loadNumber.0 = INTEGER: 3 FROGFOOT-RESOURCES-MIB::loadIndex.1 = INTEGER: 1 FROGFOOT-RESOURCES-MIB::loadIndex.2 = INTEGER: 2 FROGFOOT-RESOURCES-MIB::loadIndex.3 = INTEGER: 3 FROGFOOT-RESOURCES-MIB::loadDescr.1 = STRING: 1 Minute Average FROGFOOT-RESOURCES-MIB::loadDescr.2 = STRING: 5 Minute Average FROGFOOT-RESOURCES-MIB::loadDescr.3 = STRING: 15 Minute Average FROGFOOT-RESOURCES-MIB::loadValue.1 = Gauge32: 9 FROGFOOT-RESOURCES-MIB::loadValue.2 = Gauge32: 3 FROGFOOT-RESOURCES-MIB::loadValue.3 = Gauge32: 0
A l'exemple el FROGFOOT-RESOURCES-MIB és l'enterprise amb 10002, sense el MIB sortiria:
$ snmpwalk -v1 -c public 10.139.221.99 . | grep 10002 SNMPv2-MIB::sysObjectID.0 = OID: SNMPv2-SMI::enterprises.10002.1 SNMPv2-MIB::sysORID.5 = OID: SNMPv2-SMI::enterprises.10002.1.1.1.31 SNMPv2-SMI::enterprises.10002.1.1.1.1.1.0 = Gauge32: 30264 SNMPv2-SMI::enterprises.10002.1.1.1.1.2.0 = Gauge32: 5412 SNMPv2-SMI::enterprises.10002.1.1.1.1.3.0 = Gauge32: 3436 SNMPv2-SMI::enterprises.10002.1.1.1.1.4.0 = Gauge32: 0 SNMPv2-SMI::enterprises.10002.1.1.1.2.1.0 = Gauge32: 0 SNMPv2-SMI::enterprises.10002.1.1.1.2.2.0 = Gauge32: 0 SNMPv2-SMI::enterprises.10002.1.1.1.4.1.0 = INTEGER: 3 SNMPv2-SMI::enterprises.10002.1.1.1.4.2.1.1.1 = INTEGER: 1 SNMPv2-SMI::enterprises.10002.1.1.1.4.2.1.1.2 = INTEGER: 2 SNMPv2-SMI::enterprises.10002.1.1.1.4.2.1.1.3 = INTEGER: 3 SNMPv2-SMI::enterprises.10002.1.1.1.4.2.1.2.1 = STRING: "1 Minute Average" SNMPv2-SMI::enterprises.10002.1.1.1.4.2.1.2.2 = STRING: "5 Minute Average" SNMPv2-SMI::enterprises.10002.1.1.1.4.2.1.2.3 = STRING: "15 Minute Average" SNMPv2-SMI::enterprises.10002.1.1.1.4.2.1.3.1 = Gauge32: 0 SNMPv2-SMI::enterprises.10002.1.1.1.4.2.1.3.2 = Gauge32: 0 SNMPv2-SMI::enterprises.10002.1.1.1.4.2.1.3.3 = Gauge32: 0
O els OID:
$ snmpwalk -On -v1 -c public 10.139.221.99 . | grep 10002 .1.3.6.1.2.1.1.2.0 = OID: .1.3.6.1.4.1.10002.1 .1.3.6.1.2.1.1.9.1.2.5 = OID: .1.3.6.1.4.1.10002.1.1.1.31 .1.3.6.1.4.1.10002.1.1.1.1.1.0 = Gauge32: 30264 .1.3.6.1.4.1.10002.1.1.1.1.2.0 = Gauge32: 5412 ...
Del FAQ que podeu trobar a:
$ sudo gunzip /usr/share/doc/libsnmp-base/FAQ.gz $ joe /usr/share/doc/libsnmp-base/FAQ
How do I add a MIB to the tools? ------------------------------- Adding a MIB to the client-side tools has two main effects: - it allows you to refer to MIB objects by name (rather than having to use the numeric OIDs) - it allows the results to be displayed in a more immediately meaningful fashion. Not just giving the object names, but also showing named enumeration values, and interpreting table indexes properly (particularly for string and OID index values). There are two steps required to add a new MIB file to the tools. Firstly, copy the MIB file into the appropriate location: cp MY-MIB.txt /usr/share/snmp/mibs (which makes it available to everyone on the system) or mkdir $HOME/.snmp mkdir $HOME/.snmp/mibs cp MY-MIB.txt $HOME/.snmp/mibs (which makes it available to you only) Note that the location of the shared MIB directory may be different from that given here - see the FAQ entry "Where should I put my MIB files?" for more information. Secondly, tell the tools to load this MIB: snmpwalk -m +MY-MIB ..... (load it for this command only) or export MIBS=+MY-MIB (load it for this session only) or echo "mibs +MY-MIB" >> $HOME/.snmp/snmp.conf (load it every time) Note that the value for this variable is the name of the MIB module, *not* the name of the MIB file. These are typically the same (apart from the .txt suffix), but if in doubt, check the contents of the file. The value to use is the token immediately before the word DEFINITIONS at the start of the file. Or use the special value "all" to have the tools load all available MIBs (which may slow them down, particularly if you have a large number of MIB files. Note that you need *both* steps. Adding a MIB in this way does *not* mean that the agent will automatically return values from this MIB. The agent needs to be explicitly extended to support the new MIB objects, which typically involves writing new code. See the AGENT section for details. Most of the tools (apart from 'snmptable') will work quite happily without any MIB files at all - although the results won't be displayed in quite the same way. Similarly, the agent doesn't need MIB files either (other than to handle MIB object names in the configuration file).
http://oreilly.com/catalog/esnmp/chapter/ch02.html
IF-MIB::ifIndex.1 = INTEGER: 1
IF-MIB::ifDescr.1 = STRING: ether10
A 32-bit number with minimum value 0 and maximum value 232 - 1 (4,294,967,295). Unlike a Counter, a Gauge can increase and decrease at will, but it can never exceed its maximum value. The interface speed on a router is measured with a Gauge.
IF-MIB::ifSpeed.1 = Gauge32: 10000000
IF-MIB::ifLastChange.1 = Timeticks: (0) 0:00:00.00
Són conmptadors de 32 bits.
IF-MIB::ifInOctets.1 = Counter32: 0
TODO:
INTEGER
A 32-bit number often used to specify enumerated types within the context of a single managed object. For example, the operational status of a router interface can be up, down, or testing. With enumerated types, 1 would represent up, 2 down, and 3 testing. The value zero (0) must not be used as an enumerated type, according to RFC 1155.
OCTET STRING
A string of zero or more octets (more commonly known as bytes) generally used to represent text strings, but also sometimes used to represent physical addresses.
Counter
A 32-bit number with minimum value 0 and maximum value 232 - 1 (4,294,967,295). When the maximum value is reached, it wraps back to zero and starts over. It's primarily used to track information such as the number of octets sent and received on an interface or the number of errors and discards seen on an interface. A Counter is monotonically increasing, in that its values should never decrease during normal operation. When an agent is rebooted, all Counter values should be set to zero. Deltas are used to determine if anything useful can be said for successive queries of Counter values. A delta is computed by querying a Counter at least twice in a row, and taking the difference between the query results over some time interval.
OBJECT IDENTIFIER
A dotted-decimal string that represents a managed object within the object tree. For example, 1.3.6.1.4.1.9 represents Cisco Systems's private enterprise OID.
NULL
Not currently used in SNMP.
SEQUENCE
Defines lists that contain zero or more other ASN.1 datatypes.
SEQUENCE OF
Defines a managed object that is made up of a SEQUENCE of ASN.1 types.
IpAddress
Represents a 32-bit IPv4 address. Neither SMIv1 nor SMIv2 discusses 128-bit IPv6 addresses; this problem will be addressed by the IETF's SMI Next Generation (SMING) working group (see http://www.ietf.org/html.charters/sming-charter.html).
NetworkAddress
Same as the IpAddress type, but can represent different network address types.
Gauge
A 32-bit number with minimum value 0 and maximum value 232 - 1 (4,294,967,295). Unlike a Counter, a Gauge can increase and decrease at will, but it can never exceed its maximum value. The interface speed on a router is measured with a Gauge.
TimeTicks
A 32-bit number with minimum value 0 and maximum value 232 - 1 (4,294,967,295). TimeTicks measures time in hundredths of a second. Uptime on a device is measured using this datatype.
Opaque
Allows any other ASN.1 encoding to be stuffed into an OCTET STRING.
Vegeu també RRDTool.
Consulteu OID
NOTA: Tingueu en compte que els OID poden aparèixer en valors numèrics o en text. Per exemple, en comptes del primer número (.1.) pot posar posarà iso.
Generals
Xarxa
Linux/Unix
Impressores
Exemple amb snmpwalk:
$ snmpwalk -Os -c public -v 2c 192.168.30.151 | grep 43.10.2.1.4.1.1 mib-2.43.10.2.1.4.1.1 = Counter32: 231812
On:
Routers Cisco
TODO
On Cisco routers and switches, the status of interfaces can be requested using the general OID's (see among general for status, input and output throughput)
The interface numbers are slightly different though. Interface #1 for example is the console port, then among the 100's (?) you have the VLAN and virtual interface's (like an EtherChannel) and the physical ports start at 10101 (GigabitEthernet1/0/1). If you have a stack of multiple switches, the second physical switch ports starts at 10601 (GigabitEthernet2/0/1).
The status you're reading out with the default OID is the physical status. There is also an 'administrative' status on a different OID which contains whether the configuration has the port enabled or disabled. Retrieved from "http://openideas.info/wiki/index.php?title=SnmpOid"
La resta de paquets tenen com a dependència aquest paquet.
Els fitxers instal·lats són:
$ dpkg -L libsnmp-base /. /var /var/lib /var/lib/snmp /usr /usr/share /usr/share/doc /usr/share/doc/libsnmp-base /usr/share/doc/libsnmp-base/README.gz /usr/share/doc/libsnmp-base/README.snmpv3 /usr/share/doc/libsnmp-base/NEWS.Debian.gz /usr/share/doc/libsnmp-base/README.Debian /usr/share/doc/libsnmp-base/README.mibs /usr/share/doc/libsnmp-base/copyright /usr/share/doc/libsnmp-base/FAQ.gz /usr/share/doc/libsnmp-base/NEWS.gz /usr/share/doc/libsnmp-base/README.thread.gz /usr/share/doc/libsnmp-base/changelog.Debian.gz /usr/share/mibs /usr/share/mibs/netsnmp /usr/share/mibs/netsnmp/NET-SNMP-TC /usr/share/mibs/netsnmp/NET-SNMP-MIB /usr/share/mibs/netsnmp/NET-SNMP-AGENT-MIB /usr/share/mibs/netsnmp/NET-SNMP-EXAMPLES-MIB /usr/share/mibs/netsnmp/NET-SNMP-EXTEND-MIB /usr/share/mibs/netsnmp/NET-SNMP-PASS-MIB /usr/share/mibs/netsnmp/NET-SNMP-MONITOR-MIB /usr/share/mibs/netsnmp/NET-SNMP-SYSTEM-MIB /usr/share/mibs/netsnmp/NET-SNMP-VACM-MIB /usr/share/mibs/netsnmp/UCD-SNMP-MIB /usr/share/mibs/netsnmp/UCD-DEMO-MIB /usr/share/mibs/netsnmp/UCD-IPFWACC-MIB /usr/share/mibs/netsnmp/UCD-DLMOD-MIB /usr/share/mibs/netsnmp/UCD-DISKIO-MIB /usr/share/mibs/netsnmp/GNOME-SMI /usr/share/mibs/netsnmp/LM-SENSORS-MIB /usr/share/snmp /usr/share/snmp/mib2c-data /usr/share/snmp/mib2c-data/default-mfd-top.m2c /usr/share/snmp/mib2c-data/details-enums.m2i /usr/share/snmp/mib2c-data/details-node.m2i /usr/share/snmp/mib2c-data/details-table.m2i /usr/share/snmp/mib2c-data/generic-ctx-copy.m2i /usr/share/snmp/mib2c-data/generic-ctx-get.m2i /usr/share/snmp/mib2c-data/generic-ctx-set.m2i /usr/share/snmp/mib2c-data/generic-data-allocate.m2i /usr/share/snmp/mib2c-data/generic-data-context.m2i /usr/share/snmp/mib2c-data/generic-get-char.m2i /usr/share/snmp/mib2c-data/generic-get-decl-bot.m2i /usr/share/snmp/mib2c-data/generic-get-decl.m2i /usr/share/snmp/mib2c-data/generic-get-long.m2i /usr/share/snmp/mib2c-data/generic-get-oid.m2i /usr/share/snmp/mib2c-data/generic-header-bottom.m2i /usr/share/snmp/mib2c-data/generic-header-top.m2i /usr/share/snmp/mib2c-data/generic-source-includes.m2i /usr/share/snmp/mib2c-data/generic-table-constants.m2c /usr/share/snmp/mib2c-data/generic-table-enums.m2c /usr/share/snmp/mib2c-data/generic-table-indexes-from-oid.m2i /usr/share/snmp/mib2c-data/generic-table-indexes-set.m2i /usr/share/snmp/mib2c-data/generic-table-indexes-to-oid.m2i /usr/share/snmp/mib2c-data/generic-table-indexes-varbind-setup.m2i /usr/share/snmp/mib2c-data/generic-table-indexes.m2i /usr/share/snmp/mib2c-data/generic-table-oids.m2c /usr/share/snmp/mib2c-data/generic-value-map-func.m2i /usr/share/snmp/mib2c-data/generic-value-map-reverse.m2i /usr/share/snmp/mib2c-data/generic-value-map.m2i /usr/share/snmp/mib2c-data/m2c-internal-warning.m2i /usr/share/snmp/mib2c-data/m2c_setup_enum.m2i /usr/share/snmp/mib2c-data/m2c_setup_node.m2i /usr/share/snmp/mib2c-data/m2c_setup_table.m2i /usr/share/snmp/mib2c-data/m2c_table_save_defaults.m2i /usr/share/snmp/mib2c-data/mfd-access-container-cached-defines.m2i /usr/share/snmp/mib2c-data/mfd-access-unsorted-external-defines.m2i /usr/share/snmp/mib2c-data/mfd-data-access.m2c /usr/share/snmp/mib2c-data/mfd-data-get.m2c /usr/share/snmp/mib2c-data/mfd-data-set.m2c /usr/share/snmp/mib2c-data/mfd-doxygen.m2c /usr/share/snmp/mib2c-data/mfd-interactive-setup.m2c /usr/share/snmp/mib2c-data/mfd-interface.m2c /usr/share/snmp/mib2c-data/mfd-makefile.m2m /usr/share/snmp/mib2c-data/mfd-readme.m2c /usr/share/snmp/mib2c-data/mfd-top.m2c /usr/share/snmp/mib2c-data/mfd-persistence.m2i /usr/share/snmp/mib2c-data/node-get.m2i /usr/share/snmp/mib2c-data/node-set.m2i /usr/share/snmp/mib2c-data/node-storage.m2i /usr/share/snmp/mib2c-data/node-validate.m2i /usr/share/snmp/mib2c-data/node-varbind-validate.m2i /usr/share/snmp/mib2c-data/parent-dependencies.m2i /usr/share/snmp/mib2c-data/parent-set.m2i /usr/share/snmp/mib2c-data/subagent.m2c /usr/share/snmp/mib2c-data/syntax-COUNTER64-get.m2i /usr/share/snmp/mib2c-data/syntax-DateAndTime-get.m2d /usr/share/snmp/mib2c-data/syntax-DateAndTime-get.m2i /usr/share/snmp/mib2c-data/syntax-DateAndTime-readme.m2i /usr/share/snmp/mib2c-data/syntax-InetAddress-get.m2i /usr/share/snmp/mib2c-data/syntax-InetAddress-set.m2i /usr/share/snmp/mib2c-data/syntax-InetAddressType-get.m2i /usr/share/snmp/mib2c-data/syntax-InetAddressType-set.m2i /usr/share/snmp/mib2c-data/syntax-RowStatus-dependencies.m2i /usr/share/snmp/mib2c-data/syntax-RowStatus-get.m2i /usr/share/snmp/mib2c-data/syntax-RowStatus-varbind-validate.m2i /usr/share/snmp/mib2c-data/syntax-StorageType-dependencies.m2i /usr/share/snmp/mib2c-data/syntax-TestAndIncr-get.m2i /usr/share/man /usr/share/man/man5 /usr/share/man/man5/snmp_config.5snmp.gz /usr/share/man/man5/snmpd.examples.5snmp.gz /usr/share/man/man5/snmpd.internal.5snmp.gz /usr/share/man/man5/variables.5snmp.gz /usr/share/man/man5/mib2c.conf.5snmp.gz /usr/share/man/man5/snmp.conf.5snmp.gz
És el paquet client. Vegeu SNMP#Client
És el paquet del servidor. Vegeu SNMP#Servidor
Per un problema de llicències restrictives (no són lliures) de les bases de dades MIBs, s'ha hagut de separar la base de dades de les aplicacions client i servidor. Per instal·lar-les cal instal·lar un paquet apart que es troba al non-free de Debian o al multiverse d'Ubuntu (snmp-mibs-downloader):
$ sudo apt-get install snmp-mibs-downloader ... Downloading documents and extracting MIB files. This will take some minutes. In case this process fails, it can always be repeated later by executing /usr/bin/download-mibs again.
També uns mostrarà una llarga llista dels fitxers que descarrega amb el nom de la base de dades MIB i el nombre de línies. La podeu consultar a:
snmp-mibs-downloader/BasesdedadesMIBS
En qualsevol moment es poden tornar a baixar amb l'ordre:
$ sudo /usr/bin/download-mibs
A més un cop instal·lades les bases de dades per activar-les cal modificar el fitxer:
$ sudo joe /etc/snmp/snmp.conf
I comentar la línia mibs : deixant el fitxer de la següent forma:
# # As the snmp packages come without MIB files due to license reasons, loading # of MIBs is disabled by default. If you added the MIBs you can reenable # loaging them by commenting out the following line. #mibs :
Els fitxers instal·lats són:
$ dpkg -L snmp-mibs-downloader /. /usr /usr/bin /usr/bin/download-mibs /usr/share /usr/share/mibs /usr/share/doc /usr/share/doc/mibrfcs /usr/share/doc/mibrfcs/rfc1227.txt.gz /usr/share/doc/mibrfcs/rfc1238.txt.gz ... /usr/share/doc/mibiana /usr/share/doc/mibiana/ianacharset-mib.gz /usr/share/doc/mibiana/ianafinisher-mib.gz /usr/share/doc/mibiana/ianagmplstc-mib.gz /usr/share/doc/mibiana/ianaipfixselector-mib.gz /usr/share/doc/mibiana/ianaippmmetricsregistry-mib.gz /usr/share/doc/mibiana/ianaitualarmtc-mib.gz /usr/share/doc/mibiana/ianaiprouteprotocol-mib /usr/share/doc/mibiana/ianalanguage-mib.gz /usr/share/doc/mibiana/ianamau-mib.gz /usr/share/doc/mibiana/ianamalloc-mib /usr/share/doc/mibiana/ianatn3270etc-mib.gz /usr/share/doc/mibiana/ianaaddressfamilynumbers-mib.gz /usr/share/doc/mibiana/ianaiftype-mib.gz /usr/share/doc/mibiana/ianaprinter-mib.gz /usr/share/doc/snmp-mibs-downloader /usr/share/doc/snmp-mibs-downloader/copyright /usr/share/doc/snmp-mibs-downloader/examples /usr/share/doc/snmp-mibs-downloader/examples/cisco.conf /usr/share/doc/snmp-mibs-downloader/examples/screenos.conf /usr/share/doc/snmp-mibs-downloader/examples/screenoslist /usr/share/doc/snmp-mibs-downloader/examples/junos.conf /usr/share/doc/snmp-mibs-downloader/examples/junoslist /usr/share/doc/snmp-mibs-downloader/examples/ciscolist.gz /usr/share/doc/snmp-mibs-downloader/changelog.gz /usr/share/man /usr/share/man/man1 /usr/share/man/man1/download-mibs.1.gz /etc /etc/snmp-mibs-downloader /etc/snmp-mibs-downloader/snmp-mibs-downloader.conf /etc/snmp-mibs-downloader/iana.conf /etc/snmp-mibs-downloader/ianalist /etc/snmp-mibs-downloader/rfc.conf /etc/snmp-mibs-downloader/rfclist /etc/snmp-mibs-downloader/rfcmibs.diff /etc/snmp-mibs-downloader/simpleweb.conf /etc/snmp-mibs-downloader/simplelist /etc/snmp-mibs-downloader/ianarfc.conf /etc/snmp-mibs-downloader/ianarfclist /var /var/lib /var/lib/mibs /usr/share/mibs/ietf /usr/share/mibs/iana
Per instal·lar un servidor SNMP a una màquina Linux amb Debian i/o Ubuntu:
$ sudo apt-get install snmpd
Comandes;
$ dpkg -L snmpd | grep bin /usr/sbin /usr/sbin/snmpd /usr/sbin/snmptrapd
Fitxers de configuració
$ dpkg -L snmpd | grep etc /etc /etc/default /etc/default/snmpd /etc/snmp /etc/snmp/snmpd.conf /etc/snmp/snmptrapd.conf /etc/init.d /etc/init.d/snmpd
Per instal·lar el client:
$ sudo apt-get install snmp
Comandes:
$ dpkg -L snmp | grep bin /usr/bin /usr/bin/snmpbulkget /usr/bin/snmpbulkwalk /usr/bin/snmpconf /usr/bin/snmpdelta /usr/bin/snmpdf /usr/bin/snmpget /usr/bin/snmpgetnext /usr/bin/snmpnetstat /usr/bin/snmpnetstat53 /usr/bin/snmpset /usr/bin/snmpstatus /usr/bin/snmptable /usr/bin/snmptest /usr/bin/snmptranslate /usr/bin/snmptrap /usr/bin/snmpusm /usr/bin/snmpvacm /usr/bin/snmpwalk /usr/bin/encode_keychange /usr/bin/fixproc /usr/bin/traptoemail /usr/bin/mib2c-update /usr/bin/snmpinform
Normalment a aquest fitxer no cal posar res però a les noves versions d'Ubuntu cal tenir-lo en compte!. Llegiu:
snmp-mibs-downloader
Per a més informació podeu consultar el manual:
$ man snmp.conf
De totes maneres es pot utilitzar per sobrescriure opcions per defecte de les comandes client com per exemple la versió posant:
defVersion 2c
Aquesta carpeta permet configurar el client SNMP Per User.
Les podeu consultar consultant el manual:
$ man snmpcmd SNMPCMD(1) Net-SNMP SNMPCMD(1) NAME snmpcmd - options and behaviour common to most of the Net-SNMP command-line tools ...
Algunes de les més habituals:
defVersion 2c
L'opció de sortida per defecte és -oS:
-OS Display the name of the MIB, as well as the object name: SNMPv2-MIB::sysUpTime.0 = Timeticks: (14096763) 1 day, 15:09:27.63
Permet obtenir el valor de un OID concret. Per exemple, per obtenir el contacte (SysContact) podeu utilitzar el OID
$ snmpget -v 1 -c public 10.139.221.100 .1.3.6.1.2.1.1.4.0 SNMPv2-MIB::sysContact.0 = STRING: [email protected]
IMPORTANT: A diferència de l'ordre snmpwalk cal indicar el index encara que sigui un valor escalar i el index sigui 0 (fixeu-vos en l'últim .0)
O per nom:
$ snmpget -v 1 -c public 10.139.221.100 sysContact.0 SNMPv2-MIB::sysContact.0 = STRING: [email protected]
Per a un valor vectorial, per exemple sysORDescr cal indicar també l'índex començant aquest cas des de 1 (a l'exemple el 3 valor del vector):
$ snmpget -v 1 -c public 10.139.221.100 SNMPv2-MIB::sysORDescr.3 SNMPv2-MIB::sysORDescr.3 = STRING: The MIB module to describe generic objects for network interface sub-layers
La comanda snmpwalk ens mostra els continguts de la base de dades MIB de SNMP a partir d'un node concret.
Per exemple, per obtenir les dades de la secció sistema a una màquina local amb snmp activat:
$ snmpwalk -Os -c public -v 2c localhost system sysDescr.0 = STRING: Linux ubuntu-sala 2.6.22-14-generic #1 SMP Sun Oct 14 23:05:12 GMT 2007 i686 sysObjectID.0 = OID: netSnmpAgentOIDs.10 sysUpTimeInstance = Timeticks: (984884) 2:44:08.84 sysContact.0 = STRING: Root <[email protected]> (configure /etc/snmp/snmpd.local.conf) sysName.0 = STRING: ubuntu-sala sysLocation.0 = STRING: Unknown (configure /etc/snmp/snmpd.local.conf) sysORLastChange.0 = Timeticks: (54) 0:00:00.54 sysORID.1 = OID: snmpMIB sysORID.2 = OID: tcpMIB sysORID.3 = OID: ip sysORID.4 = OID: udpMIB sysORID.5 = OID: vacmBasicGroup sysORID.6 = OID: snmpFrameworkMIBCompliance sysORID.7 = OID: snmpMPDCompliance sysORID.8 = OID: usmMIBCompliance sysORDescr.1 = STRING: The MIB module for SNMPv2 entities sysORDescr.2 = STRING: The MIB module for managing TCP implementations sysORDescr.3 = STRING: The MIB module for managing IP and ICMP implementations sysORDescr.4 = STRING: The MIB module for managing UDP implementations sysORDescr.5 = STRING: View-based Access Control Model for SNMP. sysORDescr.6 = STRING: The SNMP Management Architecture MIB. sysORDescr.7 = STRING: The MIB for Message Processing and Dispatching. sysORDescr.8 = STRING: The management information definitions for the SNMP User-based Security Model. sysORUpTime.1 = Timeticks: (54) 0:00:00.54 sysORUpTime.2 = Timeticks: (54) 0:00:00.54 sysORUpTime.3 = Timeticks: (54) 0:00:00.54 sysORUpTime.4 = Timeticks: (54) 0:00:00.54 sysORUpTime.5 = Timeticks: (54) 0:00:00.54 sysORUpTime.6 = Timeticks: (54) 0:00:00.54 sysORUpTime.7 = Timeticks: (54) 0:00:00.54 sysORUpTime.8 = Timeticks: (54) 0:00:00.54
On
-c public
Indica la community que volem utilitzar. Es tracta com d'una espècie de clau compartida (paraula de pas) per accedir al servidor SNMP. Normalment s'utilitza public, de feu si ho canvieu no poseu cap paraula de pas que sigui critica ja que la community viatge sense xifrar per la xarxa i són molt fàcils de ser capturades amb eines com Ettercap.
Amb:
-v 2c
Indiquem la versió de SNMP. Consulteu Opcions comunes de la majoria de comandes per veure els valors possibles de versions del protocol SNMP.
Finalment l'últim paràmetre (system) ens indica que volem mostrar les dades del node:
.1.3.6.1.2.1.1
o la seva conversió a text (vegeu snmptranslate)
.iso.org.dod.mgtm.mib-2.system.
Que conté les dades generals del sistema.
De fet podeu obtenir els valors de SNMP en numèric amb l'opció -On:
$ snmpwalk -Os -On -c public -v 2c localhost system
Si utilitzem snmpwalk sense l'últim paràmetre:
$ snmpwalk -Os -c public -v 2c localhost
IMPORTANT: Per defecte, snmpwalk mostra només l'arbre mib-2 i per aquesta raó pot ser que no es mostrin totes les opcions. Demaneu com a OID el . i així mostrareu tot l'arbre!
Consulteu també snmpwalk no mostra l'arbre sencer. Per tant per defecte és el mateix:
$ snmpwalk -Os -c public -v 2c localhost
Que:
$ snmpwalk -Os -c public -v 2c localhost .1.3.6.1.2.1
Per tal d'obtenir tot l'arbre complet:
$ snmpwalk -Os -c public -v 2c localhost .
Les seccions més interessants per a consultar són les del node 'iso.org.dod.mgtm.mib-2:
Per monitoritzar les interfícies de xarxa podem utilitzar:
$ snmpwalk -Os -c public -v 2c localhost interfaces
IMPORTANT: Abans que el següent us pugui funcionar correctament a Debian Ubuntu consulteu: Snmp-mibs-downloader
Permet fer les traduccions de OIDs a noms. Per exemple
$ snmptranslate .1.3.6.1.2.1.2.2.1.2 IF-MIB::ifDescr
O al revés:
$ snmptranslate -On IF-MIB::ifDescr .1.3.6.1.2.1.2.2.1.2
O per obtenir els noms de cada part del OID:
$ snmptranslate -Of .1.3.6.1.2.1.2.2.1.2 .iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifDescr
També permet consultar tota la definició del OID amb:
$ snmptranslate -Td .1.3.6.1.2.1.2.2.1.2 IF-MIB::ifDescr ifDescr OBJECT-TYPE -- FROM IF-MIB, RFC1213-MIB -- TEXTUAL CONVENTION DisplayString SYNTAX OCTET STRING (0..255) DISPLAY-HINT "255a" MAX-ACCESS read-only STATUS current DESCRIPTION "A textual string containing information about the interface. This string should include the name of the manufacturer, the product name and the version of the interface hardware/software." ::= { iso(1) org(3) dod(6) internet(1) mgmt(2) mib-2(1) interfaces(2) ifTable(2) ifEntry(1) 2 }
Un opció interessant és definir un alias:
$ alias snmpwhat ‘snmptranslate -Td `snmptranslate -IR -On \!:1`’ $ snmpwhat sysLocation
Un cop instal·lat el servidor amb:
$ sudo apt-get install snmpd
I instal·lat i configurat el paquet snmp-mibs-downloader, cal editar el fitxer:
$ sudo joe /etc/snmp/snmpd.conf
Comenteu la línia:
agentAddress udp:127.0.0.1:161
i descomenteu la línia:
#agentAddress udp:161,udp6:[::1]:161
La secció us ha de quedar:
# # AGENT BEHAVIOUR # # Listen for connections from the local system only #agentAddress udp:127.0.0.1:161 # Listen for connections on all interfaces (both IPv4 *and* IPv6) agentAddress udp:161,udp6:[::1]:161
També canvieu la línia:
#rocommunity public localhost
i poseu quelcom similar a:
rocommunity public 192.168.50.0/24 rocommunity public localhost
NOTA: És a dir, afegim suport per a connectar al servidor SNMP des de localhost o des de la xarxa 192.168.50.0/24. Canvieu el rang de xarxa al que us pertoqui!
On 192.168.50.0/24 és el rang d'adreces IP que tindran accés al servidor SNMP.
i comenteu la línia:
rocommunity public default -V systemonly
Finalment busqueu les línies:
view systemonly included .1.3.6.1.2.1.1 view systemonly included .1.3.6.1.2.1.25.1
I comenteu-les. Afegiu a canvi la línia:
view all included .1
Aprofiteu per establir els valors de sysLocation i sysContact:
# Note that setting these values here, results in the corresponding MIB objects being 'read-only' # See snmpd.conf(5) for more details sysLocation Sitting on the Dock of the Bay sysContact Me <[email protected]>
Per exemple:
sysLocation Sala Servidors sysContact Manteniment d'Informàtica <[email protected]>
En el meu cas el fitxer ha quedat de la següent manera:
############################################################################### # # EXAMPLE.conf: # An example configuration file for configuring the Net-SNMP agent ('snmpd') # See the 'snmpd.conf(5)' man page for details # # Some entries are deliberately commented out, and will need to be explicitly activated # ############################################################################### # # AGENT BEHAVIOUR # # Listen for connections from the local system only #agentAddress udp:127.0.0.1:161 # Listen for connections on all interfaces (both IPv4 *and* IPv6) agentAddress udp:161,udp6:[::1]:161 ############################################################################### # # SNMPv3 AUTHENTICATION # # Note that these particular settings don't actually belong here. # They should be copied to the file /var/lib/snmp/snmpd.conf # and the passwords changed, before being uncommented in that file *only*. # Then restart the agent # createUser authOnlyUser MD5 "remember to change this password" # createUser authPrivUser SHA "remember to change this one too" DES # createUser internalUser MD5 "this is only ever used internally, but still change the password" # If you also change the usernames (which might be sensible), # then remember to update the other occurances in this example config file to match. ############################################################################### # # ACCESS CONTROL # # system + hrSystem groups only #view systemonly included .1.3.6.1.2.1.1 #view systemonly included .1.3.6.1.2.1.25.1 view all included .1 # Full access from the local host rocommunity public 192.168.50.0/24 # Default access to basic system info #rocommunity public default -V systemonly # Full access from an example network # Adjust this network address to match your local # settings, change the community string, # and check the 'agentAddress' setting above #rocommunity secret 10.0.0.0/16
Apliqueu els canvis amb:
$ sudo /etc/init.d/snmpd restart
Els podem obtenir consultant el fitxers /etc/services:
$ cat /etc/services | grep snmp snmp 161/tcp # Simple Net Mgmt Protocol snmp 161/udp # Simple Net Mgmt Protocol snmp-trap 162/tcp snmptrap # Traps for SNMP snmp-trap 162/udp snmptrap # Traps for SNMP
Per saber si un dispositiu suporta SNMP podem primer utilitzar l'scanner de ports nmap:
$ sudo nmap -sU 192.168.1.1 -p 161 Starting Nmap 4.20 ( http://insecure.org ) at 2007-12-10 12:56 CET Interesting ports on mygateway1.ar7 (192.168.1.1): PORT STATE SERVICE 161/udp open|filtered snmp MAC Address: 00:15:E9:CA:34:A5 (D-Link) Nmap finished: 1 IP address (1 host up) scanned in 0.439 seconds
Fixeu-vos que cal indicar explícitament que voleu fer un escaneig amb UDP.
La configuració per defecte només escolta peticions des de localhost. El següent us funcionarà:
$ snmpwalk -Os -c public -v 2c localhost .
En canvi:
$ snmpwalk -Os -c public -v 2c 192.168.0.102 .
On a l'exemple la màquina que volem monitortizar té la IP 192.168.0.102
donarà un timeout
Al fitxer /etc/snmp/snmpd.conf comenteu la línia:
agentAddress udp:127.0.0.1:161
I descomenteu:
# Listen for connections on all interfaces (both IPv4 *and* IPv6) agentAddress udp:161,udp6:[::1]:161
Apliqueu els canvis amb un restart (el reload no funciona en aquest cas):
$ sudo /etc/init.d/snmpd restart
Els servidors SNMP a Debian i Ubuntu venen amb la configuració per defecte en mode paranoic. Això fa que no vegeu tot l'arbre d'objecte OID. eDITEU EL FITXER:
$ sudo joe /etc/snmp/snmpd.conf
i comenteu les línies:
#view systemonly included .1.3.6.1.2.1.1 #view systemonly included .1.3.6.1.2.1.25.1
I poseu:
view all included .1
Descomenteu la línia:
rocommunity public localhost
i canvieu-la per quelcom similar a:
rocommunity public 192.168.0.0/24 rocommunity public 127.0.0.0/8
Si voleu donar accés a tot poseu només una línia amb
rocommunity public
On 192.168.0.0/24 és el rang d'adreces de xarxa que podran obtenir informació per SNMP.
Comenteu la línia:
# rocommunity public default -V systemonly
Apliqueu els canvis:
$ sudo /etc/init.d/snmpd restart
$ sudo /etc/init.d/snmpd dasdasdas Usage: /etc/init.d/snmpd {start|stop|restart|reload|force-reload|status}
Per aplicar canvis a la configuració feu un reload:
$ sudo /etc/init.d/snmpd reload
NOTA: Comprovat a la versió Ubuntu 11.10 però és possible que també funcioni en versions anteriors
El fitxer de configuració del servidor continua sent /etc/snmp/snmpd.conf però es controla l'accés amb vistes. Per defecte la configuració de Debian/Ubuntu és paranoica, per a poder veure tots els valors cal posar:
rocommunity public localhost
i comenteu la línia:
# rocommunity public default -V systemonly
I aplicar els canvis:
$ sudo /etc/init.d/snmpd restart
El fitxer de configuració del servidor és /etc/snmp/snmpd.conf. A una Ubuntu 9.10 trobem:
$ sudo cat /etc/snmp/snmpd.conf | grep -v '^#\|^$\|^;' com2sec paranoid default public group MyROSystem v1 paranoid group MyROSystem v2c paranoid group MyROSystem usm paranoid group MyROGroup v1 readonly group MyROGroup v2c readonly group MyROGroup usm readonly group MyRWGroup v1 readwrite group MyRWGroup v2c readwrite group MyRWGroup usm readwrite view all included .1 80 view system included .iso.org.dod.internet.mgmt.mib-2.system access MyROSystem "" any noauth exact system none none access MyROGroup "" any noauth exact all none none access MyRWGroup "" any noauth exact all all none syslocation Unknown (configure /etc/snmp/snmpd.local.conf) syscontact Root <[email protected]> (configure /etc/snmp/snmpd.local.conf)
On:
$ sudo cat /etc/snmp/snmpd.conf ................ ############################################################################### # Access Control ############################################################################### .............. .............. # sec.name source community com2sec paranoid default public #com2sec readonly default public #com2sec readwrite default private
Per defecte esta en mode paranoid. Si volem activar el servidor hem de descomentar la línia:
com2sec readonly default public
I comentar la línia
com2sec paranoid default public
El fitxer queda de la següent manera:
$ sudo cat /etc/snmp/snmpd.conf ................ ############################################################################### # Access Control ############################################################################### .............. .............. # sec.name source community #com2sec paranoid default public com2sec readonly default public #com2sec readwrite default private
Sempre que modifiquem la configuració cal aplicar els canvis tornant a iniciar el servidor amb la comanda:
$ sudo /etc/init.d/snmpd reload
Per provar que funciona:
$ snmpwalk -Os -c public -v 2c localhost system
Recursos:
La comanda snmpconf ens ofereix un assistent que permet configurar snmp.
$ sudo snmpconf The following installed configuration files were found: 1: /etc/snmp/snmpd.conf 2: /etc/snmp/snmptrapd.conf Would you like me to read them in? Their content will be merged with the output files created by this session. Valid answer examples: "all", "none","3","1,2,5" Read in which (default = all): 1 I can create the following types of configuration files for you. Select the file type you wish to create: (you can create more than one as you run this program) 1: snmpd.conf 2: snmp.conf 3: snmptrapd.conf Other options: quit Select File:
Les primeres opcions ens pregunten quins fitxers de configuració volem modificar.
Per modificar el servidor, primer escollim:
1: /etc/snmp/snmpd.conf
i després:
1: snmpd.conf
Seguim...
The configuration information which can be put into snmpd.conf is divided into sections. Select a configuration section for snmpd.conf that you wish to create: 1: Extending the Agent 2: Monitor Various Aspects of the Running Host 3: Access Control Setup 4: Agent Operating Mode 5: Trap Destinations 6: System Information Setup
Other options: finished
Select section:
A la tercera pregunta de snmpconf seleccionen l'opció 2:
2: Monitor Various Aspects of the Running Host
The configuration information which can be put into snmpd.conf is divided into sections. Select a configuration section for snmpd.conf that you wish to create: 1: Extending the Agent 2: Monitor Various Aspects of the Running Host 3: Access Control Setup 4: Agent Operating Mode 5: Trap Destinations 6: System Information Setup Other options: finished Select section: 2
Tindrem 4 grups de paràmetres a monitoritzar:
Section: Monitor Various Aspects of the Running Host Description: The following check up on various aspects of a host. Select from: 1: Check for processes that should be running. 2: Check for disk space usage of a partition. 3: Check for unreasonable load average values. 4: Check on the size of a file. Other options: finished, list Select section:
Per exemple podem controlar el servidor apache2:
Configuring: proc Description: Check for processes that should be running. proc NAME [MAX=0] [MIN=0] NAME: the name of the process to check for. It must match exactly (ie, http will not find httpd processes). MAX: the maximum number allowed to be running. Defaults to 0. MIN: the minimum number to be running. Defaults to 0. The results are reported in the prTable section of the UCD-SNMP-MIB tree Special Case: When the min and max numbers are both 0, it assumes you want a max of infinity and a min of 1. Name of the process you want to check on: apache2 Maximum number of processes named 'apache2' that should be running [default = 0]: 0 Minimum number of processes named 'apache2' that should be running [default = 0]: 10
Ara només queda guardar escrivint varies vegades la comanda finished. Snmpconf ens generarà un fitxer anomenat:
snmpd.conf
Que el podem substituir per l'antic /etc/snmp/snmpd.conf:
$ sudo cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.old $ sudo cp snmpd.conf /etc/snmp
i reiniciar snmp:
$ sudo /etc/init.d/snmpd reload
Ara podem consultar les alertes del procés apache2 amb:
$ snmpwalk -Os -c public -v 2c localhost prTable prIndex.1 = INTEGER: 1 prNames.1 = STRING: apache2 prMin.1 = INTEGER: 10 prMax.1 = INTEGER: 0 prCount.1 = INTEGER: 6 prErrorFlag.1 = INTEGER: 1 prErrMessage.1 = STRING: Too few apache2 running (# = 6) prErrFix.1 = INTEGER: 0 prErrFixCmd.1 = STRING:
O amb mbrowse:
El podeu trobar online a:
http://www.net-snmp.org/docs/FAQ.html
I també al fitxer:
/usr/share/doc/libsnmp-base/FAQ
Per instal·lar mbrowse cal executar:
$ sudo apt-get install mbrowse
i executeu el següent des de una terminal:
$ mbrowse
Exemples de com realitzar modificacions com el nom del dispositiu o reiniciar a:
Recursos:
$ snmpwalk -v1 -c public 192.168.12.50 -m ALL .1 | grep DeviceDescr HOST-RESOURCES-MIB::hrDeviceDescr.1 = STRING: hp LaserJet 2420
$ snmpwalk -Os -v 1 -c public 192.168.30.92 > information.txt $ cat information.txt | grep "43.10.2.1.4.1.1" iso.3.6.1.2.1.43.10.2.1.4.1.1 = Counter32: 19150
El OID 43.10.2.1.4.1.1 és la clau.
The major branches are: 1 iso 1.3 org 1.3.6 dod 1.3.6.1 internet 1.3.6.1.1 directory 1.3.6.1.2 mgmt 1.3.6.1.2.1 mib-2 1.3.6.1.2.1.2.2.1.3 ifType 1.3.6.1.2.1.10 transmission 1.3.6.1.2.1.10.23 transmissionppp 1.3.6.1.2.1.27 application 1.3.6.1.2.1.28 mta 1.3.6.1.2.2 pib 1.3.6.1.3 experimental 1.3.6.1.4 private 1.3.6.1.4.1 enterprise 1.3.6.1.5 security 1.3.6.1.6 SNMPv2 1.3.6.1.6.1 snmpDomains 1.3.6.1.6.2 snmpProxys 1.3.6.1.6.3 snmpModules 1.3.6.1.7 mail 1.3.6.1.8 features
TODO: Provar
/usr/bin/snmpset <ip> <write comunity> .1.3.6.1.2.1.43.5.1.1.3.1 i 5
Un altre exemple:
snmpset -v 1 -c public $HP4050N .1.3.6.1.2.1.43.5.1.1.3.1 i 5
$ snmpwalk -n -Os -c public -v 2c 172.16.3.139 1.3.6.1.2.1.43.11.1.1SNMPv2-SMI::mib-2.43.11.1.1.2.1.1 = INTEGER: 1 SNMPv2-SMI::mib-2.43.11.1.1.3.1.1 = INTEGER: 0 SNMPv2-SMI::mib-2.43.11.1.1.4.1.1 = INTEGER: 3 SNMPv2-SMI::mib-2.43.11.1.1.5.1.1 = INTEGER: 3 SNMPv2-SMI::mib-2.43.11.1.1.6.1.1 = STRING: "Cartutx negre HP CE505A" SNMPv2-SMI::mib-2.43.11.1.1.7.1.1 = INTEGER: 13 SNMPv2-SMI::mib-2.43.11.1.1.8.1.1 = INTEGER: 940 SNMPv2-SMI::mib-2.43.11.1.1.9.1.1 = INTEGER: 329
Per mostrar de mostrar els OID de forma numèrica:
$ snmpwalk -On -c public -v 2c 172.16.3.139 1.3.6.1.2.1.43.11.1.1 .1.3.6.1.2.1.43.11.1.1.2.1.1 = INTEGER: 1 .1.3.6.1.2.1.43.11.1.1.3.1.1 = INTEGER: 0 .1.3.6.1.2.1.43.11.1.1.4.1.1 = INTEGER: 3 .1.3.6.1.2.1.43.11.1.1.5.1.1 = INTEGER: 3 .1.3.6.1.2.1.43.11.1.1.6.1.1 = STRING: "Cartutx negre HP CE505A" .1.3.6.1.2.1.43.11.1.1.7.1.1 = INTEGER: 13 .1.3.6.1.2.1.43.11.1.1.8.1.1 = INTEGER: 940 .1.3.6.1.2.1.43.11.1.1.9.1.1 = INTEGER: 329
Està dins del MIB-2 i té com a OID base:
$ snmptranslate .1.3.6.1.2.1.25 HOST-RESOURCES-MIB::host
El fitxer és troba a:
/var/lib/mibs/ietf/HOST-RESOURCES-MIB
Es comença definint l'arrel:
host OBJECT IDENTIFIER ::= { mib-2 25 }
Dins de host trobem 7 subapartats:
hrSystem OBJECT IDENTIFIER ::= { host 1 } hrStorage OBJECT IDENTIFIER ::= { host 2 } hrDevice OBJECT IDENTIFIER ::= { host 3 } hrSWRun OBJECT IDENTIFIER ::= { host 4 } hrSWRunPerf OBJECT IDENTIFIER ::= { host 5 } hrSWInstalled OBJECT IDENTIFIER ::= { host 6 } hrMIBAdminInfo OBJECT IDENTIFIER ::= { host 7 }
Alguns dels exemples més habituals:
$ snmptranslate .1.3.6.1.2.1.25.3.3.1.2.1 HOST-RESOURCES-MIB::hrProcessorLoad.1 $ snmptranslate .1.3.6.1.2.1.25.3.3.1.2.2 HOST-RESOURCES-MIB::hrProcessorLoad.2 ...
La llista completa de MIBS (en construcció)
hrSystem (.1.3.6.1.2.1.25.1)
::= { hrSystem 1 }
hrStorage (.1.3.6.1.2.1.25.2)
hrDevice (.1.3.6.1.2.1.25.3)
Vegeu snmpd i l'exemple OpenFPnet/Mosaic/Formació/Execució/Màquines_virtuals_plantilla#Instal.C2.B7laci.C3.B3_de_SNMP:
El agent snmp es toba al CD de Windows XP. Imatge:
Recursos:
Els grups a MIBS-2
system OBJECT IDENTIFIER ::= { mib-2 1 }. Consulteu SNMP#Navegaci.C3.B3_de_MIBS_i_snmpwalk interfaces OBJECT IDENTIFIER ::= { mib-2 2 } at OBJECT IDENTIFIER ::= { mib-2 3 } ip OBJECT IDENTIFIER ::= { mib-2 4 } icmp OBJECT IDENTIFIER ::= { mib-2 5 } tcp OBJECT IDENTIFIER ::= { mib-2 6 } udp OBJECT IDENTIFIER ::= { mib-2 7 } egp OBJECT IDENTIFIER ::= { mib-2 8 } -- historical (some say hysterical) -- cmot OBJECT IDENTIFIER ::= { mib-2 9 } transmission OBJECT IDENTIFIER ::= { mib-2 10 } snmp OBJECT IDENTIFIER ::= { mib-2 11 }
Anem a veure en detall els grups més interessants en els següents apartats
mib-2 2 : .1.3.6.1.2.1.1
Consulteu SNMP#Navegaci.C3.B3_de_MIBS_i_snmpwalk
EL OID base és:
mib-2 2 : .1.3.6.1.2.1.2
També conegut com IF-MIB.
El podeu trobar descrit al fitxer:
/var/lib/mibs/ietf/RFC1213-MIB
Els valors més importants són:
El següent és la taula ifTable (.1.3.6.1.2.1.2.2):
Cada entrada de la taula és una de les interfícies de xarxa.
Un exemple d'una Mikrotik:
$ snmpwalk -v 1 -c public 10.139.221.100 .1.3.6.1.2.1.2 IF-MIB::ifNumber.0 = INTEGER: 7 IF-MIB::ifIndex.1 = INTEGER: 1 IF-MIB::ifIndex.2 = INTEGER: 2 IF-MIB::ifIndex.3 = INTEGER: 3 IF-MIB::ifIndex.4 = INTEGER: 4 IF-MIB::ifIndex.5 = INTEGER: 5 IF-MIB::ifIndex.6 = INTEGER: 6 IF-MIB::ifIndex.7 = INTEGER: 7 IF-MIB::ifDescr.1 = STRING: lo IF-MIB::ifDescr.2 = STRING: gre0 IF-MIB::ifDescr.3 = STRING: eth0 IF-MIB::ifDescr.4 = STRING: eth1 IF-MIB::ifDescr.5 = STRING: br0 IF-MIB::ifDescr.6 = STRING: wifi0 IF-MIB::ifDescr.7 = STRING: ath0 IF-MIB::ifType.1 = INTEGER: softwareLoopback(24) IF-MIB::ifType.2 = INTEGER: other(1) IF-MIB::ifType.3 = INTEGER: ethernetCsmacd(6) IF-MIB::ifType.4 = INTEGER: ethernetCsmacd(6) IF-MIB::ifType.5 = INTEGER: ethernetCsmacd(6) IF-MIB::ifType.6 = INTEGER: ethernetCsmacd(6) IF-MIB::ifType.7 = INTEGER: ethernetCsmacd(6) IF-MIB::ifMtu.1 = INTEGER: 16436 IF-MIB::ifMtu.2 = INTEGER: 1476 IF-MIB::ifMtu.3 = INTEGER: 1500 IF-MIB::ifMtu.4 = INTEGER: 1500 IF-MIB::ifMtu.5 = INTEGER: 1500 IF-MIB::ifMtu.6 = INTEGER: 1500 IF-MIB::ifMtu.7 = INTEGER: 1500 IF-MIB::ifSpeed.1 = Gauge32: 0 IF-MIB::ifSpeed.2 = Gauge32: 0 IF-MIB::ifSpeed.3 = Gauge32: 100000000 IF-MIB::ifSpeed.4 = Gauge32: 0 IF-MIB::ifSpeed.5 = Gauge32: 0 IF-MIB::ifSpeed.6 = Gauge32: 0 IF-MIB::ifSpeed.7 = Gauge32: 300000000 IF-MIB::ifPhysAddress.1 = STRING: IF-MIB::ifPhysAddress.2 = STRING: IF-MIB::ifPhysAddress.3 = STRING: 0:27:22:2b:df:33 IF-MIB::ifPhysAddress.4 = STRING: 2:27:22:2b:df:33 IF-MIB::ifPhysAddress.5 = STRING: 0:27:22:2a:df:33 IF-MIB::ifPhysAddress.6 = STRING: 0:27:22:2a:df:33 IF-MIB::ifPhysAddress.7 = STRING: 0:27:22:2a:df:33 IF-MIB::ifAdminStatus.1 = INTEGER: up(1) IF-MIB::ifAdminStatus.2 = INTEGER: down(2) IF-MIB::ifAdminStatus.3 = INTEGER: up(1) IF-MIB::ifAdminStatus.4 = INTEGER: up(1) IF-MIB::ifAdminStatus.5 = INTEGER: up(1) IF-MIB::ifAdminStatus.6 = INTEGER: up(1) IF-MIB::ifAdminStatus.7 = INTEGER: up(1) IF-MIB::ifOperStatus.1 = INTEGER: up(1) IF-MIB::ifOperStatus.2 = INTEGER: down(2) IF-MIB::ifOperStatus.3 = INTEGER: up(1) IF-MIB::ifOperStatus.4 = INTEGER: down(2) IF-MIB::ifOperStatus.5 = INTEGER: up(1) IF-MIB::ifOperStatus.6 = INTEGER: up(1) IF-MIB::ifOperStatus.7 = INTEGER: up(1) IF-MIB::ifLastChange.1 = Timeticks: (0) 0:00:00.00 IF-MIB::ifLastChange.2 = Timeticks: (0) 0:00:00.00 IF-MIB::ifLastChange.3 = Timeticks: (0) 0:00:00.00 IF-MIB::ifLastChange.4 = Timeticks: (0) 0:00:00.00 IF-MIB::ifLastChange.5 = Timeticks: (0) 0:00:00.00 IF-MIB::ifLastChange.6 = Timeticks: (0) 0:00:00.00 IF-MIB::ifLastChange.7 = Timeticks: (0) 0:00:00.00 IF-MIB::ifInOctets.1 = Counter32: 0 IF-MIB::ifInOctets.2 = Counter32: 0 IF-MIB::ifInOctets.3 = Counter32: 3824272071 IF-MIB::ifInOctets.4 = Counter32: 0 IF-MIB::ifInOctets.5 = Counter32: 317234036 IF-MIB::ifInOctets.6 = Counter32: 0 IF-MIB::ifInOctets.7 = Counter32: 366410037 IF-MIB::ifInUcastPkts.1 = Counter32: 0 IF-MIB::ifInUcastPkts.2 = Counter32: 0 IF-MIB::ifInUcastPkts.3 = Counter32: 690808545 IF-MIB::ifInUcastPkts.4 = Counter32: 0 IF-MIB::ifInUcastPkts.5 = Counter32: 2227623 IF-MIB::ifInUcastPkts.6 = Counter32: 0 IF-MIB::ifInUcastPkts.7 = Counter32: 442395578 IF-MIB::ifInNUcastPkts.1 = Counter32: 0 IF-MIB::ifInNUcastPkts.2 = Counter32: 0 IF-MIB::ifInNUcastPkts.3 = Counter32: 102323 IF-MIB::ifInNUcastPkts.4 = Counter32: 0 IF-MIB::ifInNUcastPkts.5 = Counter32: 0 IF-MIB::ifInNUcastPkts.6 = Counter32: 0 IF-MIB::ifInNUcastPkts.7 = Counter32: 0 IF-MIB::ifInDiscards.1 = Counter32: 0 IF-MIB::ifInDiscards.2 = Counter32: 0 IF-MIB::ifInDiscards.3 = Counter32: 0 IF-MIB::ifInDiscards.4 = Counter32: 0 IF-MIB::ifInDiscards.5 = Counter32: 0 IF-MIB::ifInDiscards.6 = Counter32: 0 IF-MIB::ifInDiscards.7 = Counter32: 0 IF-MIB::ifInErrors.1 = Counter32: 0 IF-MIB::ifInErrors.2 = Counter32: 0 IF-MIB::ifInErrors.3 = Counter32: 0 IF-MIB::ifInErrors.4 = Counter32: 0 IF-MIB::ifInErrors.5 = Counter32: 0 IF-MIB::ifInErrors.6 = Counter32: 0 IF-MIB::ifInErrors.7 = Counter32: 0 IF-MIB::ifInUnknownProtos.1 = Counter32: 0 IF-MIB::ifInUnknownProtos.2 = Counter32: 0 IF-MIB::ifInUnknownProtos.3 = Counter32: 0 IF-MIB::ifInUnknownProtos.4 = Counter32: 0 IF-MIB::ifInUnknownProtos.5 = Counter32: 0 IF-MIB::ifInUnknownProtos.6 = Counter32: 0 IF-MIB::ifInUnknownProtos.7 = Counter32: 0 IF-MIB::ifOutOctets.1 = Counter32: 0 IF-MIB::ifOutOctets.2 = Counter32: 0 IF-MIB::ifOutOctets.3 = Counter32: 1273420647 IF-MIB::ifOutOctets.4 = Counter32: 0 IF-MIB::ifOutOctets.5 = Counter32: 906978574 IF-MIB::ifOutOctets.6 = Counter32: 0 IF-MIB::ifOutOctets.7 = Counter32: 3548324143 IF-MIB::ifOutUcastPkts.1 = Counter32: 0 IF-MIB::ifOutUcastPkts.2 = Counter32: 0 IF-MIB::ifOutUcastPkts.3 = Counter32: 444217663 IF-MIB::ifOutUcastPkts.4 = Counter32: 0 IF-MIB::ifOutUcastPkts.5 = Counter32: 1821603 IF-MIB::ifOutUcastPkts.6 = Counter32: 0 IF-MIB::ifOutUcastPkts.7 = Counter32: 689286394 IF-MIB::ifOutNUcastPkts.1 = Counter32: 0 IF-MIB::ifOutNUcastPkts.2 = Counter32: 0 IF-MIB::ifOutNUcastPkts.3 = Counter32: 0 IF-MIB::ifOutNUcastPkts.4 = Counter32: 0 IF-MIB::ifOutNUcastPkts.5 = Counter32: 0 IF-MIB::ifOutNUcastPkts.6 = Counter32: 0 IF-MIB::ifOutNUcastPkts.7 = Counter32: 0 IF-MIB::ifOutDiscards.1 = Counter32: 0 IF-MIB::ifOutDiscards.2 = Counter32: 0 IF-MIB::ifOutDiscards.3 = Counter32: 3959 IF-MIB::ifOutDiscards.4 = Counter32: 0 IF-MIB::ifOutDiscards.5 = Counter32: 0 IF-MIB::ifOutDiscards.6 = Counter32: 0 IF-MIB::ifOutDiscards.7 = Counter32: 0 IF-MIB::ifOutErrors.1 = Counter32: 0 IF-MIB::ifOutErrors.2 = Counter32: 0 IF-MIB::ifOutErrors.3 = Counter32: 0 IF-MIB::ifOutErrors.4 = Counter32: 0 IF-MIB::ifOutErrors.5 = Counter32: 0 IF-MIB::ifOutErrors.6 = Counter32: 4202246 IF-MIB::ifOutErrors.7 = Counter32: 0 IF-MIB::ifOutQLen.1 = Gauge32: 0 IF-MIB::ifOutQLen.2 = Gauge32: 0 IF-MIB::ifOutQLen.3 = Gauge32: 500 IF-MIB::ifOutQLen.4 = Gauge32: 500 IF-MIB::ifOutQLen.5 = Gauge32: 0 IF-MIB::ifOutQLen.6 = Gauge32: 500 IF-MIB::ifOutQLen.7 = Gauge32: 0 IF-MIB::ifSpecific.1 = OID: SNMPv2-SMI::zeroDotZero IF-MIB::ifSpecific.2 = OID: SNMPv2-SMI::zeroDotZero IF-MIB::ifSpecific.3 = OID: SNMPv2-SMI::zeroDotZero IF-MIB::ifSpecific.4 = OID: SNMPv2-SMI::zeroDotZero IF-MIB::ifSpecific.5 = OID: SNMPv2-SMI::zeroDotZero IF-MIB::ifSpecific.6 = OID: SNMPv2-SMI::zeroDotZero IF-MIB::ifSpecific.7 = OID: SNMPv2-SMI::zeroDotZero
Extracte del fitxer:
-- the Interfaces group -- Implementation of the Interfaces group is mandatory for -- all systems. ifNumber OBJECT-TYPE SYNTAX INTEGER ACCESS read-only STATUS mandatory DESCRIPTION "The number of network interfaces (regardless of their current state) present on this system." ::= { interfaces 1 } -- the Interfaces table -- The Interfaces table contains information on the entity's -- interfaces. Each interface is thought of as being -- attached to a `subnetwork'. Note that this term should -- not be confused with `subnet' which refers to an -- addressing partitioning scheme used in the Internet suite -- of protocols. ifTable OBJECT-TYPE SYNTAX SEQUENCE OF IfEntry ACCESS not-accessible STATUS mandatory DESCRIPTION "A list of interface entries. The number of entries is given by the value of ifNumber." ::= { interfaces 2 } ifEntry OBJECT-TYPE SYNTAX IfEntry ACCESS not-accessible STATUS mandatory DESCRIPTION "An interface entry containing objects at the subnetwork layer and below for a particular interface." INDEX { ifIndex } ::= { ifTable 1 } IfEntry ::= SEQUENCE { ifIndex INTEGER, ifDescr DisplayString, ifType INTEGER, ifMtu INTEGER, ifSpeed Gauge, ifPhysAddress PhysAddress, ifAdminStatus INTEGER, ifOperStatus INTEGER, ifLastChange TimeTicks, ifInOctets Counter, ifInUcastPkts Counter, ifInNUcastPkts Counter, ifInDiscards Counter, ifInErrors Counter, ifInUnknownProtos Counter, ifOutOctets Counter, ifOutUcastPkts Counter, ifOutNUcastPkts Counter, ifOutDiscards Counter, ifOutErrors Counter, ifOutQLen Gauge, ifSpecific OBJECT IDENTIFIER } ifIndex OBJECT-TYPE SYNTAX INTEGER ACCESS read-only STATUS mandatory DESCRIPTION "A unique value for each interface. Its value ranges between 1 and the value of ifNumber. The value for each interface must remain constant at least from one re-initialization of the entity's network management system to the next re- initialization." ::= { ifEntry 1 } ifDescr OBJECT-TYPE SYNTAX DisplayString (SIZE (0..255)) ACCESS read-only STATUS mandatory DESCRIPTION "A textual string containing information about the interface. This string should include the name of the manufacturer, the product name and the version of the hardware interface." ::= { ifEntry 2 } ifType OBJECT-TYPE SYNTAX INTEGER { other(1), -- none of the following regular1822(2), hdh1822(3), ddn-x25(4), rfc877-x25(5), ethernet-csmacd(6), iso88023-csmacd(7), iso88024-tokenBus(8), iso88025-tokenRing(9), iso88026-man(10), starLan(11), proteon-10Mbit(12), proteon-80Mbit(13), hyperchannel(14), fddi(15), lapb(16), sdlc(17), ds1(18), -- T-1 e1(19), -- european equiv. of T-1 basicISDN(20), primaryISDN(21), -- proprietary serial propPointToPointSerial(22), ppp(23), softwareLoopback(24), eon(25), -- CLNP over IP [11] ethernet-3Mbit(26), nsip(27), -- XNS over IP slip(28), -- generic SLIP ultra(29), -- ULTRA technologies ds3(30), -- T-3 sip(31), -- SMDS frame-relay(32) } ACCESS read-only STATUS mandatory DESCRIPTION "The type of interface, distinguished according to the physical/link protocol(s) immediately `below' the network layer in the protocol stack." ::= { ifEntry 3 } ifMtu OBJECT-TYPE SYNTAX INTEGER ACCESS read-only STATUS mandatory DESCRIPTION "The size of the largest datagram which can be sent/received on the interface, specified in octets. For interfaces that are used for transmitting network datagrams, this is the size of the largest network datagram that can be sent on the interface." ::= { ifEntry 4 } ifSpeed OBJECT-TYPE SYNTAX Gauge ACCESS read-only STATUS mandatory DESCRIPTION "An estimate of the interface's current bandwidth in bits per second. For interfaces which do not vary in bandwidth or for those where no accurate estimation can be made, this object should contain the nominal bandwidth." ::= { ifEntry 5 } ifPhysAddress OBJECT-TYPE SYNTAX PhysAddress ACCESS read-only STATUS mandatory DESCRIPTION "The interface's address at the protocol layer immediately `below' the network layer in the protocol stack. For interfaces which do not have such an address (e.g., a serial line), this object should contain an octet string of zero length." ::= { ifEntry 6 } ifAdminStatus OBJECT-TYPE SYNTAX INTEGER { up(1), -- ready to pass packets down(2), testing(3) -- in some test mode } ACCESS read-write STATUS mandatory DESCRIPTION "The desired state of the interface. The testing(3) state indicates that no operational packets can be passed." ::= { ifEntry 7 } ifOperStatus OBJECT-TYPE SYNTAX INTEGER { up(1), -- ready to pass packets down(2), testing(3) -- in some test mode } ACCESS read-only STATUS mandatory DESCRIPTION "The current operational state of the interface. The testing(3) state indicates that no operational packets can be passed." ::= { ifEntry 8 } ifLastChange OBJECT-TYPE SYNTAX TimeTicks ACCESS read-only STATUS mandatory DESCRIPTION "The value of sysUpTime at the time the interface entered its current operational state. If the current state was entered prior to the last re- initialization of the local network management subsystem, then this object contains a zero value." ::= { ifEntry 9 } ifInOctets OBJECT-TYPE SYNTAX Counter ACCESS read-only STATUS mandatory DESCRIPTION "The total number of octets received on the interface, including framing characters." ::= { ifEntry 10 } ifInUcastPkts OBJECT-TYPE SYNTAX Counter ACCESS read-only STATUS mandatory DESCRIPTION "The number of subnetwork-unicast packets delivered to a higher-layer protocol." ::= { ifEntry 11 } ifInNUcastPkts OBJECT-TYPE SYNTAX Counter ACCESS read-only STATUS mandatory DESCRIPTION "The number of non-unicast (i.e., subnetwork- broadcast or subnetwork-multicast) packets delivered to a higher-layer protocol." ::= { ifEntry 12 } ifInDiscards OBJECT-TYPE SYNTAX Counter ACCESS read-only STATUS mandatory DESCRIPTION "The number of inbound packets which were chosen to be discarded even though no errors had been detected to prevent their being deliverable to a higher-layer protocol. One possible reason for discarding such a packet could be to free up buffer space." ::= { ifEntry 13 } ifInErrors OBJECT-TYPE SYNTAX Counter ACCESS read-only STATUS mandatory DESCRIPTION "The number of inbound packets that contained errors preventing them from being deliverable to a higher-layer protocol." ::= { ifEntry 14 } ifInUnknownProtos OBJECT-TYPE SYNTAX Counter ACCESS read-only STATUS mandatory DESCRIPTION "The number of packets received via the interface which were discarded because of an unknown or unsupported protocol." ::= { ifEntry 15 } ifOutOctets OBJECT-TYPE SYNTAX Counter ACCESS read-only STATUS mandatory DESCRIPTION "The total number of octets transmitted out of the interface, including framing characters." ::= { ifEntry 16 } ifOutUcastPkts OBJECT-TYPE SYNTAX Counter ACCESS read-only STATUS mandatory DESCRIPTION "The total number of packets that higher-level protocols requested be transmitted to a subnetwork-unicast address, including those that were discarded or not sent." ::= { ifEntry 17 } ifOutNUcastPkts OBJECT-TYPE SYNTAX Counter ACCESS read-only STATUS mandatory DESCRIPTION "The total number of packets that higher-level protocols requested be transmitted to a non- unicast (i.e., a subnetwork-broadcast or subnetwork-multicast) address, including those that were discarded or not sent." ::= { ifEntry 18 } ifOutDiscards OBJECT-TYPE SYNTAX Counter ACCESS read-only STATUS mandatory DESCRIPTION "The number of outbound packets which were chosen to be discarded even though no errors had been detected to prevent their being transmitted. One possible reason for discarding such a packet could be to free up buffer space." ::= { ifEntry 19 } ifOutErrors OBJECT-TYPE SYNTAX Counter ACCESS read-only STATUS mandatory DESCRIPTION "The number of outbound packets that could not be transmitted because of errors." ::= { ifEntry 20 } ifOutQLen OBJECT-TYPE SYNTAX Gauge ACCESS read-only STATUS mandatory DESCRIPTION "The length of the output packet queue (in packets)." ::= { ifEntry 21 } ifSpecific OBJECT-TYPE SYNTAX OBJECT IDENTIFIER ACCESS read-only STATUS mandatory DESCRIPTION "A reference to MIB definitions specific to the particular media being used to realize the interface. For example, if the interface is realized by an ethernet, then the value of this object refers to a document defining objects specific to ethernet. If this information is not present, its value should be set to the OBJECT IDENTIFIER { 0 0 }, which is a syntatically valid object identifier, and any conformant implementation of ASN.1 and BER must be able to generate and recognize this value." ::= { ifEntry 22 }
$ snmptranslate .1.3.6.1.2.1.4 IP-MIB::ip
Està dins de mib-2
$ snmptranslate .1.3.6.1.2.1 SNMPv2-SMI::mib-2
Exemple:
IP-MIB::ipForwarding.0 = INTEGER: forwarding(1) IP-MIB::ipDefaultTTL.0 = INTEGER: 255 IP-MIB::ipAdEntAddr.10.36.253.1 = IpAddress: 10.36.253.1 IP-MIB::ipAdEntAddr.10.36.253.65 = IpAddress: 10.36.253.65 IP-MIB::ipAdEntAddr.10.36.253.97 = IpAddress: 10.36.253.97 IP-MIB::ipAdEntAddr.172.16.134.18 = IpAddress: 172.16.134.18 IP-MIB::ipAdEntAddr.172.16.135.5 = IpAddress: 172.16.135.5 IP-MIB::ipAdEntAddr.172.16.135.26 = IpAddress: 172.16.135.26 IP-MIB::ipAdEntAddr.172.16.135.94 = IpAddress: 172.16.135.94 IP-MIB::ipAdEntIfIndex.10.36.253.1 = INTEGER: 9 IP-MIB::ipAdEntIfIndex.10.36.253.65 = INTEGER: 3 IP-MIB::ipAdEntIfIndex.10.36.253.97 = INTEGER: 4 IP-MIB::ipAdEntIfIndex.172.16.134.18 = INTEGER: 9 IP-MIB::ipAdEntIfIndex.172.16.135.5 = INTEGER: 18 IP-MIB::ipAdEntIfIndex.172.16.135.26 = INTEGER: 14 IP-MIB::ipAdEntIfIndex.172.16.135.94 = INTEGER: 1 IP-MIB::ipAdEntNetMask.10.36.253.1 = IpAddress: 255.255.255.224 IP-MIB::ipAdEntNetMask.10.36.253.65 = IpAddress: 255.255.255.224 IP-MIB::ipAdEntNetMask.10.36.253.97 = IpAddress: 255.255.255.224 IP-MIB::ipAdEntNetMask.172.16.134.18 = IpAddress: 255.255.255.252 IP-MIB::ipAdEntNetMask.172.16.135.5 = IpAddress: 255.255.255.252 IP-MIB::ipAdEntNetMask.172.16.135.26 = IpAddress: 255.255.255.252 IP-MIB::ipAdEntNetMask.172.16.135.94 = IpAddress: 255.255.255.252 IP-MIB::ipAdEntBcastAddr.10.36.253.1 = INTEGER: 1 IP-MIB::ipAdEntBcastAddr.10.36.253.65 = INTEGER: 1 IP-MIB::ipAdEntBcastAddr.10.36.253.97 = INTEGER: 1 IP-MIB::ipAdEntBcastAddr.172.16.134.18 = INTEGER: 1 IP-MIB::ipAdEntBcastAddr.172.16.135.5 = INTEGER: 1 IP-MIB::ipAdEntBcastAddr.172.16.135.26 = INTEGER: 1 IP-MIB::ipAdEntBcastAddr.172.16.135.94 = INTEGER: 1 IP-MIB::ipAdEntReasmMaxSize.10.36.253.1 = INTEGER: 65535 IP-MIB::ipAdEntReasmMaxSize.10.36.253.65 = INTEGER: 65535 IP-MIB::ipAdEntReasmMaxSize.10.36.253.97 = INTEGER: 65535 IP-MIB::ipAdEntReasmMaxSize.172.16.134.18 = INTEGER: 65535 IP-MIB::ipAdEntReasmMaxSize.172.16.135.5 = INTEGER: 65535 IP-MIB::ipAdEntReasmMaxSize.172.16.135.26 = INTEGER: 65535 IP-MIB::ipAdEntReasmMaxSize.172.16.135.94 = INTEGER: 65535
$ snmptranslate .1.3.6.1.2.1.4.24 IP-FORWARD-MIB::ipForward
Per exemple este MIB es troba disponible a dispositius Mikrotik
IP-FORWARD-MIB::ipCidrRouteNumber.0 = Gauge32: 43 ::= { ipForward 6 }
$ locate IP-FORWARD-MIB /usr/share/mibs/ietf/IP-FORWARD-MIB /usr/share/snmp/mibs/IP-FORWARD-MIB.txt
Els commutadors han de tenir típicament:
Exemples
Monitoritzar l'estat d'un port:
Utilitzeu el OID ifOperStatus
-C public -o ifOperStatus.1 -c 1 -m RFC1213-MIB
Exemple executat sobre un rotuer mikrotik:
$ snmpget -Os -c public -v 2c 192.168.204.1 ipCidrRouteNumber.0 ipCidrRouteNumber.0 = Gauge32: 78
Mostra totes les rutes instal·lades inclus les no actives (les que apreixen en blau)
Exemple de router connectat a Internet (BGP Peering:)
$ snmpget -Os -c public -v 2c 10.90.126.129 ipCidrRouteNumber.0 ipCidrRouteNumber.0 = Gauge32: 462416
Consulteu AirOS#SNMP
El mib file el podeu trobar a:
http://www.mikrotik.com/download/Mikrotik.mib
utilitzant els enterprises:
enterprises.3495 ??? enterprises.14988
Segons registre ([1]):
14988 MikroTik John Tully tully&mikrotik.com 3495 National Laboratory for Applied Network Research Duane Wessels wessels&ircache.net
Segons la documentació suporta els següents MIB:
MIKROTIK-MIB MIB-2 HOST-RESOURCES-MIB IF-MIB IP-MIB IP-FORWARD-MIB IPV6-MIB BRIDGE-MIB DHCP-SERVER-MIB CISCO-AAA-SESSION-MIB ENTITY-MIB UPS-MIB SQUID-MIB
Recursos:
Aquest routers tenen accés telnet:
$ telnet ip_router_adsl Copyright (c) 1994 - 2005 ZyXEL Communications Corp. Prestige 660HW-61 Main Menu Getting Started Advanced Management 1. General Setup 21. Filter Set Configuration 2. WAN Backup Setup 22. SNMP Configuration 3. LAN Setup 23. System Security 4. Internet Access Setup 24. System Maintenance 25. IP Routing Policy Setup Advanced Applications 26. Schedule Setup 11. Remote Node Setup 12. Static Routing Setup 14. Dial-in User Setup 99. Exit 15. NAT Setup Enter Menu Selection Number:
Seleccionem l'opció 22':
Menu 22 - SNMP Configuration SNMP: Get Community= public Set Community= public Trusted Host= 0.0.0.0 Trap: Community= public Destination= 0.0.0.0 Press ENTER to Confirm or ESC to Cancel:
Com podeu veure ja porten SNMP activat per defecte amb les community típiques.
Vegeu també Munin#Plugin SNMP
<?php $snmp_values = snmpwalk("10.0.0.1", "public", null); print_r($snmp_values); ?>
Gràfiques:
http://jpgraph.net/?gclid=CLWnjMLQsroCFe7HtAodHngAuA
Recursos:
Exemple pas a pas per crear gràfiques RRD amb PHP i RRDTool
http://www.juros.hr/codeigniter/codeigniter-rrdtool-library/
IMPORTANT: En versions més modernes (trobat al SNMP d'Ubuntu 11.10) el que cal modificar és el fitxer /etc/snmp/snmpd.conf
# # AGENT BEHAVIOUR # # Listen for connections from the local system only #agentAddress udp:127.0.0.1:161 # Listen for connections on all interfaces (both IPv4 *and* IPv6) agentAddress udp:161,udp6:[::1]:161
Si noteu que només podeu accedir a SNMPD des de la màquina local i utilitzant localhost en comptes de la IP, aleshores és que SNMPD només s'està executant a la interfície loopback. Consulteu el fitxer:
$ cat /etc/default/snmpd # This file controls the activity of snmpd and snmptrapd # MIB directories. /usr/share/snmp/mibs is the default, but # including it here avoids some strange problems. export MIBDIRS=/usr/share/snmp/mibs # snmpd control (yes means start daemon). SNMPDRUN=yes # snmpd options (use syslog, close stdin/out/err). SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1' # snmptrapd control (yes means start daemon). As of net-snmp version # 5.0, master agentx support must be enabled in snmpd before snmptrapd # can be run. See snmpd.conf(5) for how to do this. TRAPDRUN=no # snmptrapd options (use syslog). TRAPDOPTS='-Lsd -p /var/run/snmptrapd.pid' # create symlink on Debian legacy location to official RFC path SNMPDCOMPAT=yes
Per seguretat, el dimoni per defecte és carrega per escoltar només a localhost. Canvieu la línia:
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'
per:
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid'
I torneu a iniciar SNMPD:
$ sudo /etc/init.d/snmpd restart
A mi m'ha passat a una Ubuntu 11.10 instal·lant el paquet snmp:
$ dpkg -l | grep snmp ii snmp 5.4.3~dfsg-2.2ubuntu1 SNMP (Simple Network Management Protocol) applications
Per exemple l'ordre:
$ snmpwalk -Os -v1 -c public 10.139.221.99 ifDescr ifDescr: Unknown Object Identifier (Sub-id not found: (top) -> ifDescr)
En canvi posant el OID equivalent a ifDescr (.1.3.6.1.2.1.2.2.1.2) funciona correctament, mostrant el nom de les interfícies de xarxa:
$ snmpwalk -v1 -c public 10.139.221.99 .1.3.6.1.2.1.2.2.1.2 iso.3.6.1.2.1.2.2.1.2.1 = STRING: "lo" iso.3.6.1.2.1.2.2.1.2.2 = STRING: "gre0" iso.3.6.1.2.1.2.2.1.2.3 = STRING: "eth0" iso.3.6.1.2.1.2.2.1.2.4 = STRING: "eth1" iso.3.6.1.2.1.2.2.1.2.5 = STRING: "br0" iso.3.6.1.2.1.2.2.1.2.6 = STRING: "wifi0" iso.3.6.1.2.1.2.2.1.2.7 = STRING: "ath0"
NOTA: A l'exemple la IP 10.139.221.99 és una nanostation de Ubiquiti
Segons lo indicat a:
http://www.mail-archive.com/[email protected]/msg09236.html
Indiquen que és un problema de que la comanda snmpwalk no troba els fitxers MIB. Amb l'opció -Dparse-mibs veurem els detalls de on busca els MIBS
No log handling enabled - turning on stderr logging registered debug token parse-mibs, 1 parse-mibs: Scanning directory /home/sergi/.snmp/mibs parse-mibs: No index parse-mibs: cannot open MIB directory /home/sergi/.snmp/mibs parse-mibs: Scanning directory /usr/share/mibs/site parse-mibs: No index parse-mibs: cannot open MIB directory /usr/share/mibs/site parse-mibs: Scanning directory /usr/share/snmp/mibs parse-mibs: No index parse-mibs: cannot open MIB directory /usr/share/snmp/mibs parse-mibs: Scanning directory /usr/share/mibs/iana parse-mibs: No index parse-mibs: cannot open MIB directory /usr/share/mibs/iana parse-mibs: Scanning directory /usr/share/mibs/ietf parse-mibs: No index parse-mibs: cannot open MIB directory /usr/share/mibs/ietf parse-mibs: Scanning directory /usr/share/mibs/netsnmp parse-mibs: No index parse-mibs: Checking file: /usr/share/mibs/netsnmp/NET-SNMP-SYSTEM-MIB... parse-mibs: Module 0 NET-SNMP-SYSTEM-MIB is in /usr/share/mibs/netsnmp/NET-SNMP-SYSTEM-MIB
Segons el bug d'Ubuntu:
https://bugs.launchpad.net/ubuntu/+source/net-snmp/+bug/662578
Les taules MIBs ja no es troben incloses a Debian i/o Ubuntu per que tenen una llicència restrictiva (són non-free). Per obtenir les taules MIB cal instal·lar el paquet:
$ sudo apt-get install snmp-mibs-downloader
Un cop instal·lat aquest paquet cal modificar el fitxer /etc/snmp/snmp.conf
$ sudo joe /etc/snmp/snmp.conf
I canviar-lo de:
# # As the snmp packages come without MIB files due to license reasons, loading # of MIBs is disabled by default. If you added the MIBs you can reenable # loaging them by commenting out the following line. mibs :
a:
# # As the snmp packages come without MIB files due to license reasons, loading # of MIBs is disabled by default. If you added the MIBs you can reenable # loaging them by commenting out the following line. #mibs :
Per exemple:
$ snmpwalk -m +FROGFOOT-RESOURCES-MIB -v1 -c public 10.139.221.99 . MIB search path: /home/sergi/.snmp/mibs:/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp Cannot find module (FROGFOOT-RESOURCES-MIB): At line 1 in (none)
Normalment això indica que no està instal·lat el MIB que pertoca. A l'exemple falta el MIB de FROGFOOT-RESOURCES-MIB.
Segons el FAQ:
/usr/share/doc/libsnmp-base/FAQ
What does "Cannot find module (XXX-MIB)" mean? --------------------------------------------- If this error is only generated for one or two modules, then it's likely that the named modules are not being found - perhaps they're not installed in the correct location, are not readable, or the name being used is incorrect. See the previous entries and the entry "How do I add a MIB to the tools?" for more details. Note that the name reported is the name of the MIB *module*, which is not necessarily the same as the name of the file. If there are a large number of such errors, then it's more likely that either the MIB files haven't been installed at all. If you are compiling from source, then it is necessary to run "make install" in order to set up the full run-time environment. Otherwise, see the previous entry to check whether the MIBs are installed in the correct location for the tools to find them. Vegeu com afegir el MIB a: SNMP#Com_s.27afegeix_un_MIB
NOTA: Tingueu en compte també l'opció -m ALL??!!
Per exemple em va passar fent un snmpwalk a una nanostation amb AirOS.
No és el mateix indicar epsecificament que es vol .1 que no posar res:
$ snmpwalk -v1 -c public 10.139.221.99 .1 | wc -l 256 $ snmpwalk -v1 -c public 10.139.221.99 | wc -l 213
La clau està en:
Finally, if you can't see anything from *any* enterprise-specific tree, then this may be down to how you are asking for the information. By default, if "snmpwalk" is run without an explicitly starting OID, then it will display the contents of the 'mib-2' tree, containing most of the IETF-standard management information supported by the agent.
Obtingut del FAQ de net-snmp:
http://www.net-snmp.org/docs/FAQ.html
IMPORTANT: Per defecte, snmpwalk mostra només l'arbre mib-2 i per aquesta raó pot ser que no es mostrint totes les opcions. Demaneu com a OID el . i així mostrareu tot l'arbre!
IMPORTANT: Una segona opció pot ser estar utilitzant la configuració paranoid (sovint és la configuració per defecte)
Un exemple de com mostrar-ho absolutament tot (espero ;-)), observeru l'ús de l'opció -m ALL:
$ sudo snmpwalk -Os -v 1 -c public 192.168.140.111 . -m ALL
Tingueu en compte que si teniu un firewall com iptables cal obrir el port 161 del protocol UDP. Tenir una línia com la següent obre el port:
#Accés SNMP -A INPUT -i intranet -p udp -m udp --dport 161 -j ACCEPT