/tmp/passtest

Aus Programmers Guide

(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
K
K
 
Zeile 1: Zeile 1:
-
<p><span class="fck_mw_source" _fck_mw_customtag="true" _fck_mw_tagname="source" lang="bash">fckLR#!/bin/sh -ffckLRfckLRPATH=$PATH:/bin:/usr/bin:/usr/ucbfckLRfckLR#Dieses Script verarbeitet welche OID?fckLRPLACE=&quot;.1.3.6.1.4.1.2021.255&quot;fckLRfckLR#Die übergebene OIDfckLRREQ=&quot;$2&quot;fckLRfckLR#Für SETfckLRif [ &quot;$1&quot; = &quot;-s&quot; ]; thenfckLR  echo $* &gt;&gt; /tmp/passtest.logfckLR  exit 0fckLRfifckLRfckLR#Für GETNEXTfckLRif [ &quot;$1&quot; = &quot;-n&quot; ]; thenfckLR  case &quot;$REQ&quot; infckLR    $PLACE)      RET=$PLACE.1 ;;fckLR    $PLACE.1)    RET=$PLACE.2.1 ;;fckLR    $PLACE.2.1)  RET=$PLACE.2.2 ;;fckLR    $PLACE.2.2)  RET=$PLACE.3 ;;fckLR    $PLACE.3)    RET=$PLACE.4 ;;fckLR    $PLACE.4)    RET=$PLACE.5 ;;fckLR    $PLACE.5)    RET=$PLACE.6 ;;fckLR    *)          exit 0 ;;fckLR  esacfckLRelsefckLR  case &quot;$REQ&quot; infckLR    $PLACE)    exit 0 ;;fckLR    *)        RET=$REQ ;;fckLR  esacfckLRfifckLRfckLR#Für GETfckLRecho &quot;$RET&quot;fckLRcase &quot;$RET&quot; infckLR  $PLACE.1) echo &quot;string&quot;; echo &quot;life the universe and everything&quot;; exit 0 ;;fckLR  $PLACE.2.1) echo &quot;integer&quot;; echo &quot;42&quot;; exit 0 ;;fckLR  $PLACE.2.2) echo &quot;objectid&quot;; echo &quot;.1.3.6.1.4.42.42.42&quot;; exit 0 ;;fckLR  $PLACE.3) echo &quot;timeticks&quot;; echo &quot;363136200&quot;; exit 0 ;;fckLR  $PLACE.4) echo &quot;ipaddress&quot;; echo &quot;127.0.0.1&quot; ;;fckLR  $PLACE.5) echo &quot;counter&quot;; echo &quot;42&quot;; exit 0 ;;fckLR  $PLACE.6) echo &quot;gauge&quot;; echo &quot;42&quot;; exit 0 ;;fckLR  *) echo &quot;string&quot;; echo &quot;ack... $RET $REQ&quot;; exit 0 ;;fckLResacfckLRfckLRfckLR</span>  
+
<source lang="bash">
-
</p><p><a _fcknotitle="true" href="Snmpd.conf">Snmpd.conf</a>
+
#!/bin/sh -f
-
</p><a _fcknotitle="true" href="Category:Ubuntu">Ubuntu</a> <a _fcknotitle="true" href="Category:Bash">Bash</a> <a _fcknotitle="true" href="Category:SNMP">SNMP</a>
+
 
 +
PATH=$PATH:/bin:/usr/bin:/usr/ucb
 +
 
 +
#Dieses Script verarbeitet welche OID?
 +
PLACE=".1.3.6.1.4.1.2021.255"
 +
 
 +
#Die übergebene OID
 +
REQ="$2"
 +
 
 +
#Für SET
 +
if [ "$1" = "-s" ]; then
 +
  echo $* >> /tmp/passtest.log
 +
  exit 0
 +
fi
 +
 
 +
#Für GETNEXT
 +
if [ "$1" = "-n" ]; then
 +
  case "$REQ" in
 +
    $PLACE)      RET=$PLACE.1 ;;
 +
    $PLACE.1)    RET=$PLACE.2.1 ;;
 +
    $PLACE.2.1)  RET=$PLACE.2.2 ;;
 +
    $PLACE.2.2)  RET=$PLACE.3 ;;
 +
    $PLACE.3)    RET=$PLACE.4 ;;
 +
    $PLACE.4)    RET=$PLACE.5 ;;
 +
    $PLACE.5)    RET=$PLACE.6 ;;
 +
    *)          exit 0 ;;
 +
  esac
 +
