Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add flag -version #71

Merged
merged 2 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ $ ./pbs-exporter -help

You can use the following flags to configure the exporter. All flags can also be set using environment variables. Environment variables take precedence over flags.

| Flag | Environment Variable | Description | Default |
| ------------------------ | -------------------- | ---------------------------------------------------- | ------------------------------------------------------ |
| `pbs.loglevl` | `PBS_LOGLEVEL` | Log level (debug, info) | `info` |
| `pbs.api.token` | `PBS_API_TOKEN` | API token to use for authentication | |
| `pbs.api.token.name` | `PBS_API_TOKEN_NAME` | Name of the API token to use for authentication | `pbs-exporter` |
| `pbs.endpoint` | `PBS_ENDPOINT` | Address of the Proxmox Backup Server | `http://localhost:8007` (if no parameter `target` set) |
| `pbs.username` | `PBS_USERNAME` | Username to use for authentication | `root@pam` |
| `pbs.timeout` | `PBS_TIMEOUT` | Timeout for requests to Proxmox Backup Server | `5s` |
| `pbs.insecure` | `PBS_INSECURE` | Disable TLS certificate verification | `false` |
| `pbs.metrics-path` | `PBS_METRICS_PATH` | Path under which to expose metrics | `/metrics` |
| `pbs.web.listen-address` | `PBS_LISTEN_ADDRESS` | Address to listen on for web interface and telemetry | `:10019` |
| Flag | Environment Variable | Description | Default |
| -------------------- | -------------------- | ---------------------------------------------------- | ------------------------------------------------------ |
| `pbs.loglevel` | `PBS_LOGLEVEL` | Log level (debug, info) | `info` |
| `pbs.api.token` | `PBS_API_TOKEN` | API token to use for authentication | |
| `pbs.api.token.name` | `PBS_API_TOKEN_NAME` | Name of the API token to use for authentication | `pbs-exporter` |
| `pbs.endpoint` | `PBS_ENDPOINT` | Address of the Proxmox Backup Server | `http://localhost:8007` (if no parameter `target` set) |
| `pbs.username` | `PBS_USERNAME` | Username to use for authentication | `root@pam` |
| `pbs.timeout` | `PBS_TIMEOUT` | Timeout for requests to Proxmox Backup Server | `5s` |
| `pbs.insecure` | `PBS_INSECURE` | Disable TLS certificate verification | `false` |
| `pbs.metrics-path` | `PBS_METRICS_PATH` | Path under which to expose metrics | `/metrics` |
| `pbs.listen-address` | `PBS_LISTEN_ADDRESS` | Address to listen on for web interface and telemetry | `:10019` |

### Docker secrets

Expand Down
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ var (
"Address on which to expose metrics")
loglevel = flag.String("pbs.loglevel", "info",
"Loglevel")
showVersion = flag.Bool("version", false, "Show version and exit")

// Metrics
up = prometheus.NewDesc(
Expand Down Expand Up @@ -756,6 +757,11 @@ func findLastSnapshotWithBackupID(response SnapshotResponse, backupID string) (i
func main() {
flag.Parse()

if *showVersion {
fmt.Printf("PBS Exporter Version: %s, Commit: %s, Build Time: %s\n", Version, Commit, BuildTime)
os.Exit(0)
}

// log build information
log.Printf("INFO: Starting PBS Exporter %s, commit %s, built at %s", Version, Commit, BuildTime)

Expand Down
Loading