Initial commit: LAN Checker

Network health monitoring script with MQTT reporting for Home Assistant.
- Ping, HTTP, and SNMP checkers
- MQTT Discovery for automatic entity creation
- Configurable check intervals

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-26 16:22:55 +01:00
commit 02b14979bc
11 changed files with 536 additions and 0 deletions

53
checkers/http.py Normal file
View File

@@ -0,0 +1,53 @@
import time
import requests
from .base import BaseChecker, CheckResult
class HttpChecker(BaseChecker):
def check(self) -> CheckResult:
url = self.config["url"]
method = self.config.get("method", "GET").upper()
timeout = self.config.get("timeout", 10)
expected_status = self.config.get("expected_status", 200)
verify_ssl = self.config.get("verify_ssl", True)
headers = self.config.get("headers", {})
start = time.time()
try:
response = requests.request(
method=method,
url=url,
timeout=timeout,
verify=verify_ssl,
headers=headers
)
response_time = (time.time() - start) * 1000 # ms
if response.status_code == expected_status:
return CheckResult(
success=True,
message=f"HTTP {response.status_code}",
response_time=response_time,
details={"status_code": response.status_code}
)
else:
return CheckResult(
success=False,
message=f"Unexpected status: {response.status_code} (expected {expected_status})",
response_time=response_time,
details={"status_code": response.status_code}
)
except requests.Timeout:
return CheckResult(
success=False,
message="HTTP timeout",
response_time=None
)
except requests.RequestException as e:
return CheckResult(
success=False,
message=f"HTTP error: {e}",
response_time=None
)