Benutzer-Werkzeuge

Webseiten-Werkzeuge


de:sysadmin:tools:cisco-css-oid2string

Cisco-CSS SNMP: oid2string + string2oid (Python Script)

#!/usr/bin/env python

"""
css-oid.py
for encoding / decoding the name parts of Cisco CSS OIDs
as one might encounter with snmpget / snmpwalk
"""

import sys

def txt2oid(txt):
  l=len(txt)
  out="%s" % l
  i=0
  while (i<l):
    c=txt[i]
    out="%s.%s" % (out,ord(c))
    i=i+1
  return out

def oid2txt(oid):
  l=9999
  liste=oid.split('.')
  if (liste[0] =="") or (chr(int(liste[0]))<32):
        l=liste[0]
        liste=liste[1:]
  out=""
  restliste=[]

  if (int(liste[0]) < 65):
    l=int(liste[0])
    restliste=liste[l+2:]
    liste=liste[1:l+1]
    restoid=string.join(restliste,'.')

  for item in liste:
        item=int(item)
        out="%s%s" % (out,chr(item))
  if (len(restliste)>0):
    out=out + " " + oid2txt(restoid)

  return out

if __name__ == '__main__':

    scriptname=sys.argv[0]
    input=sys.argv[1]

    if (input[0].isdigit() or input[0] =='.'):
        print oid2txt(input)
    else:
        print txt2oid(input)

# the end

Verwendung:

$ css-oid.py Beispiel
8.66.101.105.115.112.105.101.108

oder andersrum:

$ css-oid.py 8.66.101.105.115.112.105.101.108
Beispiel


$ css-oid.py 5.79.119.110.101.114.7.86.73.80.114.117.108.101
Owner VIPrule

Owner Bytes

Zusammenhängen:

  • 1.3.6.1.4.1.9.9.368.1.25.2.1.15 = "number of bytes passed using content rules of this owner" 1)
  • 8.66.101.105.115.112.105.101.108 = "Beispiel" → Owner
$ snmpget -v1 -On -c public css07.unixwitch.de 1.3.6.1.4.1.9.9.368.1.25.2.1.15.8.66.101.105.115.112.105.101.108
.1.3.6.1.4.1.9.9.368.1.25.2.1.15.8.66.101.105.115.112.105.101.108 = Counter32: 205197490

Content Rule Bytes

Zusammenhängen:

  • 1.3.6.1.4.1.9.9.368.1.16.4.1.25 = "number of bytes passed using content rule" 2)
$ css-oid.py TheOwner

  • 8.84.104.101.79.119.110.101.114
$ css-oid.py example.com

  • 11.101.120.97.109.112.108.101.46.99.111.109
snmpget -v1 -On -c public css07.unixwitch.de 1.3.6.1.4.1.9.9.368.1.16.4.1.25.8.84.104.101.79.119.110.101.114.11.101.120.97.109.112.108.101.46.99.111.109 
.1.3.6.1.4.1.9.9.368.1.16.4.1.25.8.84.104.101.79.119.110.101.114.11.101.120.97.109.112.108.101.46.99.111.109 = Counter32: 3888751450
1) , 2) ohne Gewähr
de/sysadmin/tools/cisco-css-oid2string.txt · Zuletzt geändert: 2010-03-16 09:11 von hella

Seiten-Werkzeuge