miércoles, 24 de febrero de 2010

Compilar MIBs en Linux. Paso a Paso

0 comentarios, Publicado por Covent en 9:57 ,
En el presente caso utilizaremos unos MIBs de Cisco sin embargo el procedimiento es el mismo para cualquier otro MIBs.

Software necesario:
Necesitamos instalar net-snmp en nuestro equipo Linux. En mi caso con Mandriva:
urpmi snmp-devel

Tambien vamos a necesitar la linea devel de net-snmp:
urpmi lib64net-snmp-devel

Procedimiento:
1) Averiguar donde SNMP almacena los repositorios MIBS:
net-snmp-config --default-mibdirs

2) Bajar los MIBS que queremos implementar. En este caso hay que tener mucho cuidado con los MIBS bajados en Internet, es importante que sean archivos de texto y que en la parte superior solo tengan comentarios y luego (como primera linea válida) contenga algo similar a: CISCO-RHINO-MIB DEFINITIONS ::= BEGIN" y la última linea debe decir END.
En el siguiente ejemplo bajaremos los siguientes MIBs:
ftp://ftp.cisco.com/pub/mibs/v2/CISCO-RHINO-MIB.my
ftp://ftp.cisco.com/pub/mibs/v2/CISCO-SMI.my

3) Copiar los MIBS en alguno de los directorios resultantes de: net-snmp-config --default-mibdirs
Por ejemplo:

cp /tmp/CISCO-*.my /usr/share/snmp/mibs

4) Ubicar el archivo de configuración global para snmp (no snmpd!)
Para mandriva: /etc/snmp/snmp.local.conf y agregar al final del archivo las siguientes lineas:

mibs +CISCO-RHINO-MIB
mibs +CISCO-SMI

5) Probar que los MIBs recien instalados funcionen:

[root@localhost ~]# snmptranslate -IR -On ciscoLS1010ChassisFanLed
.1.3.6.1.4.1.9.5.11.1.1.12

Comentarios:
Existe más de una manera de realizar la compilación de los MIBs en Linux, sin embargo yo solo quise mostrar una manera práctica, rápida y funcional de como realizar la tarea.

Links importantes:
El articulo arriba descrito es la suma de mi experiencia y de la traducción y resumen del articulo: http://www.net-snmp.org/wiki/index.php/TUT:Using_and_loading_MIBS

Via | AcostaNetowork

Realizar un ping en un equipo Cisco con SNMP

0 comentarios, Publicado por Covent en 9:49 ,
Objetivo:
Desde un equipo con Linux indicarle a un Routero LAN Switch Cisco que realice un ping a un destino

Motivo:
Pueden existir diversos motivos para realizar la tarea mencionada. Por ejemplo en este momento necesito revisar si en la tabla arp de un equipo se encuentra una MAC en especifico y no tengo acceso desde mi NMS.

Software necesario:
net-snmp
snmp-devel

Configuración del router Cisco:
Para llevar a cabo dicha tarea es necesario tener acceso RW vía SNMP al router. Por ejemplo en modo configuracion:
#snmp-server community acostanetwork RW

Script en Linux:
#!/bin/sh
###### We've chosen 333 at random. 333 will be the row instance to use for this particular
###### ping experiment. After the ping, the row will be deleted.
###### This keeps the table clean. Router_Source is the dns name of the device we are
###### working with, and public is its RW community string. The values for
###### ciscoPingEntryStatus status are as follows (see Ping MIB):

###### 1 - active
###### 2 - notInService
###### 3 - notReady
###### 4 - createAndGo
###### 5 - createAndWait
###### 6 - destroy

#DECLARACION DE LAS VARIABLES
COM="epale" #SNMP Community name
PINGER_ROUTER="10.3.4.5"
IP_TO_PING="0A 00 00 01" #The IP address to ping should be define in HEX
PACKET_COUNT=20
PACKET_SIZE=100

###### We will clear out any previous entries by setting ciscoPingEntryStatus = 6 (destroy)

snmpset -c $COM $PINGER_ROUTER .1.3.6.1.4.1.9.9.16.1.1.1.16.333 integer 6
###### We start building the row by setting ciscoPingEntryStatus = 5 (createAndWait)
echo

snmpset -c $COM $PINGER_ROUTER .1.3.6.1.4.1.9.9.16.1.1.1.16.333 integer 5

echo
echo "###### Now let's set the characteristics of the ping #######"

