Exemplo n.º 1
0
def get_manager(device, community):
    sd = SNMP.sessionData(device, version=1)
    sd.add_community(community, SNMP.RW)
    sess = SNMP.new_session(sd)
    dev = DellSwitchManager(sess)
    dev.add_mibs(MIBS)
    return dev
Exemplo n.º 2
0
def get_manager(device, community):
    sd = SNMP.sessionData(device, version=1)
    sd.add_community(community, SNMP.RW)
    sess = SNMP.new_session(sd)
    dev = HPSwitchManager(sess)
    dev.add_mibs(MIBS)
    return dev
Exemplo n.º 3
0
def get_manager(device, community, manager_class=Manager, mibs=None):
    sd = SNMP.sessionData(device, version=1)
    sd.add_community(community, SNMP.RW)
    sess = SNMP.new_session(sd)
    dev = manager_class(sess)
    if mibs:
        if type(mibs[0]) is str:
            mibs = list([__import__("pycopia.mibs.%s" % n, globals(), locals(), ["*"]) for n in mibs])
        dev.add_mibs(mibs)
    return dev
Exemplo n.º 4
0
def get_manager(device, community, manager_class=Manager, mibs=None):
    sd = SNMP.sessionData(device, version=1)
    sd.add_community(community, SNMP.RW)
    sess = SNMP.new_session(sd)
    dev = manager_class(sess)
    if mibs:
        if type(mibs[0]) is str:
            mibs = list([__import__("pycopia.mibs.%s" % n, globals(), locals(), ["*"]) for n in mibs])
        dev.add_mibs(mibs)
    return dev
Exemplo n.º 5
0
def main(argv):
    host = argv[1]
    sd = SNMP.sessionData(host)
    if len(argv) > 2:
        sd.add_community(argv[2])
    else:
        sd.add_community("public")
    sess = SNMP.new_session(sd)
    mgr = Manager.Manager(sess)
    mgr.add_mib(SNMPv2_MIB)
    ors = mgr.getall("sysOR")
    for ore in ors:
        print ore
Exemplo n.º 6
0
def main(argv):
    host = argv[1]
    sd = SNMP.sessionData(host)
    if len(argv) > 2:
        sd.add_community(argv[2])
    else:
        sd.add_community("public")
    sess = SNMP.new_session(sd)
    mgr = Manager.Manager(sess)
    mgr.add_mib(SNMPv2_MIB)
    ors = mgr.getall("sysOR")
    for ore in ors:
        print ore
Exemplo n.º 7
0
def get_manager(sessiondata):
    sessiondata.version = 0 # APC still only SNMPv1 !
    sess = SNMP.new_session(sessiondata)
    dev = APCManager(sess)
    dev.add_mibs([SNMPv2_MIB])
    dev.add_mib(PowerNet_MIB, apc_mangler, subclassmodule=sys.modules[__name__])
    return dev
Exemplo n.º 8
0
def unicast_packets(argv, community="public"):
    """Display a set of strip charts, one for each set of parameters in argv.
    The set is a "host interface" pair. For example: device1 2 device2 4 """

    win = gtk.Window(gtk.WINDOW_TOPLEVEL)
    win.set_title("Unicast Packets")

    vbox = gtk.VBox()
    vbox.show()
    win.add(vbox)

    sessions = {}

    while argv:
        host = argv.pop(0)
        ifindex = int(argv.pop(0))

        if host in sessions:
            sess = sessions[host]
        else:
            sess = SNMP.get_session(host, community)
            sessions[host] = sess

        graph = rtgraph.HScrollLineGraph(
            scrollRate=2,
            pollInterval=1000,
            size=(384, 128),
            gridSize=32,
            channels=[
                SNMPChannel(sess,
                            IF_MIB.ifInUcastPkts,
                            ifindex,
                            color=(1, 0, 0)),
                SNMPChannel(sess,
                            IF_MIB.ifOutUcastPkts,
                            ifindex,
                            color=(0, 1, 0))
            ],
            bgColor=(0, 0, 0.3),
            gridColor=(0, 0, 0.5),
            range=(0, 19),
        )
        graph.show()

        frame = gtk.Frame()
        frame.set_label("device %s ifindex %s" % (host, ifindex))
        frame.add(graph)
        frame.show()

        vbox.pack_end(frame)

    del sessions
    win.show()
    win.connect("destroy", gtk.main_quit)
    gtk.main()
