Month: September 2005

Criando um objeto MIB para o SNMP

Baixar o net-snmp e compilar:
./configure –prefix=/usr –sysconfdir=/etc
make
make install

Crie o arquivo UFRGS-MIB.txt:

UFRGS-MIB DEFINITIONS ::= BEGIN

IMPORTS
MODULE-IDENTITY, OBJECT-TYPE, Integer32,
Counter32, IpAddress, enterprises FROM SNMPv2-SMI
MODULE-COMPLIANCE, OBJECT-GROUP FROM SNMPv2-CONF;

— A brief description and update information about this mib.

ufrgs MODULE-IDENTITY
LAST-UPDATED “0104010000Z” — 01 Apr 2001, midnight
ORGANIZATION “UFRGS”
CONTACT-INFO
” Author: Alan Carvalho de Assis
UFRGS, Departamento de Engenharia Eletrica
Av. Oswaldo Aranha
Porto Alegre
BRAZIL
email: acassis@gmail.com
tel: +55-051-3316-3561″

DESCRIPTION “MIB for remote control by SNMP”
::= { enterprises 9362 }

— the led group
leds OBJECT IDENTIFIER ::= { ufrgs 1 }
reserved OBJECT IDENTIFIER::= { ufrgs 2 }


— LED 0 connected to the PC parallel port

led0 OBJECT-TYPE
SYNTAX Integer32 (0..1)
MAX-ACCESS read-write
STATUS current
DESCRIPTION
“Led 0 connected to bit 0 of the PC parallel port.”
DEFVAL { 0 }
::= { leds 1 }


— LED 1 connected to the PC parallel port

led1 OBJECT-TYPE
SYNTAX Integer32 (0..1)
MAX-ACCESS read-write
STATUS current
DESCRIPTION
“Led 1 connected to bit 0 of the PC parallel port.”
DEFVAL { 0 }
::= { leds 2 }


— LED 2 connected to the PC parallel port

led2 OBJECT-TYPE
SYNTAX Integer32 (0..1)
MAX-ACCESS read-write
STATUS current
DESCRIPTION
“Led 2 connected to bit 0 of the PC parallel port.”
DEFVAL { 0 }
::= { leds 3 }


— LED 3 connected to the PC parallel port

led3 OBJECT-TYPE
SYNTAX Integer32 (0..1)
MAX-ACCESS read-write
STATUS current
DESCRIPTION
“Led 3 connected to bit 0 of the PC parallel port.”
DEFVAL { 0 }
::= { leds 4 }


— LED 4 connected to the PC parallel port

led4 OBJECT-TYPE
SYNTAX Integer32 (0..1)
MAX-ACCESS read-write
STATUS current
DESCRIPTION
“Led 4 connected to bit 0 of the PC parallel port.”
DEFVAL { 0 }
::= { leds 5 }


— LED 5 connected to the PC parallel port

led5 OBJECT-TYPE
SYNTAX Integer32 (0..1)
MAX-ACCESS read-write
STATUS current
DESCRIPTION
“Led 5 connected to bit 0 of the PC parallel port.”
DEFVAL { 0 }
::= { leds 6 }


— LED 6 connected to the PC parallel port

led6 OBJECT-TYPE
SYNTAX Integer32 (0..1)
MAX-ACCESS read-write
STATUS current
DESCRIPTION
“Led 6 connected to bit 0 of the PC parallel port.”
DEFVAL { 0 }
::= { leds 7 }


— LED 7 connected to the PC parallel port

led7 OBJECT-TYPE
SYNTAX Integer32 (0..1)
MAX-ACCESS read-write
STATUS current
DESCRIPTION
“Led 7 connected to bit 0 of the PC parallel port.”
DEFVAL { 0 }
::= { leds 8 }

END

Salve como o nome de UFRGS-MIB.txt e copie para /usr/share/snmp/mibs

Verifique se esta correto:
# snmptranslate -m +UFRGS-MIB -IR ufrgs

Instale o mib2c:
# cd ~/net-snmp
# cd perl
# cd default_store
# perl Makefile.PL
# make
# make install
# cd ..
# cd SNMP
# perl Makefile.PL
# make
# make install

Então vá para o diretório de instalação net-snmp/agent/mibgroup e execute:
# env MIBS=”+UFRGS-MIB” mib2c -c ../../local/mib2c.scalar.conf ufrgs

Recompile o snmp com suporte ao MIB ufrgs:
# cd ~/net-snmp
#./configure –prefix=/usr –sysconfdir=/etc –with-mib-modules=ufrgs

Acender o primeiro LED:
# snmpset -c led -v 1 -m +UFRGS-MIB 10.1.240.246 led0.0 i 1
ou
# snmpset -c led -v 1 10.1.240.246 1.3.6.1.4.1.9362.1.1.0 i 1

Apagar o primeiro LED:
# snmpset -c led -v 1 -m +UFRGS-MIB 10.1.240.246 led0.0 i 0
ou
# snmpset -c led -v 1 10.1.240.246 1.3.6.1.4.1.9362.1.1.0 i 0

Advertisements