Beispiel #1
0
def snmpcli(argv):
    """snmpcli [-h] [-p <port>] [-s <scriptname>] [-m <module>] host community

Provides an interactive session to an SNMP agent.
    """
    port = 161
    sourcefile = None
    logfile = None
    modname = None
    try:
        optlist, longopts, args = getopt.getopt(argv[1:], "hl:p:s:m:")
    except getopt.GetoptError:
        print(snmpcli.__doc__)
        return
    for opt, val in optlist:
        if opt == "-s":
            sourcefile = val
        elif opt == "-l":
            logfile = val
        elif opt == "-h":
            print(snmpcli.__doc__)
            return
        elif opt == "-p":
            try:
                port = int(val)
            except ValueError:
                print(snmpcli.__doc__)
                return
        elif opt == "-m":
            modname = val

    if not args:
        print(snmpcli.__doc__)
        return

    host = args[0]
    if len(args) > 1:
        community = args[1]
    else:
        community = "public"

    if modname:
        module = __import__(modname, globals(), locals(), ["*"])
        manager = module.get_manager(host, community)
    else:
        manager = Manager.get_manager(host, community, mibs=[SNMPv2_MIB, IF_MIB])

    parser = CLI.get_generic_cli(
        manager, SNMPManagerCommands, logfile=logfile, historyfile=os.path.expandvars("$HOME/.hist_snmpcli")
    )

    if sourcefile:
        try:
            parser.parse(sourcefile)
        except CLI.CommandQuit:
            pass
    else:
        parser.interact()
Beispiel #2
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
Beispiel #3
0
def snmpcli(argv):
    """snmpcli [-h] [-p <port>] [-s <scriptname>] [-m <module>] host community

Provides an interactive session to an SNMP agent.
    """
    port = 161
    sourcefile = None
    logfile = None
    modname = None
    try:
        optlist, longopts, args = getopt.getopt(argv[1:], "hl:p:s:m:")
    except getopt.GetoptError:
        print(snmpcli.__doc__)
        return
    for opt, val in optlist:
        if opt == "-s":
            sourcefile = val
        elif opt == "-l":
            logfile = val
        elif opt == "-h":
            print(snmpcli.__doc__)
            return
        elif opt == "-p":
            try:
                port = int(val)
            except ValueError:
                print(snmpcli.__doc__)
                return
        elif opt == "-m":
            modname = val

    if not args:
        print(snmpcli.__doc__)
        return

    host = args[0]
    if len(args) > 1:
        community = args[1]
    else:
        community = "public"

    if modname:
        module = __import__(modname, globals(), locals(), ["*"])
        manager = module.get_manager(host, community)
    else:
        manager = Manager.get_manager(host,
                                      community,
                                      mibs=[SNMPv2_MIB, IF_MIB])

    parser = CLI.get_generic_cli(
        manager,
        SNMPManagerCommands,
        logfile=logfile,
        historyfile=os.path.expandvars("$HOME/.hist_snmpcli"))

    if sourcefile:
        try:
            parser.parse(sourcefile)
        except CLI.CommandQuit:
            pass
    else:
        parser.interact()
Beispiel #4
0
def get_manager(device, community):
    return Manager.get_manager(device, community, APCManager, MIBS)
def _test(argv):
    device = argv[1]
    community = "Private" if len(argv) < 2 else argv[2]
    mgr = Manager.get_manager(device, community)
    print(mgr.get_outlets())
def get_manager(device, community):
    mgr = Manager.get_manager(device, community, Sentry3Manager)
    mgr.add_mib(SNMPv2_MIB)
    mgr.add_mib(Sentry3_MIB, subclassmodule=sys.modules[__name__])
    return mgr
Beispiel #7
0
def get_manager(device, community):
    return Manager.get_manager(device, community, ExtremeManager, MIBS)
Beispiel #8
0
def get_manager(device, community):
    return Manager.get_manager(device, community, BridgeManager, MIBS)
def get_manager(device, community):
    mgr = Manager.get_manager(device, community, Sentry3Manager)
    mgr.add_mib(SNMPv2_MIB)
    mgr.add_mib(Sentry3_MIB, subclassmodule=sys.modules[__name__])
    return mgr
Beispiel #10
0
def get_manager(device, community):
    return Manager.get_manager(device, community, LinuxManager, MIBNAMES)
Beispiel #11
0
def get_manager(device, community):
    return Manager.get_manager(device, community, ExtremeManager, MIBS)
Beispiel #12
0
def get_manager(device, community):
    return Manager.get_manager(device, community, BridgeManager, MIBS)
Beispiel #13
0
def get_manager(device, community):
    return Manager.get_manager(device, community, C3560Manager, MIBNAMES)
Beispiel #14
0
def _test(argv):
    device = argv[1]
    community = "Private" if len(argv) < 2 else argv[2]
    mgr = Manager.get_manager(device, community)
    print(mgr.get_outlets())
Beispiel #15
0
def get_manager(device, community):
    return Manager.get_manager(device, community, APCManager, MIBS)
Beispiel #16
0
def get_manager(device, community):
    return Manager.get_manager(device, community, LinuxManager, MIBNAMES)
Beispiel #17
0
def get_manager(device, community):
    return Manager.get_manager(device, community, C3560Manager, MIBNAMES)