Skip to content

Commit

Permalink
Allow defining the outside monitor URL via an environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Dec 26, 2024
1 parent 04d1c1d commit 514b83b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ heartbeats:

To add a new heartbeat, simply add it to the `heartbeats` section and then have the client responsible for it send `lvmbeat set <heartbeat_name>` every few seconds (but more frequently than `timeout`).

The `outside_monitor` section defines the outside URL that the actor will call every `outside_monitor.interval`. `send_email_after` indicates how long the external monitor service will wait after it has not received a heartbeat to send an alert email.
The `outside_monitor` section defines the outside URL that the actor will call every `outside_monitor.interval`. `send_email_after` indicates how long the external monitor service will wait after it has not received a heartbeat to send an alert email. The `url` value must be replaced with the URL of the external monitor service. The URL can also be defined by setting the environment variable `LVMBEAT_OUTSIDE_MONITOR_URL`.

### Status command

Expand Down
7 changes: 6 additions & 1 deletion src/lvmbeat/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from __future__ import annotations

import asyncio
import os
from time import time

from typing import Annotated, TypedDict
Expand Down Expand Up @@ -151,7 +152,11 @@ async def update(self):
async def emit_outside(self):
"""Emits a heartbeat to the outside world."""

outside_url = config["outside_monitor"]["url"]
outside_url = os.getenv(
"LVMBEAT_OUTSIDE_MONITOR_URL",
config["outside_monitor"]["url"],
)

if not outside_url:
self.log.warning(
"No outside monitor URL defined. Will not emit "
Expand Down

0 comments on commit 514b83b

Please sign in to comment.