示例#1
0
def main():
    """
    Main entry point.
    """

    parser = ArgumentParser()
    parser.add_argument('config',
                        nargs='?',
                        default='pve.yml',
                        help='Path to configuration file (pve.yml)')
    parser.add_argument('port',
                        nargs='?',
                        type=int,
                        default='9221',
                        help='Port on which the exporter is listening (9221)')
    parser.add_argument('address',
                        nargs='?',
                        default='',
                        help='Address to which the exporter will bind')

    params = parser.parse_args()

    # Load configuration.
    with open(params.config) as handle:
        config = config_from_yaml(yaml.safe_load(handle))

    if config.valid:
        start_http_server(config, params.port, params.address)
    else:
        parser.error(str(config))
def main():
    """
    Main entry point.
    """

    parser = ArgumentParser()
    parser.add_argument('--collector.status',
                        dest='collector_status',
                        action=BooleanOptionalAction,
                        default=True,
                        help='Exposes Node/VM/CT-Status')
    parser.add_argument('--collector.version',
                        dest='collector_version',
                        action=BooleanOptionalAction,
                        default=True,
                        help='Exposes PVE version info')
    parser.add_argument('--collector.node',
                        dest='collector_node',
                        action=BooleanOptionalAction,
                        default=True,
                        help='Exposes PVE node info')
    parser.add_argument('--collector.cluster',
                        dest='collector_cluster',
                        action=BooleanOptionalAction,
                        default=True,
                        help='Exposes PVE cluster info')
    parser.add_argument('--collector.resources',
                        dest='collector_resources',
                        action=BooleanOptionalAction,
                        default=True,
                        help='Exposes PVE resources info')
    parser.add_argument('--collector.config',
                        dest='collector_config',
                        action=BooleanOptionalAction,
                        default=True,
                        help='Exposes PVE onboot status')
    parser.add_argument('config',
                        nargs='?',
                        default='pve.yml',
                        help='Path to configuration file (pve.yml)')
    parser.add_argument('port',
                        nargs='?',
                        type=int,
                        default='9221',
                        help='Port on which the exporter is listening (9221)')
    parser.add_argument('address',
                        nargs='?',
                        default='',
                        help='Address to which the exporter will bind')

    params = parser.parse_args()

    collectors = CollectorsOptions(status=params.collector_status,
                                   version=params.collector_version,
                                   node=params.collector_node,
                                   cluster=params.collector_cluster,
                                   resources=params.collector_resources,
                                   config=params.collector_config)

    # Load configuration.
    if 'PVE_USER' in os.environ:
        config = config_from_env(os.environ)
    else:
        with open(params.config) as handle:
            config = config_from_yaml(yaml.safe_load(handle))

    if config.valid:
        start_http_server(config, params.port, params.address, collectors)
    else:
        parser.error(str(config))