Post by Dave ShieldPost by Donald RussellI have net-snmp 5.3 on Linux and I've been able to use the "exec" and
"extend" config statements with great success.
"pass" on the other hand is driving me crazy... I can't get snmpwalk to
walk
Post by Donald Russellthe OID I specify at all...
What does your pass script look like?
First, my snmpd.local.conf file has:
pass .1.3.6.1.4.1.15966.1 /usr/local/bin/passtest
The passtest script is:
#!/bin/sh -f
PATH=$path:/bin:/usr/bin:/usr/ucb
PLACE=".1.3.6.1.4.1.15966.1"
REQ="$2"
echo "--- $(date) ---" >> /tmp/passtest.log
echo $* >> /tmp/passtest.log
case "$1" in
-s)
# snmpset
if [[ "$REQ" != "$PLACE.1" ]]; then
echo "not-writable"
else
TYPE=$3
shift 3
VALUE="$*"
RESULT=$(/usr/local/bin/cmm $VALUE)
echo "Set OID $REQ result: $RESULT" >> /tmp/passtest.log
fi
exit 0
;;
-n)
# getnext... REQ is the requested OID, return the next OID, or exit
if none.
case "$REQ" in
$PLACE) RET=$PLACE.1 ;;
$PLACE.0) RET=$PLACE.1 ;;
$PLACE.1) RET=$PLACE.2 ;;
*) exit 0 ;;
esac
;;
-g)
# get .. return the OID, type and value
case "$REQ" in
$PLACE) RET=$PLACE.1 ;;
*) RET=$REQ ;;
esac
;;
esac
# NOTE: snmpset already exited (above)
# Reply to get/getnext with three lines: OID, type, value
case "$RET" in
$PLACE.1) type="integer"; value="42" ;;
$PLACE.2) type="string"; value="life the universe and everything" ;;
*) type="string"; value="ack... $RET $REQ" ;;
esac
echo -e "\tRET=$RET; TYPE=$type; VALUE=$value" >> /tmp/passtest.log
echo "$RET"
echo $type
echo $value
exit 0
I have an alias for snmp* commands to include the -v -c and hostname parts -
I use localhost for testing
#snmpget .1.3.6.1.4.1.15966.1.1
SNMPv2-SMI::enterprises.15966.1.1 = No Such Instance currently exists at
this OID
Yet in my /tmp.passtest.log file I see
-g .1.3.6.1.4.1.15966.1.1
RET=.1.3.6.1.4.1.15966.1.1; TYPE=integer; VALUE=42
So the script was invoked
#snmpwalk .1.3.6.1.4.1.15966.1
SNMPv2-SMI::enterprises.15966.1 = No Such Instance currently exists at this
OID
I think I'm missing something very basic. :-(
Post by Dave ShieldRemember that "exec" and "extend" scripts are SNMP-ignorant.
You can run arbitrary commands here, and the agent will report
back the output - applying a suitable MIB framework to structure this.
Yes, I use "extend" to get some read-only data, works great, and couldn't be
simpler to get working with snmp.
Post by Dave Shield"pass", on the other hand, can be used to report back information
in a user-defined structure. The price for this is that it does needs
to know about SNMP processing, and there is a very clearly defined
way of both invoking the command, and how it should return the results.
You can't simply use an arbitrary command with "pass", in the way that
you can with "exec" or "extend".
Post by Donald RussellBut, back to "extend"... I'd like to have an OID that I may both query
and
Post by Donald Russellset, and when I look at NET-SNMP-EXTEND-MIB it appears I can have a
"run-on-set" (2) value for nsExtendRunType...
How do I configure an extend config statement to support both snmpget and
snmpset?
Try using "extendFix" instead of "extend"
Post by Donald RussellOr, the man page says "extend" items can be added dynamically.... that
would
Post by Donald Russellbe great... I can have a system start up script dynamically add the
run-on-get and the run-on-set scripts. (Actually the same script, args
would
Post by Donald Russelldetermine action taken)
That would use SET requests to build up the entry in the
nsExtendConfigTable.
Try configuring a row using "extend", and walk this table to see what the
entry looks like. Then use "snmpset" with equivalent varbinds (and an
nsExtendStatus value of 'createAndGo')
Post by Donald RussellWhen the script is run due to run-on-set, is the new value simply passed
as
Post by Donald Russellthe args or is it more structured than that?
It's actually simpler than that.
When the nsExtendRunType instance is set to 'run-command(3)',
then the corresponding nsExtendCommand is invoked (using the
arguments from nsExtendArgs and input from nsExtendInput).
The "new value" for nsExtendRunType is never actually used
(other than as a trigger for invoking the command). If you read
the nsExtendRunType instance again, it will still have the value
'run-on-set(2)'
Similar to "pass" which passes -s OID TYPE VALUE
No
Post by Dave Shield"pass" is SNMP-knowledgable (and runs a closely defined command)
"extend" is SNMP-ignorant (and can run an arbitrary command)
These are two very different approaches to extending the agent.
Don't try and equate the two.
I see them as evolutionary....
Seems we first had "exec" which allowed snmpget, but the order of things
would change if new ones were added or old ones removed.
Along comes extend... now the OID is indexed by a name instead of simply
enumerated from the config file
Then comes "pass"... here's an OID.... handle it.
I wonder why the authors didn't think it would be worthwhile for the extend
feature to accept the value specified on snmpset.
Thanks very much...