| 1 |
#!/bin/sh -f |
| 2 |
|
| 3 |
PLACE=".1.3.6.1.4.1.8072.2.255" # NET-SNMP-PASS-MIB::netSnmpPassExamples |
| 4 |
REQ="$2" # Requested OID |
| 5 |
|
| 6 |
# |
| 7 |
# Process SET requests by simply logging the assigned value |
| 8 |
# Note that such "assignments" are not persistent, |
| 9 |
# nor is the syntax or requested value validated |
| 10 |
# |
| 11 |
if [ "$1" = "-s" ]; then |
| 12 |
echo $* >> /tmp/passtest.log |
| 13 |
exit 0 |
| 14 |
fi |
| 15 |
|
| 16 |
# |
| 17 |
# GETNEXT requests - determine next valid instance |
| 18 |
# |
| 19 |
if [ "$1" = "-n" ]; then |
| 20 |
case "$REQ" in |
| 21 |
$PLACE| \ |
| 22 |
$PLACE.0| \ |
| 23 |
$PLACE.0.*| \ |
| 24 |
$PLACE.1) RET=$PLACE.1.0 ;; # netSnmpPassString.0 |
| 25 |
|
| 26 |
$PLACE.1.*| \ |
| 27 |
$PLACE.2| \ |
| 28 |
$PLACE.2.0| \ |
| 29 |
$PLACE.2.0.*| \ |
| 30 |
$PLACE.2.1| \ |
| 31 |
$PLACE.2.1.0| \ |
| 32 |
$PLACE.2.1.0.*| \ |
| 33 |
$PLACE.2.1.1| \ |
| 34 |
$PLACE.2.1.1.*| \ |
| 35 |
$PLACE.2.1.2| \ |
| 36 |
$PLACE.2.1.2.0) RET=$PLACE.2.1.2.1 ;; # netSnmpPassInteger.1 |
| 37 |
|
| 38 |
$PLACE.2.1.2.*| \ |
| 39 |
$PLACE.2.1.3| \ |
| 40 |
$PLACE.2.1.3.0) RET=$PLACE.2.1.3.1 ;; # netSnmpPassOID.1 |
| 41 |
|
| 42 |
$PLACE.2.*| \ |
| 43 |
$PLACE.3) RET=$PLACE.3.0 ;; # netSnmpPassTimeTicks.0 |
| 44 |
$PLACE.3.*| \ |
| 45 |
$PLACE.4) RET=$PLACE.4.0 ;; # netSnmpPassIpAddress.0 |
| 46 |
$PLACE.4.*| \ |
| 47 |
$PLACE.5) RET=$PLACE.5.0 ;; # netSnmpPassCounter.0 |
| 48 |
$PLACE.5.*| \ |
| 49 |
$PLACE.6) RET=$PLACE.6.0 ;; # netSnmpPassGauge.0 |
| 50 |
|
| 51 |
*) exit 0 ;; |
| 52 |
esac |
| 53 |
else |
| 54 |
# |
| 55 |
# GET requests - check for valid instance |
| 56 |
# |
| 57 |
case "$REQ" in |
| 58 |
$PLACE.1.0| \ |
| 59 |
$PLACE.2.1.2.1| \ |
| 60 |
$PLACE.2.1.3.1| \ |
| 61 |
$PLACE.3.0| \ |
| 62 |
$PLACE.4.0| \ |
| 63 |
$PLACE.5.0| \ |
| 64 |
$PLACE.6.0) RET=$REQ ;; |
| 65 |
*) exit 0 ;; |
| 66 |
esac |
| 67 |
fi |
| 68 |
|
| 69 |
# |
| 70 |
# "Process" GET* requests - return hard-coded value |
| 71 |
# |
| 72 |
echo "$RET" |
| 73 |
case "$RET" in |
| 74 |
$PLACE.1.0) echo "string"; echo "Life, the Universe, and Everything"; exit 0 ;; |
| 75 |
$PLACE.2.1.2.1) echo "integer"; echo "42"; exit 0 ;; |
| 76 |
$PLACE.2.1.3.1) echo "objectid"; echo "$PLACE.99"; exit 0 ;; |
| 77 |
$PLACE.3.0) echo "timeticks"; echo "363136200"; exit 0 ;; |
| 78 |
$PLACE.4.0) echo "ipaddress"; echo "127.0.0.1"; exit 0 ;; |
| 79 |
$PLACE.5.0) echo "counter"; echo "42"; exit 0 ;; |
| 80 |
$PLACE.6.0) echo "gauge"; echo "42"; exit 0 ;; |
| 81 |
*) echo "string"; echo "ack... $RET $REQ"; exit 0 ;; # Should not happen |
| 82 |
esac |