Skip to content

Commit

Permalink
Merge pull request #1 from kumar1202/add-config-arg
Browse files Browse the repository at this point in the history
Add wal-g config file path as an optional argument
  • Loading branch information
jasoet authored Jul 21, 2021
2 parents 29299df + 43b132d commit 87b37ec
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ If there is no output from the query, then this exporter won't run and give an e
## Usage

```
usage: wal-g-exporter [-h] --archive_dir ARCHIVE_DIR [--debug] [--version]
usage: wal-g-exporter [-h] --archive_dir ARCHIVE_DIR [--debug] [--config] CONFIG_FILE_PATH [--version]
optional arguments:
-h, --help show this help message and exit
--archive_dir ARCHIVE_DIR
pg_wal/archive_status/ Directory location
--config CONFIG_FILE_PATH
file path for wal-g config
--debug enable debug log
--version show binary version
```
10 changes: 8 additions & 2 deletions exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
parser.version = "0.1.0"
parser.add_argument("--archive_dir",
help="pg_wal/archive_status/ Directory location", action="store", required=True)
parser.add_argument("--config", help="walg config file path", action="store")
parser.add_argument("--debug", help="enable debug log", action="store_true")
parser.add_argument("--version", help="show binary version", action="version")

args = parser.parse_args()
if args.debug:
logging.basicConfig(level=logging.DEBUG)
Expand Down Expand Up @@ -167,8 +169,12 @@ def update_basebackup(self, *unused):
info('Updating basebackups metrics...')
try:
# Fetch remote backup list
res = subprocess.run(["wal-g", "backup-list",
"--detail", "--json"],
command = ["wal-g", "backup-list",
"--detail", "--json"]
if args.config:
command.extend(["--config", args.config])

res = subprocess.run(command,
capture_output=True, check=True)

# Check if backup-list return an empty result
Expand Down

0 comments on commit 87b37ec

Please sign in to comment.