Example #1
0
def main(config_file):
    config = load_config(config_file)

    start_http_server(config['global']['exporter']['port'])

    collector_class = get_collector(config)
    collector = collector_class(config['collector'])
    collector.setup()

    category_list = config['collector']['category_list']
    tasks_config = config['tasks']
    print('getting ssh client...')
    tasks = []
    for a_task in tasks_config:
        client = get_ssh_client(a_task['auth'])

        tasks.append({
            'owner': a_task['owner'],
            'repo': a_task['repo'],
            'auth': a_task['auth'],
            'category_list': category_list,
            'client': client,
        })

    print('exporter is working...')
    while True:
        collector.process_request(tasks)
Example #2
0
def main():
    with open(os.path.join(get_dist_directory(), "conf/test.config.yml"), 'r') as config_file:
        config = yaml.load(config_file)
    auth = config['auth']
    client = get_ssh_client(auth)
    category_list = config['aix_category_list']
    model = get_disk_usage(category_list, client)
    print(json.dumps(model.to_dict(), indent=2))
Example #3
0
    def process_request(self, tasks):
        t = 5
        for a_task in tasks:
            auth = a_task['auth']

            try:
                self.process_single_task(a_task)
            except paramiko.ssh_exception.SSHException as ssh_exception:
                print(datetime.datetime.now(), "reconnect ssh")
                a_task['client'] = get_ssh_client(auth)
            except socket.gaierror as socket_exception:
                print(datetime.datetime.now(), "get socket gaierror exception.")
                print(datetime.datetime.now(), "wait 5 seconds...")
                time.sleep(5)
                print(datetime.datetime.now(), "reconnect ssh")
                a_task['client'] = get_ssh_client(auth)

        time.sleep(t)