else
 +
  case "$REQ" in
 +
    $PLACE)    exit 0 ;;
 +
    *)        RET=$REQ ;;
 +
  esac
 +
fi
 +
 
 +
#Für GET
 +
echo "$RET"
 +
case "$RET" in
 +
  $PLACE.1) echo "string"; echo "life the universe and everything"; exit 0 ;;
 +
  $PLACE.2.1) echo "integer"; echo "42"; exit 0 ;;
 +
  $PLACE.2.2) echo "objectid"; echo ".1.3.6.1.4.42.42.42"; exit 0 ;;
 +
  $PLACE.3) echo "timeticks"; echo "363136200"; exit 0 ;;
 +
  $PLACE.4) echo "ipaddress"; echo "127.0.0.1" ;;
 +
  $PLACE.5) echo "counter"; echo "42"; exit 0 ;;
 +
  $PLACE.6) echo "gauge"; echo "42"; exit 0 ;;
 +
  *) echo "string"; echo "ack... $RET $REQ"; exit 0 ;;
 +
esac
 +
 
 +
 
 +
</source>  
 +
 
 +
[[Snmpd.conf]]
 +
 
 +
[[Category:Ubuntu]] [[Category:Bash]] [[Category:SNMP]]

Aktuelle Version vom 10:41, 5. Sep. 2010

#!/bin/sh -f
 
PATH=$PATH:/bin:/usr/bin:/usr/ucb
 
#Dieses Script verarbeitet welche OID?
PLACE=".1.3.6.1.4.1.2021.255"
 
#Die übergebene OID
REQ="$2"
 
#Für SET
if [ "$1" = "-s" ]; then
  echo $* >> /tmp/passtest.log
  exit 0
fi
 
#Für GETNEXT
if [ "$1" = "-n" ]; then
  case "$REQ" in
    $PLACE)      RET=$PLACE.1 ;;
    $PLACE.1)    RET=$PLACE.2.1 ;;
    $PLACE.2.1)  RET=$PLACE.2.2 ;;
    $PLACE.2.2)  RET=$PLACE.3 ;;
    $PLACE.3)    RET=$PLACE.4 ;;
    $PLACE.4)    RET=$PLACE.5 ;;
    $PLACE.5)    RET=$PLACE.6 ;;
    *)           exit 0 ;;
  esac
else
  case "$REQ" in
    $PLACE)    exit 0 ;;
    *)         RET=$REQ ;;
  esac
fi
 
#Für GET
echo "$RET"
case "$RET" in
  $PLACE.1) echo "string"; echo "life the universe and everything"; exit 0 ;;
  $PLACE.2.1) echo "integer"; echo "42"; exit 0 ;;
  $PLACE.2.2) echo "objectid"; echo ".1.3.6.1.4.42.42.42"; exit 0 ;;
  $PLACE.3) echo "timeticks"; echo "363136200"; exit 0 ;;
  $PLACE.4) echo "ipaddress"; echo "127.0.0.1" ;;
  $PLACE.5) echo "counter"; echo "42"; exit 0 ;;
  $PLACE.6) echo "gauge"; echo "42"; exit 0 ;;
  *) echo "string"; echo "ack... $RET $REQ"; exit 0 ;;
esac

Snmpd.conf

Persönliche Werkzeuge