コード例 #1
0
ファイル: cmd.py プロジェクト: tegola-hubs/dendria
def interrogate(args):
    db = get_db(args)
    hostname = args.hostname[0]
    authinfo = db.authinfo.find_one({"name": hostname})
    if authinfo is None:
        authinfo = {"name": hostname}
    default = db.authinfo.find_one({"name": "default"})
    if default is None:
        authinfo = {}

    descriptions = {}
    if args.snmp:
        for community in authinfo.get("community", []) + default.get("community", []):
            log.info("querying with SNMP community: %s" % community)
            try:
                from snmp import interrogate_snmp
                descriptions["snmp"] = interrogate_snmp(hostname, community=community)
                authinfo["community"] = [community]
                break
            except:
                pass

    if args.login:
        for u,p in authinfo.get("login", []) + default.get("login", []):
            log.info("logging in as user: %s" % u)
            try:
                from rlogin import interrogate_rlogin
                descriptions["login"] = interrogate_rlogin(host=hostname,
                                                           username=u, password=p)
                authinfo["login"] = [(u,p)]
                break
            except:
                pass

    db.authinfo.save(authinfo)

    try:
        ident = pkey_check(descriptions)
    except PKeyError, e:
        log.warning("%s\n%s" % (e, format_exc(e)))
        return
コード例 #2
0
ファイル: interrogate.py プロジェクト: tegola-hubs/dendria
def interrogate(host, **kw):
    result = {}
    try:
        result["snmp"] = interrogate_snmp(host, **kw)
    except Exception, e:
        log.warning(str(e) + "\n" + format_exc())