###### Only the first three sets below are REQUIRED. The rest have default
###### values.

#Set ciscoPingEntryOwner = any_name
snmpset -c $COM $PINGER_ROUTER .1.3.6.1.4.1.9.9.16.1.1.1.15.333 s anyname

#Set ciscoPingProtocol = 1 = ip (see CISCO-TC-V1SMI.my CiscoNetworkProtocol)
snmpset -c $COM $PINGER_ROUTER .1.3.6.1.4.1.9.9.16.1.1.1.2.333 i 1

#Set ciscoPingAddress = #.#.#.#--take Remote_Dest's ip & convert each octet to hex
snmpset -c $COM $PINGER_ROUTER .1.3.6.1.4.1.9.9.16.1.1.1.3.333 x "$IP_TO_PING"
#Set the packet count to 20 (ciscoPingPacketCount)
snmpset -c $COM $PINGER_ROUTER .1.3.6.1.4.1.9.9.16.1.1.1.4.333 i $PACKET_COUNT

#Set the packetsize to 100 (ciscoPingPacketSize)
snmpset -c $COM $PINGER_ROUTER .1.3.6.1.4.1.9.9.16.1.1.1.5.333 i $PACKET_SIZ

echo
echo "##### Now let's verify that the ping is ready to go and launch it #######"

#Get ciscoPingEntryStatus and make sure it is now equal to 2. This means
# notInService which indicates that we're ready to go.

snmpget -c $COM $PINGER_ROUTER .1.3.6.1.4.1.9.9.16.1.1.1.16.333

# Set ciscoPingEntryStatus = 1 to tell it to activate.

snmpset -c $COM $PINGER_ROUTER .1.3.6.1.4.1.9.9.16.1.1.1.16.333 integer 1

#Let's wait two seconds before looking the results
sleep 2

echo
echo "##### Let's look at the results. #####"

snmpwalk -c $COM $PINGER_ROUTER .1.3.6.1.4.1.9.9.16.1.1.1

echo

echo "##### Now that we've gotten the results, let's destroy the row #####"
snmpset -c $COM $PINGER_ROUTER .1.3.6.1.4.1.9.9.16.1.1.1.16.333 integer 6



Funcionamiento:
- Declarar las variables de manera correcta al comienzo del script
- Notese que existe un sleep en el script. Este sleep sirve para esperar 2 segundos antes de continuar a ver los resultados. Es importante debido a que si se ejecuta el script sin la pausa el router probablemente no tendrá tiempo de tener los resultados.
- Recomiendo (pero no es necesario) instalar los MIBs ubicados en: http://tools.cisco.com/Support/SNMP/do/BrowseMIB.do?local=en&mibName=CISCO-PING-MIB

Ejemplo de resultado (con MIBs compilados):
CISCO-PING-MIB::ciscoPingProtocol.333 1
CISCO-PING-MIB::ciscoPingAddress.333 "0A 00 00 01 "
CISCO-PING-MIB::ciscoPingPacketCount.333 20
CISCO-PING-MIB::ciscoPingPacketSize.333 100
CISCO-PING-MIB::ciscoPingPacketTimeout.333 2000
CISCO-PING-MIB::ciscoPingDelay.333 0
CISCO-PING-MIB::ciscoPingTrapOnCompletion.333 2
CISCO-PING-MIB::ciscoPingSentPackets.333 20
CISCO-PING-MIB::ciscoPingReceivedPackets.333 20
CISCO-PING-MIB::ciscoPingMinRtt.333 1
CISCO-PING-MIB::ciscoPingAvgRtt.333 1
CISCO-PING-MIB::ciscoPingMaxRtt.333 1
CISCO-PING-MIB::ciscoPingCompleted.333 1
CISCO-PING-MIB::ciscoPingEntryOwner.333 "anyname"
CISCO-PING-MIB::ciscoPingEntryStatus.333 1
CISCO-PING-MIB::ciscoPingVrfName.333 ""

He colocado en negrillas e itálicas algunos valores importantes

Link importantes:
http://www.scozzafava.com/scripts/remote-ping/
http://www.cisco.com/en/US/tech/tk648/tk362/technologies_tech_note09186a0080094e8e.shtml
http://tools.cisco.com/Support/SNMP/do/BrowseMIB.do?local=en&mibName=CISCO-PING-MI

Via | AcostaNetowork