I have added the following 2 lines to my snmpd.conf file:
view all included .1.3.6.1.4.1.8072.9999.9999
pass_persist .1.3.6.1.4.1.8072.9999.9999 /root/kshtest
I have created a shell script (/root/kshtest) that takes a file, OIDDEFS, containing lines with each OID, its type, and its value (separated by a space):
.1.3.6.1.4.1.8072.9999.9999.1.1 integer 35
.1.3.6.1.4.1.8072.9999.9999.1.2 integer 21
.1.3.6.1.4.1.8072.9999.9999.1.3 integer 56
.1.3.6.1.4.1.8072.9999.9999.2.1 integer 3592
.1.3.6.1.4.1.8072.9999.9999.2.2 integer 2234
.1.3.6.1.4.1.8072.9999.9999.2.3 integer 4499
.1.3.6.1.4.1.8072.9999.9999.2.4 integer 2233
.1.3.6.1.4.1.8072.9999.9999.3.1 integer 6650
.1.3.6.1.4.1.8072.9999.9999.3.2 integer 6650
.1.3.6.1.4.1.8072.9999.9999.3.3 integer 6650
.1.3.6.1.4.1.8072.9999.9999.3.4 integer 6650
.1.3.6.1.4.1.8072.9999.9999.4.1 integer 0
.1.3.6.1.4.1.8072.9999.9999.4.2 integer 0
.1.3.6.1.4.1.8072.9999.9999.4.3 integer 0
.1.3.6.1.4.1.8072.9999.9999.4.4 integer 0
.1.3.6.1.4.1.8072.9999.9999.4.5 integer 0
.1.3.6.1.4.1.8072.9999.9999.4.6 integer 0
.1.3.6.1.4.1.8072.9999.9999.4.7 integer 0
.1.3.6.1.4.1.8072.9999.9999.4.8 integer 0
.1.3.6.1.4.1.8072.9999.9999.4.9 integer 0
.1.3.6.1.4.1.8072.9999.9999.4.10 integer 0
.1.3.6.1.4.1.8072.9999.9999.4.11 integer 0
.1.3.6.1.4.1.8072.9999.9999.4.12 integer 0
and provides the following interaction when run from the command line:
<- PING
-> PONG
<- get
<- .1.3.6.1.4.1.8072.9999.9999.1.1
-> .1.3.6.1.4.1.8072.9999.9999.1.1
-> integer
-> 35
<- PING
-> PONG
<- getnext
<- .1.3.6.1.4.1.8072.9999.9999.1.1
-> .1.3.6.1.4.1.8072.9999.9999.1.2
-> integer
-> 21
The script's contents are as follows (but I think all you may need to know is that it works as shown above):
#!/usr/pkg/bin/ksh93
OIDDEFS=OIDDEFS
IFS=$'\n'
lines=($(< $OIDDEFS))
typeset -A gettype
typeset -A getvalue
typeset -A getnextoid
typeset -A getnexttype
typeset -A getnextvalue
for (( x=0; x<${#lines[*]}; ((x++)) ))
do IFS=$'\t\n '
words=($(echo ${lines[x]}))
gettype[${words[0]}]=${words[1]}
getvalue[${words[0]}]=$(printf "%i\n" ${words[2]})
if [[ x -gt 0 ]]; then
getnextoid[${lines[x-1]%% *}]=${words[0]}
getnexttype[${lines[x-1]%% *}]=${words[1]}
getnextvalue[${lines[x-1]%% *}]=$(printf "%i\n" ${words[2]})
fi
done
while true
do read
if [[ $REPLY == "PING" ]]; then
echo PONG
else
exit 1
fi
x=0
while [[ x -lt 2 ]];
do read REPLY$x
((x++))
done
if [[ $REPLY0 == get ]]; then
echo $REPLY1
echo ${gettype[$REPLY1]}
echo ${getvalue[$REPLY1]}
fi
if [[ $REPLY0 == getnext ]]; then
if [[ ! -v getnextoid[$REPLY1] ]]; then
echo NONE
else
echo ${getnextoid[$REPLY1]}
echo ${getnexttype[$REPLY1]}
echo ${getnextvalue[$REPLY1]}
fi
fi
done
I can run 'snmpd -f' (although I don't understand why it won't work without the -f flag) and do a
snmpgetnext -On -v 2c -c public 127.0.0.1 .1.3.6.1.4.1.8072.9999.9999.1.1
and get the response:
.1.3.6.1.4.1.8072.9999.9999.1.2 = INTEGER: 21
I can successfully snmpget (net-snmp command) any of the oids in my MIB and get their values or snmpgetnext any oid and get the next oid and value. However, I cannot snmpwalk my oids. When I
snmpwalk -On -v 2c -c public 127.0.0.1 .1.3.6.1.4.1.8072.9999.9999.1.1
I get
.1.3.6.1.4.1.8072.9999.9999.1.1 = INTEGER: 35
which is the same response I get from an snmpget on that oid.
snmpwalk -d -v 2c -c public 127.0.0.1 .1.3.6.1.4.1.8072.9999.9999.1.1
gives me:
Sending 48 bytes to UDP: [127.0.0.1]:161->[0.0.0.0]:0
0000: 30 2E 02 01 01 04 06 70 75 62 6C 69 63 A1 21 02 0......public.!.
0016: 04 7F 15 82 9A 02 01 00 02 01 00 30 13 30 11 06 ...........0.0..
0032: 0D 2B 06 01 04 01 BF 08 CE 0F CE 0F 01 01 05 00 .+..............
Received 49 byte packet from UDP: [127.0.0.1]:161->[0.0.0.0]:65489
0000: 30 2F 02 01 01 04 06 70 75 62 6C 69 63 A2 22 02 0/.....public.".
0016: 04 7F 15 82 9A 02 01 00 02 01 00 30 14 30 12 06 ...........0.0..
0032: 0D 2B 06 01 04 01 BF 08 CE 0F CE 0F 01 02 02 01 .+..............
0048: 15 .
Sending 48 bytes to UDP: [127.0.0.1]:161->[0.0.0.0]:0
0000: 30 2E 02 01 01 04 06 70 75 62 6C 69 63 A0 21 02 0......public.!.
0016: 04 7F 15 82 9B 02 01 00 02 01 00 30 13 30 11 06 ...........0.0..
0032: 0D 2B 06 01 04 01 BF 08 CE 0F CE 0F 01 01 05 00 .+..............
Received 49 byte packet from UDP: [127.0.0.1]:161->[0.0.0.0]:65489
0000: 30 2F 02 01 01 04 06 70 75 62 6C 69 63 A2 22 02 0/.....public.".
0016: 04 7F 15 82 9B 02 01 00 02 01 00 30 14 30 12 06 ...........0.0..
0032: 0D 2B 06 01 04 01 BF 08 CE 0F CE 0F 01 01 02 01 .+..............
0048: 23 #
NET-SNMP-MIB::monoCount = INTEGER: 35
which appears to be an snmpgetnext to .1.3.6.1.4.1.8072.9999.9999.1.1, followed by an snmpgetresponse referencing .1.3.6.1.4.1.8072.9999.9999.1.2, followed by an snmpget for .1.3.6.1.4.1.8072.9999.9999.1.1, followed by an snmpgetresponse referencing .1.3.6.1.4.1.8072.9999.9999.1.1.
My NET-SNMP-MIB.txt file, which I altered to add the MIB values is as follows:
NET-SNMP-MIB DEFINITIONS ::= BEGIN
--
-- Top-level infrastructure of the Net-SNMP project enterprise MIB tree
--
IMPORTS
MODULE-IDENTITY, Integer32, enterprises FROM SNMPv2-SMI;
netSnmp MODULE-IDENTITY
LAST-UPDATED "200201300000Z"
ORGANIZATION "www.net-snmp.org"
CONTACT-INFO
"postal: Wes Hardaker
P.O. Box 382
Davis CA 95617
email: net-snmp-coders@lists.sourceforge.net"
DESCRIPTION
"Top-level infrastructure of the Net-SNMP project enterprise MIB tree"
REVISION "200201300000Z"
DESCRIPTION
"First draft"
::= { enterprises 8072}
--
-- Net-SNMP enterprise-specific management objects
--
netSnmpObjects OBJECT IDENTIFIER ::= {netSnmp 1}
-- netSnmpExamples OBJECT IDENTIFIER ::= {netSnmp 2}
netSnmpEnumerations OBJECT IDENTIFIER ::= {netSnmp 3}
netSnmpModuleIDs OBJECT IDENTIFIER ::= {netSnmpEnumerations 1}
netSnmpAgentOIDs OBJECT IDENTIFIER ::= {netSnmpEnumerations 2}
netSnmpDomains OBJECT IDENTIFIER ::= {netSnmpEnumerations 3}
netSnmpExperimental OBJECT IDENTIFIER ::= {netSnmp 9999}
--
-- A subtree specifically designed for private testing purposes.
-- No "public" management objects should ever be defined within this tree.
--
-- It is provided for private experimentation, prior to transferring a MIB
-- structure to another part of the overall OID tree
--
netSnmpPlaypen OBJECT IDENTIFIER ::= {netSnmpExperimental 9999}
--
-- Notifications
--
netSnmpNotificationPrefix OBJECT IDENTIFIER ::= {netSnmp 4}
netSnmpNotifications OBJECT IDENTIFIER ::= {netSnmpNotificationPrefix 0}
netSnmpNotificationObjects OBJECT IDENTIFIER ::= {netSnmpNotificationPrefix 1}
--
-- Conformance
-- (No laughing at the back!)
--
netSnmpConformance OBJECT IDENTIFIER ::= {netSnmp 5}
netSnmpCompliances OBJECT IDENTIFIER ::= {netSnmpConformance 1}
netSnmpGroups OBJECT IDENTIFIER ::= {netSnmpConformance 2}
-- start additions:
pageCountsVals OBJECT IDENTIFIER ::= {netSnmpPlaypen 1}
tonerLevelsVals OBJECT IDENTIFIER ::= {netSnmpPlaypen 2}
tonerLevelsMaxVals OBJECT IDENTIFIER ::= {netSnmpPlaypen 3}
otherRandomVals OBJECT IDENTIFIER ::= {netSnmpPlaypen 4}
monoCount OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DEFVAL { 0 }
::= {pageCountsVals 1}
colorCount OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DEFVAL { 0 }
::= {pageCountsVals 2}
totalCount OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DEFVAL { 0 }
::= {pageCountsVals 3}
cyanVal OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DEFVAL { 0 }
::= {tonerLevelsVals 1}
magentaVal OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DEFVAL { 0 }
::= {tonerLevelsVals 2}
yellowVal OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DEFVAL { 0 }
::= {tonerLevelsVals 3}
blackVal OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DEFVAL { 0 }
::= {tonerLevelsVals 4}
cyanMaxVal OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DEFVAL { 0 }
::= {tonerLevelsMaxVals 1}
magentaMaxVal OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DEFVAL { 0 }
::= {tonerLevelsMaxVals 2}
yellowMaxVal OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DEFVAL { 0 }
::= {tonerLevelsMaxVals 3}
blackMaxVal OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DEFVAL { 0 }
::= {tonerLevelsMaxVals 4}
randomVal1 OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DEFVAL { 0 }
::= {otherRandomVals 1}
randomVal2 OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DEFVAL { 0 }
::= {otherRandomVals 2}
randomVal3 OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DEFVAL { 0 }
::= {otherRandomVals 3}
randomVal4 OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DEFVAL { 0 }
::= {otherRandomVals 4}
randomVal5 OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DEFVAL { 0 }
::= {otherRandomVals 5}
randomVal6 OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DEFVAL { 0 }
::= {otherRandomVals 6}
randomVal7 OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DEFVAL { 0 }
::= {otherRandomVals 7}
randomVal8 OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DEFVAL { 0 }
::= {otherRandomVals 8}
randomVal9 OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DEFVAL { 0 }
::= {otherRandomVals 9}
randomVal10 OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DEFVAL { 0 }
::= {otherRandomVals 10}
randomVal11 OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DEFVAL { 0 }
::= {otherRandomVals 11}
randomVal12 OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DEFVAL { 0 }
::= {otherRandomVals 12}
END
I am hoping that this will give an experienced snmp'er enough info to see what I am doing wrong. If not, please ask. Thanks.