Exemplo n.º 9
0
def unicast_packets(argv, community="public"):
    """Display a set of strip charts, one for each set of parameters in argv.
    The set is a "host interface" pair. For example: device1 2 device2 4 """

    win = gtk.Window(gtk.WINDOW_TOPLEVEL)
    win.set_title("Unicast Packets")

    vbox = gtk.VBox()
    vbox.show()
    win.add(vbox)

    sessions = {}

    while argv:
        host = argv.pop(0)
        ifindex = int(argv.pop(0))

        if host in sessions:
            sess = sessions[host]
        else:
            sess = SNMP.get_session(host, community)
            sessions[host] = sess

        graph = rtgraph.HScrollLineGraph(
            scrollRate = 2,
            pollInterval = 1000,
            size       = (384,128),
            gridSize   = 32,
            channels   = [SNMPChannel(sess, IF_MIB.ifInUcastPkts, ifindex, color=(1,0,0)),
                          SNMPChannel(sess, IF_MIB.ifOutUcastPkts, ifindex, color=(0,1,0))],
            bgColor    = (0, 0, 0.3),
            gridColor  = (0, 0, 0.5),
            range      = (0, 19),
            )
        graph.show()

        frame = gtk.Frame()
        frame.set_label("device %s ifindex %s" % (host, ifindex))
        frame.add(graph)
        frame.show()

        vbox.pack_end(frame)

    del sessions
    win.show()
    win.connect("destroy", gtk.main_quit)
    gtk.main()
Exemplo n.º 10
0
def get_manager(host, community):
    box = SNMP.get_session(host, community)
    device = DiscoverManager(box)
    device.add_mibs([SNMPv2_MIB, IF_MIB, IP_MIB, RFC1213_MIB])
    device.add_mibs([CDP_MIB, LLDP_MIB])
    return device
Exemplo n.º 11
0
def get_manager(sessiondata):
    sess = SNMP.new_session(sessiondata)
    dev = LinuxManager(sess)
    dev.add_mibs([SNMPv2_MIB, HOST_RESOURCES_MIB])
    dev.add_mib(UCD_SNMP_MIB, subclassmodule=sys.modules[__name__])
    return dev
Exemplo n.º 12
0
def get_manager(host, community):
    box = SNMP.get_session(host, community)
    device = DiscoverManager(box)
    device.add_mibs([SNMPv2_MIB, IF_MIB, IP_MIB, RFC1213_MIB])
    device.add_mibs([CDP_MIB, LLDP_MIB])
    return device
Exemplo n.º 13
0
def get_session(sessiondata):
    sess = SNMP.new_session(sessiondata)
    dev = DellSwitchManager(sess)
    dev.add_mibs(MIBS)
    return dev
Exemplo n.º 14
0
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#    Lesser General Public License for more details.
"""
Demo SNMP API.
Supply a host and community on the command line.

"""

import sys
from pycopia.SNMP import SNMP

# common code - get an SNMP session object.
host = sys.argv[1]
community = sys.argv[2]

box = SNMP.get_session(host, community)

# bug here... must import Python mibs so that OIDMAP gets created.
from pycopia.mibs import SNMPv2_MIB
from pycopia.mibs import IF_MIB

print "Direct OID list method:"
print box.get([1, 3, 6, 1, 2, 1, 1, 5, 0])  # get OID from some other source
print

print "MIB node and raw SNMP method:"
try:
    from pycopia.SMI import SMI
except ImportError, err:
    print err
    print "you need libsmi and the libsmi wrappers installed for this demo."
Exemplo n.º 15
0
def get_manager(sessiondata):
    sess = SNMP.new_session(sessiondata)
    dev = ExtremeManager(sess)
    dev.add_mibs(MIBS)
    return dev
Exemplo n.º 16
0
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Demo SNMP API.
Supply a host and community on the command line.

"""

import sys
from pycopia.SNMP import SNMP

# common code - get an SNMP session object.
host = sys.argv[1] ; community = sys.argv[2]

box = SNMP.get_session(host, community)

# bug here... must import Python mibs so that OIDMAP gets created.
from pycopia.mibs import SNMPv2_MIB
from pycopia.mibs import IF_MIB

print "Direct OID list method:"
print box.get([1, 3, 6, 1, 2, 1, 1, 5, 0]) # get OID from some other source
print

print "MIB node and raw SNMP method:"
try:
    from pycopia.SMI import SMI
except ImportError, err:
    print err
    print "you need libsmi and the libsmi wrappers installed for this demo."
Exemplo n.º 17
0
def get_manager(sessiondata):
    sess = SNMP.new_session(sessiondata)
    dev = LinuxManager(sess)
    dev.add_mibs([SNMPv2_MIB, HOST_RESOURCES_MIB])
    dev.add_mib(UCD_SNMP_MIB, subclassmodule=sys.modules[__name__])
    return dev
Exemplo n.º 18
0
def get_session(sessiondata):
    sess = SNMP.new_session(sessiondata)
    dev = HPSwitchManager(sess)
    dev.add_mibs(MIBS)
    return dev
Exemplo n.º 19
0
def get_manager(sessiondata):
    sess = SNMP.new_session(sessiondata)
    dev = ExtremeManager(sess)
    dev.add_mibs(MIBS)
    return dev