Ejemplo n.º 1
0
def parse_command_line():
    parser = cli.create_parser(
        name='Prometheus',
        field_ids=DEFAULT_FIELDS,
    )

    cli.add_custom_argument(parser, '--send-uuid', dest='send_uuid', default=False,
                            action='store_true', help='Send GPU UUID instead of bus id')

    args = cli.run_parser(parser)
    field_ids = cli.get_field_ids(args)
    numeric_log_level = cli.get_log_level(args)

    # Defaults to localhost, so we need to set it to None
    if args.embedded:
        g_settings['dcgmHostName'] = None
    else:
        g_settings['dcgmHostName'] = args.hostname

    g_settings['prometheusPort'] = args.publish_port

    g_settings['prometheusPublishInterval'] = args.interval

    logfile = args.logfile

    g_settings['publishFieldIds'] = field_ids

    g_settings['sendUuid'] = args.send_uuid

    if logfile != None:
        logging.basicConfig(level=numeric_log_level, filename=logfile, filemode='w+', format='%(asctime)s %(levelname)s: %(message)s')
    else:
        logging.basicConfig(level=numeric_log_level, filemode='w+', format='%(asctime)s %(levelname)s: %(message)s')
Ejemplo n.º 2
0
def test_run_parser():
    parser = maybemock.Mock()
    cli.run_parser(parser)
    parser.parse_args.assert_called()