Beispiel #1
0
            print('Cannot found %s in config_huawei.json file.' % monitor)
            exit(1)
        will_moniter.append([monitor, spiders[monitor]])
    return will_moniter


if __name__ == '__main__':
    if len(sys.argv) == 2:
        config_file = sys.argv[1]
    elif len(sys.argv) == 1:
        config_file = './config_huawei.json'
    else:
        print("Example: \n"
              "  python3 monitor.py\n"
              "  python3 monitor.py ./config_huawei.json")
        exit(1)

    Config.config_file = config_file
    spiders = get_monitors()
    hosts = Config.get_hosts()
    source_dir = Config.get_sources_dir()
    while True:
        for spider in spiders:
            dprint("check spider: %s" % spider[0])
            for host in hosts:
                dprint("...check on host: %s" % host)
                check_and_start(host, source_dir, spider[0], spider[1])
            print("")
        print("wait 120 seconds...\n")
        time.sleep(120)